Class Service

java.lang.Object
i5.las2peer.api.Configurable
i5.las2peer.api.Service
Direct Known Subclasses:
NotCreatableService, NotStartingService, TestService

public abstract class Service
extends Configurable
Base class for services to be hosted within the las2peer network. All public methods of this service are available for RMI. The service is instantiated once per node. Thus, no user related data should be stored in class members. Access to las2peers service api is given via the Context interface.
  • Constructor Summary

    Constructors 
    Constructor Description
    Service()  
  • Method Summary

    Modifier and Type Method Description
    ServiceAgent getAgent()
    Gets the agent corresponding to this service.
    java.lang.String getAlias()
    Should return the service alias, which is registered on service start.
    java.util.Map<java.lang.String,​java.lang.String> getCustomMessageDescriptions()
    Override this method to make descriptions for log message codes available to other services.
    java.util.logging.Logger getLogger()
    Gets the logger for the service class.
    boolean isMonitor()
    Indicates whether monitoring is enabled for this service.
    boolean isSelfDeployable()
    Indicates whether the service is self deployable (restricting some features) or not (unlimited access).
    void onStart()
    Notifies the service that it has been launched at the given node.
    void onStart​(ServiceAgent agent, java.util.logging.Logger logger)
    Notifies the service that it has been launched at the given node.
    void onStop()
    Notifies the service, that it has been stopped at this node.
    protected void setFieldValues()
    Sets the fields of the service according to the configuration file.

    Methods inherited from class i5.las2peer.api.Configurable

    getProperties

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • onStart

      public void onStart() throws ServiceException
      Notifies the service that it has been launched at the given node. Simple startup hook that may be overwritten in subclasses.
      Throws:
      ServiceException - Can be thrown if an error occurs. The service will not be advertised to be running.
    • onStart

      public final void onStart​(ServiceAgent agent, java.util.logging.Logger logger) throws ServiceException
      Notifies the service that it has been launched at the given node.
      Parameters:
      agent - The agent responsible for executing this service.
      logger - The logger for the service class.
      Throws:
      ServiceException - Can be thrown if an error occurs. The service will not be advertised to be running.
    • onStop

      public void onStop()
      Notifies the service, that it has been stopped at this node. Simple shutdown hook to be overwritten in subclasses.
    • getAlias

      public java.lang.String getAlias()
      Should return the service alias, which is registered on service start.
      Returns:
      The alias, or null if no alias should be registered.
    • isMonitor

      public final boolean isMonitor()
      Indicates whether monitoring is enabled for this service.
      Returns:
      True if this service should be monitored.
    • isSelfDeployable

      public final boolean isSelfDeployable()
      Indicates whether the service is self deployable (restricting some features) or not (unlimited access).
      Returns:
      True if ManualDeployment is not set.
    • setFieldValues

      protected final void setFieldValues()
      Sets the fields of the service according to the configuration file. Note that this feature is only available for services with self-deployment disabled.
      Overrides:
      setFieldValues in class Configurable
      Throws:
      java.lang.IllegalStateException - If the service is not set up for manual deployment by annotating the service class with ManualDeployment.
    • getAgent

      public final ServiceAgent getAgent() throws ServiceException
      Gets the agent corresponding to this service.
      Returns:
      The agent responsible for this service.
      Throws:
      ServiceException - If the service is not started yet.
    • getLogger

      public final java.util.logging.Logger getLogger() throws ServiceException
      Gets the logger for the service class.
      Returns:
      The agent responsible for this service.
      Throws:
      ServiceException - If the service is not started yet.
    • getCustomMessageDescriptions

      public java.util.Map<java.lang.String,​java.lang.String> getCustomMessageDescriptions()
      Override this method to make descriptions for log message codes available to other services.
      Returns:
      A map with "SERVICE_CUSTOM_MESSAGE_(1-99) as key and a Markdown formatted string as value.