public abstract class AbstractService extends Object implements IService
UUID
,
etc.Modifier | Constructor and Description |
---|---|
protected |
AbstractService() |
Modifier and Type | Method and Description |
---|---|
protected void |
clearLoggingContext()
Clear the logging context.
|
void |
destroy()
Destroy the service.
|
abstract AbstractFederation |
getFederation()
Return the proxy used to access other services in the federation.
|
String |
getHostname()
The host on which this service is running.
|
abstract Class |
getServiceIface()
Return the most interesting interface for the service.
|
String |
getServiceName()
Note: This is overridden in the jini integration to return a configured
name for the service.
|
UUID |
getServiceUUID()
The unique identifier for this service.
|
void |
setServiceUUID(UUID serviceUUID)
This method must be invoked to set the service
UUID . |
protected void |
setupLoggingContext()
Sets up the
MDC logging context. |
void |
shutdown() |
void |
shutdownNow() |
abstract AbstractService |
start()
Starts the
AbstractService . |
public void setServiceUUID(UUID serviceUUID) throws IllegalStateException
UUID
.
Note: This method gets invoked at different times depending on whether the service is embedded (generally invoked from the service constructor) or written against a service discovery framework (invoked once the service has been assigned a UUID by a registrar or during re-start since the service UUID is read from a local file).
Several things depend on when this method is invoked, including the setup
of the per-service CounterSet
reported by the service to the
ILoadBalancerService
.
serviceUUID
- The UUID
assigned to the service.IllegalArgumentException
- if the parameter is null.IllegalStateException
- if the service UUID
has already been set to a
different value.public final UUID getServiceUUID()
IService
Note: Some service discovery frameworks (Jini) will assign the service a
UUID
asynchronously after a new service starts, in which case
this method will return null
until the service
UUID
has been assigned.
getServiceUUID
in interface IService
public abstract Class getServiceIface()
getServiceIface
in interface IService
public abstract AbstractService start()
AbstractService
.
Note: A start()
is required in order to give subclasses an
opportunity to be fully initialized before they are required to begin
operations. It is impossible to encapsulate the startup logic cleanly
without this ctor() + start() pattern. Those familiar with Objective-C
will recognized this.
public abstract AbstractFederation getFederation()
public final String getHostname()
IService
getHostname
in interface IService
public void shutdown()
public void shutdownNow()
public void destroy()
IService
DestroyAdmin#destroy()
.public String getServiceName()
getServiceName
in interface IService
protected void setupLoggingContext()
MDC
logging context. You should do this on every
client facing point of entry and then call clearLoggingContext()
in a finally
clause. You can extend this method to add
additional context.
This implementation adds the following parameters to the MDC
.
MDC
. This datum can be injected into log messages
using %X{serviceUUID} in your log4j pattern layout.protected void clearLoggingContext()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.