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

## org.mule.lifecycle
Class AbstractLifecycleManager<O>

    java.lang.Object
      org.mule.lifecycle.AbstractLifecycleManager<O>

Type Parameters:
  `O` - The object type being managed by this `LifecycleManager`

All Implemented Interfaces:
  LifecycleManager

Direct Known Subclasses:
  MuleContextLifecycleManager, RegistryLifecycleManager, SimpleLifecycleManager

    public abstract class AbstractLifecycleManager<O>

extends Object
implements LifecycleManager

This is a base implementation of the `LifecycleManager` interface and provides almost all the plumbing required to write a `LifecycleManager` implementation. This class handles the tracking ofg the phases, transition validation and checking state.

Since:
  3.0

Field Summary
`protected Set<String>` | `completedPhases`
`protected String` | `currentPhase`
`protected String` | `executingPhase`
`protected String` | `lifecycleManagerId`
`protected Log` | `logger` logger used by this class
`protected O` | `object`
`protected Set<String>` | `phaseNames`
`protected LifecycleState` | `state`

Fields inherited from interface org.mule.api.lifecycle.LifecycleManager
`NOT_IN_LIFECYCLE_PHASE`

Constructor Summary
`AbstractLifecycleManager(String id, O object)`

Method Summary
`protected void` | `addDirectTransition(String phase1, String phase2)`
`void` | `checkPhase(String name)` Will check that the phase passed in is a valid next phase for this lifecycle manager.
`protected LifecycleState` | `createLifecycleState()`
`void` | `fireLifecycle(String phase)` Applies lifecycle phase to a collection of objects.
`String` | `getCurrentPhase()` The current phase for the lifecycle manager.
`String` | `getExecutingPhase()` Returns the lifecycle phase being executed.
`O` | `getLifecycleObject()`
`LifecycleState` | `getState()` Provides access to a state machine for this lifecycle manager.
`protected void` | `invokePhase(String phase, Object object, LifecycleCallback callback)`
`boolean` | `isDirectTransition(String destinationPhase)`
`protected boolean` | `isDirectTransition(String startPhase, String endPhase)`
`boolean` | `isPhaseComplete(String phaseName)` Checks that a phase has completed
`protected void` | `notifyTransition(String currentPhase)` Allows any for any state adjustments in sub classes.
`void` | `registerLifecycleCallback(String phaseName, LifecycleCallback<O> callback)`
`protected abstract void` | `registerTransitions()`
`void` | `reset()` Reset the lifecycle manager state back to 'not in lifecycle' phase
`protected void` | `setCurrentPhase(String currentPhase)`
`protected void` | `setExecutingPhase(String executingPhase)`

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

Field Detail

### logger

    protected final transient Log logger

  logger used by this class

### lifecycleManagerId

    protected String lifecycleManagerId

### currentPhase

    protected String currentPhase

### executingPhase

    protected String executingPhase

### phaseNames

    protected Set<String> phaseNames

### completedPhases

    protected Set<String> completedPhases

### object

    protected O object

### state

    protected LifecycleState state

Constructor Detail

### AbstractLifecycleManager

    public AbstractLifecycleManager(String id,
                                    O object)

Method Detail

### registerTransitions

    protected abstract void registerTransitions()

### registerLifecycleCallback

    public void registerLifecycleCallback(String phaseName,
                                          LifecycleCallback<O> callback)

### createLifecycleState

    protected LifecycleState createLifecycleState()

### addDirectTransition

    protected void addDirectTransition(String phase1,
                                       String phase2)

### checkPhase

    public void checkPhase(String name)
                    throws IllegalStateException

  Description copied from interface: `LifecycleManager`
  Will check that the phase passed in is a valid next phase for this lifecycle manager. If the phase is not a valid next transition an exception will be thrown

  Specified by:
    `checkPhase` in interface `LifecycleManager`
  Parameters:
    `name` - The name of the lifecycle to validate as a valid next transition
  Throws:
    `IllegalStateException` - if the lifecycle name is not recognised or the phase is not valid for the current lifecycle state

### getLifecycleObject

    public O getLifecycleObject()

### fireLifecycle

    public void fireLifecycle(String phase)
                       throws LifecycleException

  Description copied from interface: `LifecycleManager`
  Applies lifecycle phase to a collection of objects.

  Specified by:
    `fireLifecycle` in interface `LifecycleManager`
  Parameters:
    `phase` - that phase to execute next
  Throws:
    `LifecycleException` - if the phase is not a valid transition of does not exist on this lifecycle manager

### invokePhase

    protected void invokePhase(String phase,
                               Object object,
                               LifecycleCallback callback)
                        throws LifecycleException

  Throws:
    `LifecycleException`

### isDirectTransition

    public boolean isDirectTransition(String destinationPhase)

  Specified by:
    `isDirectTransition` in interface `LifecycleManager`

### isDirectTransition

    protected boolean isDirectTransition(String startPhase,
                                         String endPhase)

### getCurrentPhase

    public String getCurrentPhase()

  Description copied from interface: `LifecycleManager`
  The current phase for the lifecycle manager. While in transition this will reflect the last completed phase not the currently executing phase, use `LifecycleManager.getExecutingPhase()` to get the phase being executed.

  Specified by:
    `getCurrentPhase` in interface `LifecycleManager`
  Returns:
    The current completed phase for the lifecycle manager

### setCurrentPhase

    protected void setCurrentPhase(String currentPhase)

### getExecutingPhase

    public String getExecutingPhase()

  Description copied from interface: `LifecycleManager`
  Returns the lifecycle phase being executed. This will be null if the lifecycle is not in transition

  Specified by:
    `getExecutingPhase` in interface `LifecycleManager`
  Returns:
    the lifecycle phase being executed

### setExecutingPhase

    protected void setExecutingPhase(String executingPhase)

### notifyTransition

    protected void notifyTransition(String currentPhase)

  Allows any for any state adjustments in sub classes. For example, it may be necessary to remove a state from the 'completedPhases' collection once a transition occurs. This is only necessary for a Lifecycle Manager that introduces a new phase pair.

  Parameters:
    `currentPhase` - the currently completed phase

### reset

    public void reset()

  Description copied from interface: `LifecycleManager`
  Reset the lifecycle manager state back to 'not in lifecycle' phase

  Specified by:
    `reset` in interface `LifecycleManager`

### isPhaseComplete

    public boolean isPhaseComplete(String phaseName)

  Description copied from interface: `LifecycleManager`
  Checks that a phase has completed

  Specified by:
    `isPhaseComplete` in interface `LifecycleManager`
  Parameters:
    `phaseName` - the name of the pahse to check for
  Returns:
    true if that phase has completed, false if the phase has not completed, or currently processing or does not exist

### getState

    public LifecycleState getState()

  Description copied from interface: `LifecycleManager`
  Provides access to a state machine for this lifecycle manager. components in the registry can use this to assert lifecycle rather than managing thier own lifecycle state

  Specified by:
    `getState` in interface `LifecycleManager`
  Returns:
    A state machine for this lifecycle manager

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

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.