Class 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 Details

    • Service

      public Service()
  • 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, 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 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:
      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 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 Map<String,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.