Package de.espirit.firstspirit.module
Interface Service<T>
- All Superinterfaces:
Component<ServiceDescriptor,ServerEnvironment>
FirstSpirit service interface. Implementing classes must have a no-arg constructor.
The lifecycle of a service instance doesn't necessarily end with the
The lifecycle of a service instance doesn't necessarily end with the
stop call.
Therefore it is necessary to ensure all instances passed by to this service (e.g. during init)
must be cleaned up during stop and needs to be requested again during next
init and start- Since:
- 4.1
-
Method Summary
Modifier and TypeMethodDescription@Nullable Class<? extends ServiceProxy<T>>A service proxy is an optional, client-side service implementation.Returns the service server / communication interface.booleanReturns whether the service is running.voidstart()Starts the service.
Attention: If it is necessary to use instances provided by theenvironment(e.g.voidstop()Stops the service.Methods inherited from interface de.espirit.firstspirit.module.Component
init, installed, uninstalling, updated
-
Method Details
-
start
void start()Starts the service.
Attention: If it is necessary to use instances provided by theenvironment(e.g.specialistbroker) which is passed by inComponent.init(ComponentDescriptor, ServerEnvironment), it is recommended to request these instances in this start method or later on demand. These instances will become invalid afterstop()and need to be requested again during nextstart()- Since:
- 4.1
-
stop
void stop()Stops the service. This method should be used to clean up instances and references to request them again duringstart().
e.g. thebrokerprovided by theenvironmentduringComponent.init(ComponentDescriptor, ServerEnvironment)will become invalid after stop.- Since:
- 4.1
-
isRunning
boolean isRunning()Returns whether the service is running.- Returns:
trueif the service is running.- Since:
- 4.1
-
getServiceInterface
Returns the service server / communication interface. Only methods of this interface are accessible, soServiceinstances must also implement this interface.
If noproxy classis specified this interface must be used torequestthe service instance.- Returns:
- service interface class, never
null. - Since:
- 4.1
- See Also:
-
getProxyClass
A service proxy is an optional, client-side service implementation. It will be instantiated,initializedand returned byConnection.getService(String). The proxy class must have a no-arg constructor and must implement theServiceProxyinterface, but does not have to implement thecommunication interfaceitself.
It is recommended that the proxy class implements an interface because the proxy instance will berequestedwith this interface. For the following usecases it is useful to specify a proxy class:
1)Caching:
To avoid unnecessary client / server communication via thecommunication interface. In this case the proxy class normally implements thecommunication interfaceitself and that is used to request the service.
2)Serialization or slim interface for external use:
If you want to provide a slim interface forexternal usagebut need more functions in the internal communication interface or you want to provide an interface with signatures containing non serializable objects it is necessary to define an interface which is implemented by this proxy class which is different to thecommunication interface. In this case the proxy class should not implement thecommunication interface.- Returns:
- service proxy class or
nullif no proxy is provided. - Since:
- 4.1
-