Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.soa.esb.listeners.lifecycle
Class AbstractThreadedManagedLifecycle

    java.lang.Object
      org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle
          org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle

All Implemented Interfaces:
  java.io.Serializable, java.lang.Runnable, ManagedLifecycle

Direct Known Subclasses:
  GroovyGateway, JmsGatewayListener, MessageAwareListener, SqlTableGatewayListener

    public abstract class AbstractThreadedManagedLifecycle

extends AbstractManagedLifecycle
implements java.lang.Runnable

This class provides threaded support for a managed instance.

Author:
  kevin
See Also:
  Serialized Form

Field Summary

Fields inherited from class org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle
`PARAM_TERMINATION_PERIOD`

Constructor Summary
`protected` | `AbstractThreadedManagedLifecycle(ConfigTree config)` Construct the threaded managed lifecycle.

Method Summary
`void` | `addManagedLifecycleThreadEventListener(ManagedLifecycleThreadEventListener listener)` Add a managed lifecycle thread event listener.
`protected void` | `doDestroy()` Handle the destroy of the managed instance.
`protected abstract void` | `doRun()` Execute on the thread.
`protected void` | `doStart()` Handle the start of the managed instance.
`protected void` | `doStop()` Handle the stop of the managed instance.
`protected void` | `doThreadedDestroy()` Handle the threaded destroy of the managed instance.
`boolean` | `isRunning()` Is the associated thread still running?
`boolean` | `isStopped()` Is the associated thread stopped?
`boolean` | `isStopping()` Is the associated thread stopping?
`void` | `removeManagedLifecycleThreadEventListener(ManagedLifecycleThreadEventListener listener)` Remove a managed lifecycle thread event listener.
`void` | `run()` The thread execution method.
`protected void` | `setRunning(ManagedLifecycleThreadState newState)` Set the running state.
`protected boolean` | `waitForRunningStateChange(ManagedLifecycleThreadState state, long terminationPeriod)` Wait until the running state has the specified value.
`boolean` | `waitUntilStopped()` Wait until the associated thread has stopped.
`boolean` | `waitUntilStopped(long terminationPeriod)` Wait until the associated thread has stopped.
`boolean` | `waitUntilStopping(long terminationPeriod)` Wait until the associated thread has changed to a state of "STOPPING".

Methods inherited from class org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle
`addManagedLifecycleEventListener, changeState, destroy, doInitialise, getConfig, getState, getTerminationPeriod, initialise, removeManagedLifecycleEventListener, start, stop, waitUntilDestroyed, waitUntilDestroyed, waitUntilNotState, waitUntilState`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractThreadedManagedLifecycle

    protected AbstractThreadedManagedLifecycle(ConfigTree config)
                                        throws ConfigurationException

  Construct the threaded managed lifecycle.

  Parameters:
    `config` - The configuration associated with this instance.
  Throws:
    `ConfigurationException` - for configuration errors during initialisation.

Method Detail

### doStart

    protected void doStart()
                    throws ManagedLifecycleException

  Handle the start of the managed instance.

  Specified by:
    `doStart` in class `AbstractManagedLifecycle`
  Throws:
    `ManagedLifecycleException` - for errors while starting.

### run

    public final void run()

  The thread execution method.

  Specified by:
    `run` in interface `java.lang.Runnable`

### doRun

    protected abstract void doRun()

  Execute on the thread.

### doStop

    protected void doStop()
                   throws ManagedLifecycleException

  Handle the stop of the managed instance.

  Specified by:
    `doStop` in class `AbstractManagedLifecycle`
  Throws:
    `ManagedLifecycleException` - for errors while stopping.

### doDestroy

    protected final void doDestroy()
                            throws ManagedLifecycleException

  Handle the destroy of the managed instance.

  Specified by:
    `doDestroy` in class `AbstractManagedLifecycle`
  Throws:
    `ManagedLifecycleException` - for errors while destroying.

### doThreadedDestroy

    protected void doThreadedDestroy()
                              throws ManagedLifecycleException

  Handle the threaded destroy of the managed instance.

  Throws:
    `ManagedLifecycleException` - for errors while destroying.

### isRunning

    public boolean isRunning()

  Is the associated thread still running?

  Returns:
    true if the thread is still running, false otherwise.

### isStopped

    public boolean isStopped()

  Is the associated thread stopped?

  Returns:
    true if the thread is stopped, false otherwise.

### isStopping

    public boolean isStopping()

  Is the associated thread stopping?

  Returns:
    true if the thread is stopped, false otherwise.

### setRunning

    protected void setRunning(ManagedLifecycleThreadState newState)

  Set the running state.

  Parameters:
    `newState` - The new running state.

### waitUntilStopping

    public boolean waitUntilStopping(long terminationPeriod)

  Wait until the associated thread has changed to a state of "STOPPING".

  Parameters:
    `terminationPeriod` - The maximum delay expected for the termination, specified in milliseconds.
  Returns:
    true if the thread changes state to "STOPPING" within the expected period, false otherwise.

### waitUntilStopped

    public boolean waitUntilStopped()

  Wait until the associated thread has stopped.

  Returns:
    true if the thread stops within the expected period, false otherwise.

### waitUntilStopped

    public boolean waitUntilStopped(long terminationPeriod)

  Wait until the associated thread has stopped.

  Parameters:
    `terminationPeriod` - The maximum delay expected for the termination, specified in milliseconds.
  Returns:
    true if the thread stops within the expected period, false otherwise.

### waitForRunningStateChange

    protected boolean waitForRunningStateChange(ManagedLifecycleThreadState state,
                                                long terminationPeriod)

  Wait until the running state has the specified value.

  Parameters:
    `state` - The expected running state value.
    `terminationPeriod` - The maximum delay expected for the termination, specified in milliseconds.
  Returns:
    true if the state has the specified value within the expected period, false otherwise.

### addManagedLifecycleThreadEventListener

    public void addManagedLifecycleThreadEventListener(ManagedLifecycleThreadEventListener listener)

  Add a managed lifecycle thread event listener.

  Parameters:
    `listener` - The listener.

### removeManagedLifecycleThreadEventListener

    public void removeManagedLifecycleThreadEventListener(ManagedLifecycleThreadEventListener listener)

  Remove a managed lifecycle thread event listener.

  Parameters:
    `listener` - The listener.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD