|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.camel.support.ServiceSupport
public abstract class ServiceSupport
A useful base class which ensures that a service is only initialized once and provides some helper methods for enquiring of its status.
Implementations can extend this base class and implementSuspendableService
in case they support suspend/resume.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
ServiceSupport()
|
|
| Method Summary | |
|---|---|
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 |
isSuspended()
Tests whether the service is suspended or not. |
boolean |
isSuspending()
Whether the service is suspending |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public ServiceSupport()
| Method Detail |
|---|
public void start()
throws Exception
Service
start in interface ServiceException - is thrown if starting failed
public void stop()
throws Exception
Service
stop in interface ServiceException - is thrown if stopping failed
public void suspend()
throws Exception
SuspendableService
suspend in interface SuspendableServiceException - is thrown if suspending failed
public void resume()
throws Exception
SuspendableService
resume in interface SuspendableServiceException - is thrown if resuming failed
public void shutdown()
throws Exception
ShutdownableService
shutdown in interface ShutdownableServiceException - thrown if shutting down failedpublic ServiceStatus getStatus()
StatefulService
getStatus in interface StatefulServicepublic boolean isStarted()
StatefulService
isStarted in interface StatefulServicepublic boolean isStarting()
StatefulService
isStarting in interface StatefulServicepublic boolean isStopping()
StatefulService
isStopping in interface StatefulServicepublic boolean isStopped()
StatefulService
isStopped in interface StatefulServicepublic boolean isSuspending()
StatefulService
isSuspending in interface StatefulServicepublic boolean isSuspended()
SuspendableService
isSuspended in interface SuspendableServicepublic boolean isRunAllowed()
StatefulService
isRunAllowed in interface StatefulService
protected abstract void doStart()
throws Exception
doStop() for more details.
ExceptiondoStop()
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.
ExceptiondoStart()
protected void doSuspend()
throws Exception
Exception
protected void doResume()
throws Exception
Exception
protected void doShutdown()
throws Exception
Exceptionpublic String getVersion()
StatefulService
getVersion in interface StatefulService
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||