Package org.eclipse.sisu.bean
Class LifecycleManager
- java.lang.Object
-
- org.eclipse.sisu.bean.BeanScheduler
-
- org.eclipse.sisu.bean.LifecycleManager
-
- All Implemented Interfaces:
BeanManager
public final class LifecycleManager extends BeanScheduler implements BeanManager
BeanManagerthat manages JSR250 beans and schedules lifecycle events.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.sisu.bean.BeanScheduler
BeanScheduler.CycleActivator
-
-
Field Summary
Fields Modifier and Type Field Description private LifecycleBuilderbuilderprivate java.util.Map<java.lang.Class<?>,BeanLifecycle>lifecyclesprivate java.util.Deque<java.lang.Object>stoppableBeans-
Fields inherited from class org.eclipse.sisu.bean.BeanScheduler
CANDIDATE_CYCLE, CYCLE_ACTIVATOR, CYCLE_CONFIRMED, MODULE, pendingHolder
-
-
Constructor Summary
Constructors Constructor Description LifecycleManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(java.lang.Object bean)Customized activation of the given bean.private booleanbuildLifecycle(java.lang.Class<?> clazz)Attempts to build a JSR250 lifecycle for the given bean type.private BeanLifecyclelifecycleFor(java.lang.Object bean)Looks up the JSR250 lifecycle previously built for this bean.booleanmanage(java.lang.Class<?> clazz)Decides whether instances of the given bean type should be reported to this manager.booleanmanage(java.lang.Object bean)Asks this manager to manage the given bean instance.PropertyBindingmanage(BeanProperty<?> property)Asks this manager to manage the given bean property.private java.lang.ObjectpopStoppable()private voidpushStoppable(java.lang.Object bean)private booleanremoveStoppable(java.lang.Object bean)booleanunmanage()Asks this manager to unmanage all the bean instances it knows about.booleanunmanage(java.lang.Object bean)Asks this manager to unmanage the given bean instance.-
Methods inherited from class org.eclipse.sisu.bean.BeanScheduler
detectCycle, schedule
-
-
-
-
Field Detail
-
builder
private final LifecycleBuilder builder
-
lifecycles
private final java.util.Map<java.lang.Class<?>,BeanLifecycle> lifecycles
-
stoppableBeans
private final java.util.Deque<java.lang.Object> stoppableBeans
-
-
Method Detail
-
manage
public boolean manage(java.lang.Class<?> clazz)
Description copied from interface:BeanManagerDecides whether instances of the given bean type should be reported to this manager.- Specified by:
managein interfaceBeanManager- Parameters:
clazz- The bean type- Returns:
trueif instances of the bean should be reported; otherwisefalse
-
manage
public PropertyBinding manage(BeanProperty<?> property)
Description copied from interface:BeanManagerAsks this manager to manage the given bean property.- Specified by:
managein interfaceBeanManager- Parameters:
property- The bean property- Returns:
- Non-null binding if the bean property was managed; otherwise
null
-
manage
public boolean manage(java.lang.Object bean)
Description copied from interface:BeanManagerAsks this manager to manage the given bean instance.- Specified by:
managein interfaceBeanManager- Parameters:
bean- The bean instance- Returns:
trueif the bean instance was managed; otherwisefalse
-
unmanage
public boolean unmanage(java.lang.Object bean)
Description copied from interface:BeanManagerAsks this manager to unmanage the given bean instance.- Specified by:
unmanagein interfaceBeanManager- Parameters:
bean- The bean instance- Returns:
trueif the bean instance was unmanaged; otherwisefalse
-
unmanage
public boolean unmanage()
Description copied from interface:BeanManagerAsks this manager to unmanage all the bean instances it knows about.- Specified by:
unmanagein interfaceBeanManager- Returns:
trueif any bean instances were unmanaged; otherwisefalse
-
activate
protected void activate(java.lang.Object bean)
Description copied from class:BeanSchedulerCustomized activation of the given bean.- Specified by:
activatein classBeanScheduler- Parameters:
bean- The bean to activate
-
buildLifecycle
private boolean buildLifecycle(java.lang.Class<?> clazz)
Attempts to build a JSR250 lifecycle for the given bean type.- Parameters:
clazz- The bean type- Returns:
trueif the bean defines a lifecycle; otherwisefalse
-
lifecycleFor
private BeanLifecycle lifecycleFor(java.lang.Object bean)
Looks up the JSR250 lifecycle previously built for this bean.- Parameters:
bean- The bean instance- Returns:
- Lifecycle for the bean
-
pushStoppable
private void pushStoppable(java.lang.Object bean)
-
removeStoppable
private boolean removeStoppable(java.lang.Object bean)
-
popStoppable
private java.lang.Object popStoppable()
-
-