Package org.jcsp.net

Class ServiceManager


  • public class ServiceManager
    extends java.lang.Object

    An instance of the ServiceManager is created by the Node when it is initialized. This reference can be obtained from the Node class.

    The class allows the local Node's services to be installed and started. The class does not currently allow services to removed. Services can be stopped by obtaining their reference and stopping them directly.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Hashtable services  
    • Constructor Summary

      Constructors 
      Constructor Description
      ServiceManager()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Service getService​(java.lang.String name)
      Returns the Service object of the service with the specified name.
      java.lang.String[] getServiceNames()
      Returns an array containing an array of String objects which represent the names of the currently installed services.
      boolean installService​(Service service, java.lang.String name)
      Installs a Service object as a service in this ServiceManager.
      boolean installService​(ServiceSettings settings, java.lang.Class serviceClass)
      Installs a service as specified by its class and a set of settings.
      boolean startService​(java.lang.String name)
      Starts the service with the specified name.
      boolean uninstallService​(java.lang.String name)
      This method allows a service that is not running to be uninstalled.
      • Methods inherited from class java.lang.Object

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

      • services

        private java.util.Hashtable services
    • Constructor Detail

      • ServiceManager

        public ServiceManager()
    • Method Detail

      • installService

        public boolean installService​(ServiceSettings settings,
                                      java.lang.Class serviceClass)
        Installs a service as specified by its class and a set of settings.
        Parameters:
        settings - the settings for the service.
        serviceClass - the Class object of the class of the service to install.
        Returns:
        true iff the service has successfully been installed.
      • installService

        public boolean installService​(Service service,
                                      java.lang.String name)
        Installs a Service object as a service in this ServiceManager. The name of the service must be supplied.
        Parameters:
        service - the Service object to install.
        name - the name of the service.
        Returns:
        true iff the service has been successfully installed.
      • startService

        public boolean startService​(java.lang.String name)
        Starts the service with the specified name.
        Parameters:
        name - the name of the service to start.
        Returns:
        true iff the service has been successfully started.
      • uninstallService

        public boolean uninstallService​(java.lang.String name)

        This method allows a service that is not running to be uninstalled.

        A running service can be uninstalled by obtaining the service reference, calling its stop() method and then calling this method with the service's name.

        Parameters:
        name - the name of the service to uninstall.
        Returns:
        true iff the service has been uninstalled.
      • getService

        public Service getService​(java.lang.String name)

        Returns the Service object of the service with the specified name.

        Parameters:
        name - the name of the service
        Returns:
        the Service object of the service with the specified name.
      • getServiceNames

        public java.lang.String[] getServiceNames()
        Returns an array containing an array of String objects which represent the names of the currently installed services.
        Returns:
        an array of String service names.