Class DaemonWrapper
- java.lang.Object
-
- org.apache.commons.daemon.support.DaemonWrapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
DaemonWrapper.Invoker
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ARGS
private DaemonConfiguration
config
private java.lang.String
configFileName
private DaemonWrapper.Invoker
shutdown
private static java.lang.String
START_CLASS
private static java.lang.String
START_METHOD
private DaemonWrapper.Invoker
startup
private static java.lang.String
STOP_ARGS
private static java.lang.String
STOP_CLASS
private static java.lang.String
STOP_METHOD
-
Constructor Summary
Constructors Constructor Description DaemonWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Frees any resources allocated by this daemon such as file descriptors or sockets.void
init(DaemonContext context)
Called from DaemonLoader on init stage.void
start()
Starts the operation of thisDaemon
instance.void
stop()
Stops the operation of thisDaemon
instance.
-
-
-
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:
init
in interfaceDaemon
- Parameters:
context
- ADaemonContext
object 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.Exception
Description copied from interface:Daemon
Starts the operation of thisDaemon
instance. 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.Exception
Description copied from interface:Daemon
Stops the operation of thisDaemon
instance. 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:Daemon
Frees 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.
-
-