|
JBoss Modular Service Kernel API 1.0.0.CR2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- the type of value that this service provides; may be Void
public interface Service<T>
A service is a thing which can be started and stopped. A service may be started or stopped from any thread. In
general, injections will always happen from the same thread that will call start()
, and uninjections will
always happen from the same thread that had called stop()
. However no other guarantees are made with respect
to locking or thread safety; a robust service implementation should always take care to protect any mutable state
appropriately.
The value type specified by this service is used by default by consumers of this service, and should represent the public interface of this service, which may or may not be the same as the implementing type of this service.
When writing MSC service implementations, your start(StartContext)
and stop(StopContext)
methods must never block. This means these methods must not:
LifecycleContext.asynchronous()
) and do one of the following:
LifecycleContext.complete()
when your start/stop completes instead of blockingExecutor
) which calls LifecycleContext.complete()
when done
Note that using LifecycleContext.execute(Runnable)
to execute the blocking task is also not permissible.
Field Summary | |
---|---|
static Service<Void> |
NULL
A simple null service which performs no start or stop action. |
static Value<Service<Void>> |
NULL_VALUE
A value which resolves to the null service . |
Method Summary | |
---|---|
void |
start(StartContext context)
Start the service. |
void |
stop(StopContext context)
Stop the service. |
Methods inherited from interface org.jboss.msc.value.Value |
---|
getValue |
Field Detail |
---|
static final Service<Void> NULL
static final Value<Service<Void>> NULL_VALUE
null service
.
Method Detail |
---|
void start(StartContext context) throws StartException
If the service start involves any activities that may block, the asynchronous mechanism
provided by the context
should be used. See the class javadoc
for details.
context
- the context which can be used to trigger an asynchronous service start
StartException
- if the service could not be started for some reasonvoid stop(StopContext context)
If the service start involves any activities that may block, the asynchronous mechanism
provided by the context
should be used. See the class javadoc
for details.
context
- the context which can be used to trigger an asynchronous service stop
|
JBoss Modular Service Kernel API 1.0.0.CR2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |