O - The object type being managed by this LifecycleManagerpublic 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 org.slf4j.Logger |
logger
logger used by this class
|
protected O |
object |
protected Set<String> |
phaseNames |
protected LifecycleState |
state |
| Constructor and Description |
|---|
AbstractLifecycleManager(String id,
O object) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDirectTransition(String phase1,
String phase2) |
void |
applyCompletedPhases(Object object)
Successively applies all completed lifecycle phase to an object.
|
void |
applyPhase(Object object,
String startPhase,
String toPhase)
Applies lifecycle phase to an object independent of the current lifecycle phase.
|
void |
checkPhase(String name)
Will check that the phase passed in is a valid next phase for this lifecycle manager.
|
protected LifecycleState |
createLifecycleState() |
protected void |
doOnConnectException(ConnectException ce) |
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.
|
String |
getLastPhaseExecuted() |
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 |
isLastPhaseExecutionFailed() |
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 org.slf4j.Logger 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
LifecycleManagercheckPhase in interface LifecycleManagername - 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 org.mule.runtime.api.lifecycle.LifecycleException
LifecycleManagerfireLifecycle in interface LifecycleManagerphase - that phase to execute nextorg.mule.runtime.api.lifecycle.LifecycleException - 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 org.mule.runtime.api.lifecycle.LifecycleException
org.mule.runtime.api.lifecycle.LifecycleExceptionprotected void doOnConnectException(ConnectException ce) throws org.mule.runtime.api.lifecycle.LifecycleException
org.mule.runtime.api.lifecycle.LifecycleExceptionpublic void applyPhase(Object object, String startPhase, String toPhase) throws org.mule.runtime.api.lifecycle.LifecycleException
startPhase
(not inclusive) and the endPhase will be executed.applyPhase in interface LifecycleManagerobject - the object to apply lifecycle tostartPhase - the lifecycle phase the object is currently in. Must not be null.toPhase - the lifecycle phase to transition the object to. Must not be null.org.mule.runtime.api.lifecycle.LifecycleException - if there is an exception while invoking lifecycle on the objectpublic void applyCompletedPhases(Object object) throws org.mule.runtime.api.lifecycle.LifecycleException
applyCompletedPhases in interface LifecycleManagerobject - the object to which the lifecycle should be appliedorg.mule.runtime.api.lifecycle.LifecycleException - if there is an error while applying lifecycle to the objectpublic boolean isDirectTransition(String destinationPhase)
isDirectTransition in interface LifecycleManagerpublic String getCurrentPhase()
LifecycleManagerLifecycleManager.getExecutingPhase() to get the phase being executed.getCurrentPhase in interface LifecycleManagerprotected void setCurrentPhase(String currentPhase)
public String getExecutingPhase()
LifecycleManagergetExecutingPhase in interface LifecycleManagerprotected void setExecutingPhase(String executingPhase)
protected void notifyTransition(String phase)
phase - the currently completed phasepublic void reset()
LifecycleManagerreset in interface LifecycleManagerpublic boolean isPhaseComplete(String phaseName)
LifecycleManagerisPhaseComplete in interface LifecycleManagerphaseName - the name of the pahse to check forpublic LifecycleState getState()
LifecycleManagergetState in interface LifecycleManagerpublic String getLastPhaseExecuted()
public boolean isLastPhaseExecutionFailed()
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.