org.mule.lifecycle.phases
Class DefaultLifecyclePhase

java.lang.Object
  extended by org.mule.lifecycle.phases.DefaultLifecyclePhase
All Implemented Interfaces:
MuleContextAware, LifecyclePhase, NamedObject
Direct Known Subclasses:
ContainerManagedLifecyclePhase, MuleContextDisposePhase, MuleContextInitialisePhase, MuleContextStartPhase, MuleContextStopPhase, NotInLifecyclePhase, PausePhase, ResumePhase

public class DefaultLifecyclePhase
extends Object
implements LifecyclePhase, MuleContextAware

Represents a configurable lifecycle phase. This is a default implementation of a 'generic phase' in that is can be configured to represnt any phase. Instances of this phase can then be registered with a LifecycleManager and by used to enforce a lifecycle phase on an object. Usually, Lifecycle phases have a fixed configuration in which case a specialisation of this class should be created that initialises its configuration internally.

Note that this class and LifecycleTransitionResult both make assumptions about the interfaces used - the return values and exceptions. These are, currently, that the return value is either void or LifecycleTransitionResult and either 0 or 1 exceptions can be thrown which are either InstantiationException or LifecycleException.

See Also:
LifecyclePhase

Field Summary
protected  Log logger
           
 
Fields inherited from interface org.mule.api.lifecycle.LifecyclePhase
ALL_PHASES
 
Constructor Summary
DefaultLifecyclePhase(String name, Class<?> lifecycleClass, String oppositeLifecyclePhase)
           
 
Method Summary
 void addOrderedLifecycleObject(LifecycleObject lco)
           
 void applyLifecycle(Object o)
           
 Class<?>[] getIgnoredObjectTypes()
           
 Class<?> getLifecycleClass()
           
 String getName()
          Gets the name of the object
 String getOppositeLifecyclePhase()
           
 Set<LifecycleObject> getOrderedLifecycleObjects()
           
 Set<String> getSupportedPhases()
           
protected  boolean ignoreType(Class<?> type)
           
 boolean isPhaseSupported(String phase)
           
 void registerSupportedPhase(String phase)
           
 void removeOrderedLifecycleObject(LifecycleObject lco)
           
 void setIgnoredObjectTypes(Class<?>[] ignorredObjectTypes)
           
 void setLifecycleClass(Class<?> lifecycleClass)
           
 void setMuleContext(MuleContext context)
           
 void setOrderedLifecycleObjects(Set<LifecycleObject> orderedLifecycleObjects)
           
 void setSupportedPhases(Set<String> supportedPhases)
           
protected  List sortLifecycleInstances(Collection objects, LifecycleObject lo)
          Subclasses can override this method to order objects before the lifecycle method is applied to them.
 
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
Constructor Detail

DefaultLifecyclePhase

public DefaultLifecyclePhase(String name,
                             Class<?> lifecycleClass,
                             String oppositeLifecyclePhase)
Method Detail

setMuleContext

public void setMuleContext(MuleContext context)
Specified by:
setMuleContext in interface MuleContextAware

sortLifecycleInstances

protected List sortLifecycleInstances(Collection objects,
                                      LifecycleObject lo)
Subclasses can override this method to order objects before the lifecycle method is applied to them. This method does not apply any special ordering to objects.

Parameters:
objects -
lo -
Returns:
List with ordered objects

addOrderedLifecycleObject

public void addOrderedLifecycleObject(LifecycleObject lco)
Specified by:
addOrderedLifecycleObject in interface LifecyclePhase

removeOrderedLifecycleObject

public void removeOrderedLifecycleObject(LifecycleObject lco)
Specified by:
removeOrderedLifecycleObject in interface LifecyclePhase

ignoreType

protected boolean ignoreType(Class<?> type)

getOrderedLifecycleObjects

public Set<LifecycleObject> getOrderedLifecycleObjects()
Specified by:
getOrderedLifecycleObjects in interface LifecyclePhase

setOrderedLifecycleObjects

public void setOrderedLifecycleObjects(Set<LifecycleObject> orderedLifecycleObjects)
Specified by:
setOrderedLifecycleObjects in interface LifecyclePhase

getIgnoredObjectTypes

public Class<?>[] getIgnoredObjectTypes()
Specified by:
getIgnoredObjectTypes in interface LifecyclePhase

setIgnoredObjectTypes

public void setIgnoredObjectTypes(Class<?>[] ignorredObjectTypes)
Specified by:
setIgnoredObjectTypes in interface LifecyclePhase

getLifecycleClass

public Class<?> getLifecycleClass()
Specified by:
getLifecycleClass in interface LifecyclePhase

setLifecycleClass

public void setLifecycleClass(Class<?> lifecycleClass)
Specified by:
setLifecycleClass in interface LifecyclePhase

getName

public String getName()
Description copied from interface: NamedObject
Gets the name of the object

Specified by:
getName in interface NamedObject
Returns:
the name of the object

getSupportedPhases

public Set<String> getSupportedPhases()
Specified by:
getSupportedPhases in interface LifecyclePhase

setSupportedPhases

public void setSupportedPhases(Set<String> supportedPhases)
Specified by:
setSupportedPhases in interface LifecyclePhase

registerSupportedPhase

public void registerSupportedPhase(String phase)
Specified by:
registerSupportedPhase in interface LifecyclePhase

isPhaseSupported

public boolean isPhaseSupported(String phase)
Specified by:
isPhaseSupported in interface LifecyclePhase

applyLifecycle

public void applyLifecycle(Object o)
                    throws LifecycleException
Specified by:
applyLifecycle in interface LifecyclePhase
Throws:
LifecycleException

getOppositeLifecyclePhase

public String getOppositeLifecyclePhase()
Specified by:
getOppositeLifecyclePhase in interface LifecyclePhase


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