public abstract class ServiceSupport extends Object implements StatefulService
SuspendableService
in case they support suspend/resume.
Important: You should override the lifecycle methods that start with do, eg doStart()
},
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overridden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.Modifier and Type | Field and Description |
---|---|
protected static int |
FAILED |
protected static int |
INITIALIZED |
protected Object |
lock |
protected org.slf4j.Logger |
log |
protected static int |
NEW |
protected static int |
SHUTDOWN |
protected static int |
SHUTTINGDOWN |
protected static int |
STARTED |
protected static int |
STARTING |
protected int |
status |
protected static int |
STOPPED |
protected static int |
STOPPING |
protected static int |
SUSPENDED |
protected static int |
SUSPENDING |
Constructor and Description |
---|
ServiceSupport() |
Modifier and Type | Method and Description |
---|---|
protected void |
doInit()
Initialize the service.
|
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
|
void |
init()
Initialize the service
|
boolean |
isInit() |
boolean |
isNew() |
boolean |
isRunAllowed()
Helper methods so the service knows if it should keep running.
|
boolean |
isShutdown() |
boolean |
isStarted()
Whether the service is started
|
boolean |
isStarting()
Whether the service is starting
|
boolean |
isStartingOrStarted()
Is the service in progress of being suspended or already suspended
|
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()
|
void |
shutdown()
|
void |
start()
|
void |
stop()
|
void |
suspend()
|
protected static final int NEW
protected static final int INITIALIZED
protected static final int STARTING
protected static final int STARTED
protected static final int SUSPENDING
protected static final int SUSPENDED
protected static final int STOPPING
protected static final int STOPPED
protected static final int SHUTTINGDOWN
protected static final int SHUTDOWN
protected static final int FAILED
protected final org.slf4j.Logger log
protected volatile int status
public ServiceSupport()
public void start()
doStart()
,
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overriden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.public void stop()
doStart()
,
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overridden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.public void suspend()
doStart()
,
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overridden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.suspend
in interface SuspendableService
public void resume()
doStart()
,
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overriden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.resume
in interface SuspendableService
public void shutdown()
doStart()
,
doStop()
, etc. where you implement your logic. The methods start()
, stop()
should
NOT be overriden as they are used internally to keep track of the state of this service and properly
invoke the operation in a safe manner.shutdown
in interface ShutdownableService
public ServiceStatus getStatus()
StatefulService
getStatus
in interface StatefulService
public boolean isNew()
public boolean isInit()
public boolean isStarted()
StatefulService
isStarted
in interface StatefulService
public boolean isStarting()
StatefulService
isStarting
in interface StatefulService
public boolean isStopping()
StatefulService
isStopping
in interface StatefulService
public boolean isStopped()
StatefulService
isStopped
in interface StatefulService
public boolean isSuspending()
StatefulService
isSuspending
in interface StatefulService
public boolean isSuspended()
SuspendableService
isSuspended
in interface SuspendableService
public boolean isRunAllowed()
StatefulService
isRunAllowed
in interface StatefulService
public boolean isShutdown()
public boolean isStoppingOrStopped()
public boolean isSuspendingOrSuspended()
public boolean isStartingOrStarted()
protected void doInit() throws Exception
Exception
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
Exception
protected void doResume() throws Exception
Exception
protected void doShutdown() throws Exception
Exception
Apache Camel