T - The type of the service this is a sub service of.public class AbstractSubService<T extends AbstractADEPT2Service>
extends java.lang.Object
AbstractADEPT2Service. This provides just the basic requirements
for a sub service and forwards the session handling to the corresponding main
service. The basic requirements include empty implementations for the
initialisation, start and shutdown as well as the startup and runtime
required services. Note that a sub service must only provide its own required
services not the ones of the main service!
This interface can be used by the main services to manage their sub services.
Note that unlike the methods of AbstractADEPT2Service no method
of this interface will be called by the registry.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
The logger of the corresponding main service this sub service belongs to.
|
protected java.lang.String[] |
runtimeRequiredServices
The service type names of services required at runtime (after startup time)
by this sub service.
|
protected T |
service
The corresponding main service this sub service belongs to.
|
protected java.lang.String[] |
startupRequiredServices
The service type names of services required at runtime (after startup time)
by this sub service.
|
| Constructor and Description |
|---|
AbstractSubService(java.lang.String[] startupRequiredServices,
java.lang.String[] runtimeRequiredServices,
T service)
Creates a simple sub service with the designated required services for the
designated main service.
|
AbstractSubService(T service)
Creates a simple sub service for the designated main service.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.net.URI[] |
getLocalUris()
Forwards to
AbstractADEPT2Service.getLocalUris() of the main
service. |
java.lang.String[] |
getRuntimeRequiredServices()
Gets the service type names of services required at runtime (after startup
time) by this sub service.
|
java.lang.String[] |
getStartupRequiredServices()
|
protected java.net.URI[] |
getURIs()
Forwards to
AbstractADEPT2Service.getURIs() of the main service. |
void |
init()
Initialise the sub service.
|
long |
ping()
Gets whether the main service is running and accepts requests or not and since when.
|
protected void |
privilegeSession(SessionToken activeSession,
SessionToken newSession)
Forwards to
AbstractADEPT2Service.privilegeSession(SessionToken, SessionToken)
of the main service. |
protected void |
sessionActive(SessionToken session)
Forwards to
AbstractADEPT2Service.sessionActive(SessionToken) of
the main service. |
protected void |
sessionFinished(SessionToken session)
Forwards to
AbstractADEPT2Service.sessionFinished(SessionToken) of
the main service. |
void |
shutdown(boolean emergency)
Signals this service that it is being shut down.
|
void |
start()
Starts the sub service.
|
protected java.util.logging.Logger logger
protected final java.lang.String[] startupRequiredServices
protected final java.lang.String[] runtimeRequiredServices
protected final T extends AbstractADEPT2Service service
public AbstractSubService(T service)
service - The main service this sub service belongs to.public AbstractSubService(java.lang.String[] startupRequiredServices,
java.lang.String[] runtimeRequiredServices,
T service)
startupRequiredServices - The service type names of services required
at startup time (in init() and start()) by this
sub service.runtimeRequiredServices - The service type names of services required
at runtime (after startup time) by this sub service.service - The main service this sub service belongs to.protected final void privilegeSession(SessionToken activeSession, SessionToken newSession)
AbstractADEPT2Service.privilegeSession(SessionToken, SessionToken)
of the main service.activeSession - The session token with which to privilege a new
session that should be allowed to terminate despite this service
shutting down. This session token has to be
active and must not be
null.newSession - The session token which should be allowed to terminate
despite this service shutting down. This has to be a top-level
session token and it must not be null.protected final void sessionActive(SessionToken session)
AbstractADEPT2Service.sessionActive(SessionToken) of
the main service.session - The session token with which a method is called and
therefore active. This must not be null.protected final void sessionFinished(SessionToken session)
AbstractADEPT2Service.sessionFinished(SessionToken) of
the main service.session - The session token with which a method has been executed and
which is not active any more in this service. This must not be
null.public final java.lang.String[] getStartupRequiredServices()
public final java.lang.String[] getRuntimeRequiredServices()
protected java.net.URI[] getLocalUris()
AbstractADEPT2Service.getLocalUris() of the main
service.protected java.net.URI[] getURIs()
AbstractADEPT2Service.getURIs() of the main service.public long ping()
0 for a service that has not been
started, -1 for a service that has been shut down. boolean logic use 0 < ping().public void init()
throws AbortServiceException
init(), the sub service must be ready for
start().
This implementation is empty which allows subclasses to omit the initialisation if they do not need one.
AbortServiceException - If this sub service cannot be initialised due
to a severe problem, an AbortServiceException will
be thrown. shutdown(boolean) will not be called when aborting;
the sub service has to shut down itself/clean up before throwing
the exception.public void start()
throws AbortServiceException
start(), the service must be ready to receive
any API call. This implicates for instance, that the thread calling this
method may not leave the method before a server thread is actually ready to
receive requests.
This implementation is empty which allows subclasses to omit the start procedure if they do not need one.
AbortServiceException - If this sub service cannot be started due to
a severe problem, an AbortServiceException will be
thrown. shutdown(boolean) will not be called when aborting; the
sub service has to shut down itself/clean up before throwing the
exception.public void shutdown(boolean emergency)
ServiceThreadHandling. This implementation is empty.
emergency - Whether the shutdown will be an emergency shutdown.