|
Class AsyncManagedExecutable
|
On invocation AsyncManagedExecutable will transition to an transient
state and invoke the associated abstract method to kick-off the process of
transitioning the executable to the target state. For example, when an IDLE
asynchronous executable is started, AsyncManagedExecutable will transition
to the transient STARTING state and invoke the doStart() method
on the implementation. The implementation will kick-off the starting process
and return. When the implemenation reaches the RUNNING state it MUST
indicate it's arrival through the running() callback.
NOTE: it is the responsibility of the implementor to indicate when
they reach the target state by invoking one of the following:
running(): invoked to indicate that the executable has reached the RUNNING statesuspended(): invoked to indicate that the executable has reached the SUSPENDED statedone(): invoked to indicate that the executable has reached the DONE stateerror(): invoked to indicate that the executable has reached the ERROR state
extending AsyncManagedExecutable requires implementations for the following
methods:
doStart(): kick-off executable startupdoStop(): kick-off executable stopdoRestart(): kick-off executable restartdoShutdown(): kick-off executable graceful shutdowndoSuspend(): kick-off suspension of executiondoResume(): kick-off resuming of execution
NOTE: If the implementation throws and exception during itsdo...() method, AsyncManagedExecutable will automatically
transition to exectuable to ERROR and rethrow the exception.
NOTE: the AsyncManagedExecutable implementation has a default
implementation for doSuspend, doResume, and doRestart that throw an ExecutableException
indicating that the suspend/resume/restart operation is not supported
NOTE:invoking these from the body of yourdo...() method renders the implemenation of the operation
synchronous. You should reconsider using the SyncManagedExecutable if this
is true for all your transitions.
On invocation AsyncManagedExecutable will transition to an transient
state and invoke the associated abstract method to kick-off the process of
transitioning the executable to the target state. For example, when an IDLE
asynchronous executable is started, AsyncManagedExecutable will transition
to the transient STARTING state and invoke the doStart() method
on the implementation. The implementation will kick-off the starting process
and return. When the implemenation reaches the RUNNING state it MUST
indicate it's arrival through the running() callback.
NOTE: it is the responsibility of the implementor to indicate when
they reach the target state by invoking one of the following:
running(): invoked to indicate that the executable has reached the RUNNING statesuspended(): invoked to indicate that the executable has reached the SUSPENDED statedone(): invoked to indicate that the executable has reached the DONE stateerror(): invoked to indicate that the executable has reached the ERROR state
extending AsyncManagedExecutable requires implementations for the following
methods:
doStart(): kick-off executable startupdoStop(): kick-off executable stopdoRestart(): kick-off executable restartdoShutdown(): kick-off executable graceful shutdowndoSuspend(): kick-off suspension of executiondoResume(): kick-off resuming of execution
NOTE: If the implementation throws and exception during itsdo...() method, AsyncManagedExecutable will automatically
transition to exectuable to ERROR and rethrow the exception.
NOTE: the AsyncManagedExecutable implementation has a default
implementation for doSuspend, doResume, and doRestart that throw an ExecutableException
indicating that the suspend/resume/restart operation is not supported
NOTE:invoking these from the body of yourdo...() method renders the implemenation of the operation
synchronous. You should reconsider using the SyncManagedExecutable if this
is true for all your transitions.
| Field Summary | |
|---|---|
private final static String |
|
private String |
|
private List |
|
private static Logger |
|
private ExecState |
|
| Method Summary | |
|---|---|
public synchronized void |
addListener(ManagedExecutableListener listener) |
protected synchronized final void |
done() |
protected void |
|
protected void |
doResume() |
protected abstract void |
|
protected abstract void |
doStart() |
protected abstract void |
doStop() |
protected void |
|
protected synchronized final void |
error() |
public synchronized ExecState |
getState() |
public synchronized void |
removeListener(ManagedExecutableListener listener) |
public synchronized void |
resume() |
protected synchronized final void |
running() |
private void |
|
public synchronized void |
shutdown() |
public synchronized void |
start() |
public synchronized void |
stop() |
public synchronized void |
suspend() |
protected synchronized final void |
|
NOTE: done() MUST be invoked by AsyncManagedExecutable
implementations to indicate that they have reached the DONE state.
NOTE:invoking done() from the body of yourdoStop() or doShutdown() methods creates a
synchronous implementation of the transition. You may reconsider using the
SyncManagedExecutable if this is true for all your transitions.
NOTE: AsyncManagedExecutable implementations MUST invoke therunning() method to indicate that they have reached the
RUNNING state.
NOTE: AsyncManagedExecutable implementations MUST invoke therunning() method to indicate that they have reached the
RUNNING state.
NOTE: AsyncManagedExecutable implementations MUST invoke theidle() method to indicate that they have reached the
IDLE state.
NOTE: AsyncManagedExecutable implementations MUST invoke therunning() method to indicate that they have reached the
RUNNING state.
NOTE: AsyncManagedExecutable implementations MUST invoke theidle() method to indicate that they have reached the
IDLE state.
NOTE: AsyncManagedExecutable implementations MUST invoke thesuspended() method to indicate that they have reached the
SUSPENDED state.
NOTE: error() MUST be invoked by AsyncManagedExecutable
implementations to indicate that they have reached the ERROR state.
doResume() method.
NOTE:
resume() may only be invoked onrunning() method to indicate that they have
NOTE:invokingrunning() from the body of yourdoResume() method creates a synchronous implementation of the
transition. You may reconsider using the SyncManagedExecutable if this
is true for all your transitions.
NOTE: running() MUST be invoked by AsyncManagedExecutable
implementations to indicate that they have reached the RUNNING state.
NOTE:invoking running() from the body of yourdoStart() or doResume() methods creates a
synchronous implementation of the transition. You may reconsider using the
SyncManagedExecutable if this is true for all your transitions.
doShutdown() method.
NOTE:
shutdown() may only be invoked ondone() method to indicate that they have
NOTE:invokingdone() from the body of yourdoShutdown() method creates a synchronous implementation of the
transition. You may reconsider using the SyncManagedExecutable if this
is true for all your transitions.
doStart() method.
NOTE:
start() may only be invoked onrunning() method to indicate that they have
NOTE:invoking running() from the body of yourdoStart() method creates a synchronous implementation of the
transition. You may reconsider using the SyncManagedExecutable if this
is true for all your transitions.
doStop() method.
NOTE:
stop() may only be invoked ondone() method to indicate that they have
NOTE:invokingdone() from the body of yourdoStop() method creates a synchronous implementation of the
transition. You may reconsider using the SyncManagedExecutable if this
is true for all your transitions.
doSuspend() method.
NOTE:
suspend() may only be invoked onsuspended() method to indicate that they have
NOTE:invokingsuspended() from the body of yourdoSuspdend() method creates a synchronous implementation of the
transition. You may reconsider using the SyncManagedExecutable if this
is true for all your transitions.
NOTE: suspended() MUST be invoked by AsyncManagedExecutable
implementations to indicate that they have reached the SUSPENDED state.
NOTE:invoking suspended() from the body of yourdoSuspend() method creates a synchronous implementation
of the transition. You may reconsider using the SyncManagedExecutable if
this is true for all your transitions.