T
- the type of value that this service provides; may be Void
public interface Service<T> extends Value<T>
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.
Modifier and Type | Field and Description |
---|---|
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 . |
Modifier and Type | Method and Description |
---|---|
void |
start(StartContext context)
Start the service.
|
void |
stop(StopContext context)
Stop the service.
|
static final Value<Service<Void>> NULL_VALUE
null service
.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 startStartException
- 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 stopCopyright © 2017 JBoss by Red Hat. All rights reserved.