@ConfigurationDescription(properties=) public class InitialisedInjectedService extends InjectedADEPT2Service implements LogService, ServiceThreadHandling
AbstractADEPT2Service. The main difference
is that the injected service has constructors without a configuration and a
registry. Both are provided when this service is
initialised by the
platform. This is also an additional step in the lifecycle of this service.
Before this initialisation, most features will not work properly, e. g.
session tracking since this requires a registry. Check with
isInitialised() whether the injected service is usable. Methods that
usually wait for this service to be started, will not block but throw an
exception before the initialisation. This is similar to their behaviour after
the service has been shut down.| Modifier and Type | Field and Description |
|---|---|
protected AbstractADEPT2Service |
adept2Service
|
protected java.lang.Class<?> |
loggerClass
The class which to use for the logger provided by
AbstractADEPT2Service, this is usually the interface of the
service. |
static java.lang.String |
NOT_INITIALISED_EXCEPTION
The message for the
InvalidServiceStateException for methods of
AbstractADEPT2Service before the
initialisation by the
platform. |
EMPTY_STRING_ARRAY, logger, runtimeRequiredServices, startupRequiredServices| Constructor and Description |
|---|
InitialisedInjectedService(java.util.logging.Logger logger)
Creates an injected service that can be initialised by the platform.
|
InitialisedInjectedService(java.util.logging.Logger logger,
java.lang.String[] startupRequiredServices,
java.lang.String[] runtimeRequiredServices,
java.lang.Class<?> cls)
Creates an injected service that can be initialised by the platform.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_sessionActive(SessionToken session,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIR,
int addStackElems) |
protected void |
_sessionFinished(SessionToken session,
int addStackElems) |
void |
changeLogContext(EBPInstanceReference ebpIr)
Convenience method for
LogService.changeLogContext(String, SessionToken, UUID, UUID, UUID, UUID, EBPInstanceReference). |
void |
changeLogContext(java.lang.String contextString)
Convenience method for
LogService.changeLogContext(String, SessionToken, UUID, UUID, UUID, UUID, EBPInstanceReference). |
void |
changeLogContext(java.lang.String contextString,
SessionToken session,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr)
Changes the current log record parameter values for the designated session
intermediately to the designated values.
|
boolean |
csvLoggingEnabled()
Whether the debug/CSV-logging is being used.
|
java.util.logging.Logger |
getClassSpecificJulLogger(java.lang.Class<?> cls)
Gets the logger of this service using and recognising class names.
|
java.util.logging.Logger |
getLogger()
If this service has not been initialised by the platform yet, the logger
provided in the constructor will be returned.
|
SerialisablePair<java.lang.String,java.lang.String> |
getRelease()
If this service has not been initialised by the platform yet, the release will be unknown.
|
void |
init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
Initialise the service.
|
void |
initPlatform(Configuration conf,
Registry registry)
Initialises this service by the platform, that is, sets a configuration and
a registry thus allowing access to the platform.
|
boolean |
isActive()
Gets whether this service has been
initialised by the
platform and AbstractADEPT2Service.isActive().
|
protected boolean |
isInitialised()
Gets whether this service has been
initialised by the
platform.
|
void |
logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg)
Registers the log context for the current thread (if CSV-logging is
configured) and logs the designated message.
|
void |
logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr)
Registers the log context for the current thread (if CSV-logging is
configured) and logs the designated message.
|
protected void |
logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr,
int removeElems) |
void |
logMethodExit(java.lang.String msg)
Logs the designated message and unregisters the log context for the current
thread (if CSV-logging is configured).
|
protected void |
logMethodExit(java.lang.String msg,
int removeElems) |
boolean |
privilegeThread()
Stores the current thread as privileged when the service has not been
started or is currently shut down.
|
void |
revertLogContextChanges()
Reverts the current changes of the log context registered for the current
thread.
|
void |
sessionActive(SessionToken session) |
protected void |
sessionActive(SessionToken session,
java.util.UUID templId,
java.util.UUID embdTemplId,
EBPInstanceReference ebpIr) |
protected void |
sessionActive(SessionToken session,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId) |
void |
sessionFinished(SessionToken session) |
void |
shutdown(boolean emergency)
Signals this service that it is being shut down.
|
void |
signalShutdown(boolean emergency)
Privileges the current thread, sets the shutdown flag and in case of
emergency interrupts all active threads without the privileged ones since
they are shutting down this service.
|
void |
signalStart()
Signals the successful start by counting down the latch and removing
privileged threads.
|
void |
start()
Starts the service.
|
void |
unprivilegeThread()
Revokes the privileges of the current thread that is, it may not access the
service any more in case it is not started or currently shut down.
|
getLocalUris, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdownpublic static final java.lang.String NOT_INITIALISED_EXCEPTION
InvalidServiceStateException for methods of
AbstractADEPT2Service before the
initialisation by the
platform.protected final java.lang.Class<?> loggerClass
AbstractADEPT2Service, this is usually the interface of the
service.protected AbstractADEPT2Service adept2Service
public InitialisedInjectedService(java.util.logging.Logger logger)
logger - The logger which to use for this service. This will only be
used until initialisation by the platform. Afterwards the logger of the
AbstractADEPT2Service will be used.public InitialisedInjectedService(java.util.logging.Logger logger,
java.lang.String[] startupRequiredServices,
java.lang.String[] runtimeRequiredServices,
java.lang.Class<?> cls)
logger - The logger which to use for this service. This will only be
used until initialisation by the platform. Afterwards the logger of the
AbstractADEPT2Service will be used.startupRequiredServices - The service type names of services required
at startup time (in init(URI[], URI[]) and start()).
This may be null.runtimeRequiredServices - The service type names of services required
at runtime (after startup time). This may be null.cls - The class which to use for the logger provided by
AbstractADEPT2Service, this is usually the interface
of the service.public void initPlatform(Configuration conf, Registry registry) throws AbortServiceException
conf - The configuration provided by the platform.registry - The registry allowing to access the platform.AbortServiceException - If there are problems initialising this
service, an AbortServiceException will be thrown.public void init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
throws AbortServiceException
ADEPT2ServiceADEPT2Service.init(URI[], URI[]), the service must be ready
for ADEPT2Service.start().init in interface ADEPT2Serviceinit in class InjectedADEPT2ServicelocalExportedUris - The URIs with which this service is exported
locally or a local URI or an empty array for internal services.globalExportedUris - The URIs with which this service is published
globally or null in case the service is not
published.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbortServiceException - If this service cannot be initialised due to
a severe problem, an AbortServiceException will be
thrown. ADEPT2Service.shutdown(boolean) will not be called when aborting; the
service has to shut down itself/clean up before throwing the
exception.InjectedADEPT2Service.init(URI[], URI[]),
AbstractADEPT2Service.init(URI[], URI[])public void start()
throws AbortServiceException
ADEPT2Service
After returning from ADEPT2Service.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.
start in interface ADEPT2Servicestart in class InjectedADEPT2ServiceInvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbortServiceException - If this service cannot be started due to
a severe problem, an AbortServiceException will be
thrown. ADEPT2Service.shutdown(boolean) will not be called when aborting; the
service has to shut down itself/clean up before throwing the
exception.InjectedADEPT2Service.start(),
AbstractADEPT2Service.start()public void shutdown(boolean emergency)
ADEPT2ServiceServiceThreadHandling. shutdown in interface ADEPT2Serviceshutdown in class InjectedADEPT2Serviceemergency - Whether the shutdown will be an emergency shutdown.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.InjectedADEPT2Service.start(),
AbstractADEPT2Service.start()protected boolean isInitialised()
public boolean isActive()
AbstractADEPT2Service.isActive()public void sessionActive(SessionToken session)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.sessionActive(SessionToken)protected void sessionActive(SessionToken session, java.util.UUID templId, java.util.UUID baseTemplId, java.util.UUID embdTemplId, java.util.UUID instId)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.sessionActive(SessionToken, UUID, UUID, UUID,
UUID)protected void sessionActive(SessionToken session, java.util.UUID templId, java.util.UUID embdTemplId, EBPInstanceReference ebpIr)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.sessionActive(SessionToken, UUID, UUID,
EBPInstanceReference)protected void _sessionActive(SessionToken session, java.util.UUID templId, java.util.UUID baseTemplId, java.util.UUID embdTemplId, java.util.UUID instId, EBPInstanceReference ebpIR, int addStackElems)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service._sessionActive(SessionToken, UUID, UUID, UUID,
UUID, EBPInstanceReference, int)public void sessionFinished(SessionToken session)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.sessionFinished(SessionToken)protected void _sessionFinished(SessionToken session, int addStackElems)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service._sessionFinished(SessionToken, int)public java.util.logging.Logger getLogger()
getLogger in interface LogServicegetLogger in class InjectedADEPT2Servicepublic SerialisablePair<java.lang.String,java.lang.String> getRelease()
getRelease in interface ADEPT2ServicegetRelease in class InjectedADEPT2Servicepublic java.util.logging.Logger getClassSpecificJulLogger(java.lang.Class<?> cls)
LogServicegetClassSpecificJulLogger in interface LogServicecls - The class for which to get a class-specific service logger.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.getClassSpecificJulLogger(Class)public boolean csvLoggingEnabled()
LogServicecsvLoggingEnabled in interface LogServiceInvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.csvLoggingEnabled()protected void logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr,
int removeElems)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.logMethodEntry(String, SessionToken, String,
UUID, UUID, UUID, UUID, EBPInstanceReference, int)public void logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg)
LogServicenull can be provided for the session
token).
Make sure to call LogService.logMethodExit(String) when exiting the method
using the same thread again. Otherwise the log context remains registered
and all following log messages will have the wrong log context.
Hint: This method must not be called by another component than this component or a sub component/sub module of this component.
logMethodEntry in interface LogServicecontextString - An arbitrary string identifying the new log context.
This string is used additionally for every message logged with
this log context, that is all log messages occurring until a new
log context is set or the log context is dropped since the method
is exited.session - The session token with which a method is called providing
useful information for the CSV-log. This may be null.msg - The message for logging the method entry.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.logMethodEntry(String, SessionToken, String)public void logMethodEntry(java.lang.String contextString,
SessionToken session,
java.lang.String msg,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr)
LogServiceLogService.logMethodEntry(String, SessionToken, String) but allows for more
log context information.
Make sure to call LogService.logMethodExit(String) when exiting the method
using the same thread again. Otherwise the log context remains registered
and all following log messages will have the wrong log context.
Hint: This method must not be called by another component than this component or a sub component/sub module of this component.
logMethodEntry in interface LogServicecontextString - An arbitrary string identifying the new log context.
This string is used additionally for every message logged with
this log context, that is all log messages occurring until a new
log context is set or the log context is dropped since the method
is exited. This is useful for sorting and/or filtering the
CSV-log.session - The session token with which a method is called providing
useful information for the CSV-log. This may be null.msg - The message for logging the method entry.templId - The template ID for the log record. This may be
null.baseTemplId - The base template ID for the log record. This may be
null.embdTemplId - The (internal) ID of the embedded template ID the for
the log record. This may be null.instId - The instance ID for the log record. This may be
null.ebpIr - The EBPInstanceReference for the log record. This
may be null.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.logMethodEntry(String, SessionToken, String,
UUID, UUID, UUID, UUID, EBPInstanceReference)public void changeLogContext(java.lang.String contextString)
LogServiceLogService.changeLogContext(String, SessionToken, UUID, UUID, UUID, UUID, EBPInstanceReference).
Changes just the context string for the previous registered log context. removing the log context completely.changeLogContext in interface LogServicecontextString - An arbitrary string identifying the current log
context. This string is used additionally for every message logged
with this log context, that is all log messages occurring until a
new log context is set or the log context is dropped since the
method is exited. This is useful for sorting and/or filtering the
CSV-log.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.changeLogContext(String)public void changeLogContext(EBPInstanceReference ebpIr)
LogServiceLogService.changeLogContext(String, SessionToken, UUID, UUID, UUID, UUID, EBPInstanceReference).
Changes just the EBPInstanceReference parameter value for the
previous registered log context. changeLogContext in interface LogServiceebpIr - The EBPInstanceReference for the log record. This
may be null.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.changeLogContext(EBPInstanceReference)public void changeLogContext(java.lang.String contextString,
SessionToken session,
java.util.UUID templId,
java.util.UUID baseTemplId,
java.util.UUID embdTemplId,
java.util.UUID instId,
EBPInstanceReference ebpIr)
LogServicenull, it will not be changed. The agents will be retrieved
from the session token and the service name from the registry of this
service. LogService.revertLogContextChanges().
The changed log context will also be removed (together with the original
log context) when unregistering the log context via
LogService.logMethodExit(String).
Make sure that you have registered the log context before
(LogService.logMethodEntry(String, SessionToken, String) or
LogService.logMethodEntry(String, SessionToken, String, UUID, UUID, UUID, UUID, EBPInstanceReference)).
changeLogContext in interface LogServicecontextString - An arbitrary additional string for the log record allowing
to sort and/or filter the log. This may be null.session - The session including the agent information for the log
record. This may be null.templId - The template ID for the log record. This may be null.baseTemplId - The base template ID for the log record. This may be
null.embdTemplId - The (internal) ID of the embedded template ID the for
the log record. This may be null.instId - The instance ID for the log record. This may be null.ebpIr - The EBPInstanceReference for the log record. This
may be null.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.changeLogContext(String, SessionToken, UUID,
UUID, UUID, UUID, EBPInstanceReference)public void revertLogContextChanges()
LogServicerevertLogContextChanges in interface LogServiceInvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.revertLogContextChanges()public void logMethodExit(java.lang.String msg)
LogServicelogMethodExit in interface LogServicemsg - The message for logging the method exit.InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.logMethodExit(String)protected void logMethodExit(java.lang.String msg,
int removeElems)
InvalidServiceStateException - If this service has not been
initialised by the platform yet, an
InvalidServiceStateException will be thrown.AbstractADEPT2Service.logMethodExit(String, int)public boolean privilegeThread()
ServiceThreadHandlingunprivileging them again.
The thread running the constructor and the thread signalling the shutdown is implicitly privileged.
privilegeThread in interface ServiceThreadHandlingfalse will be
returned and the caller must not unprivilege the thread.public void unprivilegeThread()
ServiceThreadHandlingunprivilegeThread in interface ServiceThreadHandlingpublic void signalStart()
ServiceThreadHandlingsignalStart in interface ServiceThreadHandlingpublic void signalShutdown(boolean emergency)
ServiceThreadHandlingsignalShutdown in interface ServiceThreadHandlingemergency - Flag whether this is an emergency shutdown and the active
sessions should be interrupted.