O
- The object type being managed by this LifecycleManager
public abstract class AbstractLifecycleManager<O> extends Object implements LifecycleManager
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.Modifier and Type | Field and Description |
---|---|
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 |
NOT_IN_LIFECYCLE_PHASE
Constructor and Description |
---|
AbstractLifecycleManager(String id,
O object) |
Modifier and Type | Method and Description |
---|---|
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 phase)
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) |
protected final transient Log logger
protected String lifecycleManagerId
protected String currentPhase
protected String executingPhase
protected O object
protected LifecycleState state
protected abstract void registerTransitions()
public void registerLifecycleCallback(String phaseName, LifecycleCallback<O> callback)
protected LifecycleState createLifecycleState()
public void checkPhase(String name) throws IllegalStateException
LifecycleManager
checkPhase
in interface LifecycleManager
name
- The name of the lifecycle to validate as a valid next transitionIllegalStateException
- if the lifecycle name is not recognised or the phase is not valid for the current lifecycle statepublic O getLifecycleObject()
public void fireLifecycle(String phase) throws LifecycleException
LifecycleManager
fireLifecycle
in interface LifecycleManager
phase
- that phase to execute nextLifecycleException
- if the phase is not a valid transition of does not exist on this lifecycle managerprotected void invokePhase(String phase, Object object, LifecycleCallback callback) throws LifecycleException
LifecycleException
public boolean isDirectTransition(String destinationPhase)
isDirectTransition
in interface LifecycleManager
public String getCurrentPhase()
LifecycleManager
LifecycleManager.getExecutingPhase()
to get the phase being executed.getCurrentPhase
in interface LifecycleManager
protected void setCurrentPhase(String currentPhase)
public String getExecutingPhase()
LifecycleManager
getExecutingPhase
in interface LifecycleManager
protected void setExecutingPhase(String executingPhase)
protected void notifyTransition(String phase)
phase
- the currently completed phasepublic void reset()
LifecycleManager
reset
in interface LifecycleManager
public boolean isPhaseComplete(String phaseName)
LifecycleManager
isPhaseComplete
in interface LifecycleManager
phaseName
- the name of the pahse to check forpublic LifecycleState getState()
LifecycleManager
getState
in interface LifecycleManager
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.