Class DaemonWrapper
- java.lang.Object
-
- org.apache.commons.daemon.support.DaemonWrapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classDaemonWrapper.Invoker
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringARGSprivate DaemonConfigurationconfigprivate java.lang.StringconfigFileNameprivate DaemonWrapper.Invokershutdownprivate static java.lang.StringSTART_CLASSprivate static java.lang.StringSTART_METHODprivate DaemonWrapper.Invokerstartupprivate static java.lang.StringSTOP_ARGSprivate static java.lang.StringSTOP_CLASSprivate static java.lang.StringSTOP_METHOD
-
Constructor Summary
Constructors Constructor Description DaemonWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Frees any resources allocated by this daemon such as file descriptors or sockets.voidinit(DaemonContext context)Called from DaemonLoader on init stage.voidstart()Starts the operation of thisDaemoninstance.voidstop()Stops the operation of thisDaemoninstance.
-
-
-
Field Detail
-
ARGS
private static final java.lang.String ARGS
- See Also:
- Constant Field Values
-
START_CLASS
private static final java.lang.String START_CLASS
- See Also:
- Constant Field Values
-
START_METHOD
private static final java.lang.String START_METHOD
- See Also:
- Constant Field Values
-
STOP_CLASS
private static final java.lang.String STOP_CLASS
- See Also:
- Constant Field Values
-
STOP_METHOD
private static final java.lang.String STOP_METHOD
- See Also:
- Constant Field Values
-
STOP_ARGS
private static final java.lang.String STOP_ARGS
- See Also:
- Constant Field Values
-
configFileName
private java.lang.String configFileName
-
config
private final DaemonConfiguration config
-
startup
private final DaemonWrapper.Invoker startup
-
shutdown
private final DaemonWrapper.Invoker shutdown
-
-
Method Detail
-
init
public void init(DaemonContext context) throws java.lang.Exception
Called from DaemonLoader on init stage.Accepts the following configuration arguments:
- -daemon-properties: - load DaemonConfiguration properties from the specified file to act as defaults
- -start: set start class name
- -start-method: set start method name
- -stop: set stop class name
- -stop-method: set stop method name
- -stop-argument: set optional argument to stop method
- Anything else is treated as a startup argument
The following "-daemon-properties" are recognized:
- args (startup argument)
- start
- start.method
- stop
- stop.method
- stop.args
- Specified by:
initin interfaceDaemon- Parameters:
context- ADaemonContextobject used to communicate with the container.- Throws:
DaemonInitException- An exception that prevented initialization where you want to display a nice message to the user, rather than a stack trace.java.lang.Exception- Any exception preventing a successful initialization.
-
start
public void start() throws java.lang.ExceptionDescription copied from interface:DaemonStarts the operation of thisDaemoninstance. This method is to be invoked by the environment after the init() method has been successfully invoked and possibly the security level of the JVM has been dropped. Implementors of this method are free to start any number of threads, but need to return control after having done that to enable invocation of the stop()-method.
-
stop
public void stop() throws java.lang.ExceptionDescription copied from interface:DaemonStops the operation of thisDaemoninstance. Note that the proper place to free any allocated resources such as sockets or file descriptors is in the destroy method, as the container may restart the Daemon by calling start() after stop().
-
destroy
public void destroy()
Description copied from interface:DaemonFrees any resources allocated by this daemon such as file descriptors or sockets. This method gets called by the container after stop() has been called, before the JVM exits. The Daemon can not be restarted after this method has been called without a new call to the init() method.
-
-