Package i5.las2peer.api
Class Service
java.lang.Object
i5.las2peer.api.Configurable
i5.las2peer.api.Service
- Direct Known Subclasses:
NotCreatableService
,NotStartingService
,TestService
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal ServiceAgent
getAgent()
Gets the agent corresponding to this service.getAlias()
Should return the service alias, which is registered on service start.Override this method to make descriptions for log message codes available to other services.final Logger
Gets the logger for the service class.final boolean
Indicates whether monitoring is enabled for this service.final boolean
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.final void
onStart
(ServiceAgent agent, 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 final void
Sets the fields of the service according to the configuration file.Methods inherited from class i5.las2peer.api.Configurable
getProperties
-
Constructor Details
-
Service
public Service()
-
-
Method Details
-
onStart
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
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
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 classConfigurable
- Throws:
IllegalStateException
- If the service is not set up for manual deployment by annotating the service class withManualDeployment
.
-
getAgent
Gets the agent corresponding to this service.- Returns:
- The agent responsible for this service.
- Throws:
ServiceException
- If the service is not started yet.
-
getLogger
Gets the logger for the service class.- Returns:
- The agent responsible for this service.
- Throws:
ServiceException
- If the service is not started yet.
-
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.
-