private class ServiceControllerImpl.StartContextImpl extends java.lang.Object implements StartContext
| Modifier and Type | Field and Description |
|---|---|
private long |
startNanos |
private ServiceControllerImpl.ContextState |
state |
| Modifier | Constructor and Description |
|---|---|
private |
StartContextImpl(long startNanos) |
| Modifier and Type | Method and Description |
|---|---|
void |
asynchronous()
Call within the service lifecycle method to trigger an asynchronous lifecycle action.
|
void |
complete()
Call when either synchronous or asynchronous lifecycle action is complete.
|
void |
execute(java.lang.Runnable command)
Execute a task asynchronously using the MSC task executor.
|
void |
failed(StartException reason)
Call when start lifecycle action has failed for some reason.
|
ServiceTarget |
getChildTarget()
Get a service target which may be used to add child services.
|
ServiceController<?> |
getController()
Get the associated service controller.
|
long |
getElapsedTime()
Get the amount of time elapsed since the start or stop was initiated, in nanoseconds.
|
private ServiceControllerImpl.ContextState state
private final long startNanos
public void failed(StartException reason) throws java.lang.IllegalStateException
StartContextfailed in interface StartContextreason - the reason for the failurejava.lang.IllegalStateException - if called after StartContext.complete() was calledpublic ServiceTarget getChildTarget()
StartContext
Any listeners added directly to this service target will be added to child services when they are installed.
Listeners added directly to this service target will be applied recursively to descendants as well, as long as
the listener exists on this service target. To avoid this recursive behavior, apply listeners to any sub-target
of this this target (see ServiceTarget.subTarget() for more information about sub-targets).
Note that any listeners existing on the starting service are not applied to child services automatically; they must be explicitly added to the child service target.
getChildTarget in interface StartContextpublic void asynchronous()
throws java.lang.IllegalStateException
StartContextStartContext.complete() or StartContext.failed(StartException) method on this interface.asynchronous in interface LifecycleContextasynchronous in interface StartContextjava.lang.IllegalStateException - if called twice in a rowpublic void complete()
throws java.lang.IllegalStateException
StartContextcomplete in interface LifecycleContextcomplete in interface StartContextjava.lang.IllegalStateException - if called after StartContext.failed(StartException) was called or if called twice in a rowpublic long getElapsedTime()
LifecycleContextgetElapsedTime in interface LifecycleContextpublic ServiceController<?> getController()
LifecycleContextgetController in interface LifecycleContextpublic void execute(java.lang.Runnable command)
LifecycleContext
Note: This method should not be used for executing tasks that may block,
particularly from within a service's Service.start(StartContext) or Service.stop(StopContext)
methods. See the Service class javadoc for further details.
execute in interface java.util.concurrent.Executorexecute in interface LifecycleContextcommand - the command to execute