Class AbstractLifeCycle<T extends LifeCycleListener<E>,E extends LifeCycleEvent<?,?>>
- java.lang.Object
-
- org.exoplatform.social.common.lifecycle.AbstractLifeCycle<T,E>
-
- Direct Known Subclasses:
ActivityLifeCycle,ProfileLifeCycle,SpaceLifecycle
public abstract class AbstractLifeCycle<T extends LifeCycleListener<E>,E extends LifeCycleEvent<?,?>> extends Object
Generic implementation a Lifecycle
Events are dispatched asynchronously but sequentially to their listeners according to their type.
Listeners may fail, this is safe for the lifecycle, subsequent listeners will still be called.- Version:
- $Revision$
- Author:
- Patrice Lamarque
-
-
Field Summary
Fields Modifier and Type Field Description protected LifeCycleCompletionServicecompletionServiceprotected org.exoplatform.container.PortalContainercontainerprotected Set<T>listeners
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLifeCycle()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(T listener)protected voidbegin()protected voidbroadcast(E event)Broadcasts an event to the registered listeners.protected abstract voiddispatchEvent(T listener, E event)protected voidend()voidremoveListener(T listener)
-
-
-
Field Detail
-
listeners
protected Set<T extends LifeCycleListener<E>> listeners
-
container
protected final org.exoplatform.container.PortalContainer container
-
completionService
protected LifeCycleCompletionService completionService
-
-
Method Detail
-
addListener
public void addListener(T listener)
-
removeListener
public void removeListener(T listener)
-
broadcast
protected void broadcast(E event)
Broadcasts an event to the registered listeners. The event is broadcasted asynchronously but sequentially.- Parameters:
event-- See Also:
dispatchEvent(LifeCycleListener, LifeCycleEvent)
-
begin
protected void begin()
-
end
protected void end()
-
-