Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public interface Daemon
Daemon
interface can be initialized, started and
stopped according to the convensions of the underlying operating
system.
Implementors of this interface must also provide a public constructor
with no arguments so that instances can be created in an automated
fashion.
Method Summary | |
void |
|
void |
|
void |
|
void |
|
public void destroy()
Free 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.
public void init(DaemonContext context) throws Exception
Initialize thisDaemon
instance. This method gets called once the JVM process is created and theDaemon
instance is created thru its empty public constructor. Under certain operating systems (typically Unix based operating systems) and if the native invocation framework is configured to do so, this method might be called with super-user privileges. For example, it might be wise to createServerSocket
instances within the scope of this method, and perform all operations requiring super-user privileges in the underlying operating system. Apart from set up and allocation of native resources, this method must not start the actual operation of theDaemon
(such as starting threads calling theServerSocket.accept()
method) as this would impose some serious security hazards. The start of operation must be performed in thestart()
method.
- Parameters:
context
- ADaemonContext
object used to communicate with the container.
public void start() throws Exception
Start 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 avfter having done that to enable invocation of the stop()-method.
public void stop() throws Exception
Stop 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().