private static final class ServiceManager.NoOpService extends AbstractService
Service
instance that does nothing. This is only useful as a placeholder to ensure
that the ServiceManager
functions properly even when it is managing no services.
The use of this class is considered an implementation detail of ServiceManager and as such
it is excluded from ServiceManager.servicesByState()
, ServiceManager.startupTimes()
, AbstractService.toString()
and all
logging statements.
Service.Listener, Service.State
Modifier | Constructor and Description |
---|---|
private |
NoOpService() |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart()
This method is called by
AbstractService.startAsync() to initiate service startup. |
protected void |
doStop()
This method should be used to initiate service shutdown.
|
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
protected void doStart()
AbstractService
AbstractService.startAsync()
to initiate service startup. The invocation of
this method should cause a call to AbstractService.notifyStarted()
, either during this method's run,
or after it has returned. If startup fails, the invocation should cause a call to AbstractService.notifyFailed(Throwable)
instead.
This method should return promptly; prefer to do work on a different thread where it is
convenient. It is invoked exactly once on service startup, even when AbstractService.startAsync()
is
called multiple times.
doStart
in class AbstractService
protected void doStop()
AbstractService
AbstractService.notifyStopped()
, either during this method's run, or after it has
returned. If shutdown fails, the invocation should cause a call to AbstractService.notifyFailed(Throwable)
instead.
This method should return promptly; prefer to do work on a different thread where it is
convenient. It is invoked exactly once on service shutdown, even when AbstractService.stopAsync()
is
called multiple times.
If AbstractService.stopAsync()
is called on a Service.State.STARTING
service, this method is not
invoked immediately. Instead, it will be deferred until after the service is Service.State.RUNNING
. Services that need to cancel startup work can override AbstractService.doCancelStart()
.
doStop
in class AbstractService