Class 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.Daemon
    Class for starting/stopping jadex as a service / daemon.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String[] args
      The arguments for starting jadex.
      protected static ServiceStarter instance
      Singleton of service handler.
      protected IExternalAccess platform
      The 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
      void destroy()
      Frees any resources allocated by this daemon such as file descriptors or sockets.
      protected void doStart()
      Do the actual starting.
      protected void doStop()
      Do the actual starting.
      protected IPlatformConfiguration getConfig()
      Get the platform configuration.
      void init​(org.apache.commons.daemon.DaemonContext context)
      Initializes this Daemon instance.
      void start()
      Starts the operation of this Daemon instance.
      static void start​(java.lang.String[] args)
      Static method called by prunsrv to start the Windows service.
      void stop()
      Stops the operation of this Daemon instance.
      static void stop​(java.lang.String[] args)
      Static method called by prunsrv to stop the Windows service.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • instance

        protected static ServiceStarter instance
        Singleton of service handler.
      • args

        protected java.lang.String[] args
        The arguments for starting jadex.
    • Constructor Detail

      • ServiceStarter

        public ServiceStarter()
        Bean constructor for Unix daemon.
      • ServiceStarter

        public ServiceStarter​(java.lang.String[] args)
        Constructor for Windows service.
    • 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.Exception
        Initializes this Daemon instance. 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 the ServerSocket.accept() method) as this would impose some serious security hazards. The start of operation must be performed in the start() method.
        Specified by:
        init in interface org.apache.commons.daemon.Daemon
        Parameters:
        context - A DaemonContext object 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.Exception
        Starts the operation of this Daemon 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.
        Specified by:
        start in interface org.apache.commons.daemon.Daemon
        Throws:
        java.lang.Exception
      • stop

        public void stop()
                  throws java.lang.Exception
        Stops the operation of this Daemon 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().
        Specified by:
        stop in interface org.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:
        destroy in interface org.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.