public abstract class ServiceSupport extends Object implements StatefulService
SuspendableService
in case they support suspend/resume.| Modifier and Type | Field and Description |
|---|---|
protected AtomicBoolean |
shutdown |
protected AtomicBoolean |
shuttingdown |
protected AtomicBoolean |
started |
protected AtomicBoolean |
starting |
protected AtomicBoolean |
stopped |
protected AtomicBoolean |
stopping |
protected AtomicBoolean |
suspended |
protected AtomicBoolean |
suspending |
| Constructor and Description |
|---|
ServiceSupport() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doResume()
Implementations override this method to support customized suspend/resume.
|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown.
|
protected abstract void |
doStart()
Implementations override this method to support customized start/stop.
|
protected abstract void |
doStop()
Implementations override this method to support customized start/stop.
|
protected void |
doSuspend()
Implementations override this method to support customized suspend/resume.
|
ServiceStatus |
getStatus()
Returns the current status
|
String |
getVersion()
Returns the version of this service
|
boolean |
isRunAllowed()
Helper methods so the service knows if it should keep running.
|
boolean |
isStarted()
Whether the service is started
|
boolean |
isStarting()
Whether the service is starting
|
boolean |
isStopped()
Whether the service is stopped
|
boolean |
isStopping()
Whether the service is stopping
|
boolean |
isStoppingOrStopped()
Is the service in progress of being stopped or already stopped
|
boolean |
isSuspended()
Tests whether the service is suspended or not.
|
boolean |
isSuspending()
Whether the service is suspending
|
boolean |
isSuspendingOrSuspended()
Is the service in progress of being suspended or already suspended
|
void |
resume()
Resumes the service.
|
void |
shutdown()
Shutdown the service, which means it cannot be started again.
|
void |
start()
Starts the service
|
void |
stop()
Stops the service
|
void |
suspend()
Suspends the service.
|
protected final AtomicBoolean started
protected final AtomicBoolean starting
protected final AtomicBoolean stopping
protected final AtomicBoolean stopped
protected final AtomicBoolean suspending
protected final AtomicBoolean suspended
protected final AtomicBoolean shuttingdown
protected final AtomicBoolean shutdown
public ServiceSupport()
public void start() throws Exception
Servicepublic void stop() throws Exception
Servicepublic void suspend() throws Exception
SuspendableServicesuspend in interface SuspendableServiceException - is thrown if suspending failedpublic void resume() throws Exception
SuspendableServiceresume in interface SuspendableServiceException - is thrown if resuming failedpublic void shutdown() throws Exception
ShutdownableServiceshutdown in interface ShutdownableServiceException - thrown if shutting down failedpublic ServiceStatus getStatus()
StatefulServicegetStatus in interface StatefulServicepublic boolean isStarted()
StatefulServiceisStarted in interface StatefulServicepublic boolean isStarting()
StatefulServiceisStarting in interface StatefulServicepublic boolean isStopping()
StatefulServiceisStopping in interface StatefulServicepublic boolean isStopped()
StatefulServiceisStopped in interface StatefulServicepublic boolean isSuspending()
StatefulServiceisSuspending in interface StatefulServicepublic boolean isSuspended()
SuspendableServiceisSuspended in interface SuspendableServicepublic boolean isRunAllowed()
StatefulServiceisRunAllowed in interface StatefulServicepublic boolean isStoppingOrStopped()
public boolean isSuspendingOrSuspended()
protected abstract void doStart() throws Exception
doStop() for more details.protected abstract void doStop() throws Exception
doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.protected void doSuspend() throws Exception
Exceptionprotected void doResume() throws Exception
Exceptionprotected void doShutdown() throws Exception
Exceptionpublic String getVersion()
StatefulServicegetVersion in interface StatefulServiceApache Camel