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.boolean
Returns whether the service is running.void
start()
Starts the service.
Attention: If it is necessary to use instances provided by theenvironment
(e.g.void
stop()
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. thebroker
provided by theenvironment
duringComponent.init(ComponentDescriptor, ServerEnvironment)
will become invalid after stop.- Since:
- 4.1
-
isRunning
boolean isRunning()Returns whether the service is running.- Returns:
true
if the service is running.- Since:
- 4.1
-
getServiceInterface
Returns the service server / communication interface. Only methods of this interface are accessible, soService
instances must also implement this interface.
If noproxy class
is specified this interface must be used torequest
the 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,initialized
and returned byConnection.getService(String)
. The proxy class must have a no-arg constructor and must implement theServiceProxy
interface, but does not have to implement thecommunication interface
itself.
It is recommended that the proxy class implements an interface because the proxy instance will berequested
with 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 interface
itself 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 usage
but 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
null
if no proxy is provided. - Since:
- 4.1
-