Package jadex.platform.service
Class ServiceStarter
- java.lang.Object
-
- jadex.platform.service.ServiceStarter
-
- All Implemented Interfaces:
org.apache.commons.daemon.Daemon
- Direct Known Subclasses:
TimeServiceStarter
public class ServiceStarter extends java.lang.Object implements org.apache.commons.daemon.DaemonClass for starting/stopping jadex as a service / daemon.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]argsThe arguments for starting jadex.protected static ServiceStarterinstanceSingleton of service handler.protected IExternalAccessplatformThe jadex platform.
-
Constructor Summary
Constructors Constructor Description ServiceStarter()Bean constructor for Unix daemon.ServiceStarter(java.lang.String[] args)Constructor for Windows service.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Frees any resources allocated by this daemon such as file descriptors or sockets.protected voiddoStart()Do the actual starting.protected voiddoStop()Do the actual starting.protected IPlatformConfigurationgetConfig()Get the platform configuration.voidinit(org.apache.commons.daemon.DaemonContext context)Initializes thisDaemoninstance.voidstart()Starts the operation of thisDaemoninstance.static voidstart(java.lang.String[] args)Static method called by prunsrv to start the Windows service.voidstop()Stops the operation of thisDaemoninstance.static voidstop(java.lang.String[] args)Static method called by prunsrv to stop the Windows service.
-
-
-
Field Detail
-
instance
protected static ServiceStarter instance
Singleton of service handler.
-
platform
protected IExternalAccess platform
The jadex platform.
-
args
protected java.lang.String[] args
The arguments for starting jadex.
-
-
Method Detail
-
start
public static void start(java.lang.String[] args)
Static method called by prunsrv to start the Windows service.
-
stop
public static void stop(java.lang.String[] args)
Static method called by prunsrv to stop the Windows service.
-
init
public void init(org.apache.commons.daemon.DaemonContext context) throws org.apache.commons.daemon.DaemonInitException, java.lang.ExceptionInitializes thisDaemoninstance.Daemon instance is created thru its empty public constructor.
ServerSocket instances within the scope of this method, and perform all operations requiring Daemon (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.- Specified by:
initin interfaceorg.apache.commons.daemon.Daemon- Parameters:
context- ADaemonContextobject used to communicate with the container.- Throws:
org.apache.commons.daemon.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.ExceptionStarts 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.- Specified by:
startin interfaceorg.apache.commons.daemon.Daemon- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.ExceptionStops 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().- Specified by:
stopin interfaceorg.apache.commons.daemon.Daemon- Throws:
java.lang.Exception
-
destroy
public void destroy()
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.- Specified by:
destroyin interfaceorg.apache.commons.daemon.Daemon
-
doStart
protected void doStart()
Do the actual starting. Separate method to get rid of exception.
-
getConfig
protected IPlatformConfiguration getConfig()
Get the platform configuration. Subclass and override for specific use cases.
-
doStop
protected void doStop()
Do the actual starting. Separate method to get rid of exception.
-
-