Class AbstractConcurrentEventManager
java.lang.Object
org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
- All Implemented Interfaces:
Serializable,EventManager
- Direct Known Subclasses:
AbstractDataCache,AbstractQueryCache,BrokerFactoryEventManager,JDBCEventConnectionDecorator,RemoteCommitEventManager,TransactionEventManager
public abstract class AbstractConcurrentEventManager
extends Object
implements EventManager, Serializable
Base event manager that handles adding/removing listeners
and firing events. Meant for high concurrency. This class is
reentrant-safe; listeners can be added and removed by other listeners when
they receive events. The changes will not be visible until the event fire
that initiated the recursive sequence of calls completes, however.
- Author:
- Abe White
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Object listener) Register an event listener.Fire the given event to all listeners.protected abstract voidImplement this method to fire the given event to the given listener.Return a read-only list of listeners.booleanhasListener(Object listener) Return whether the given instance is in the list of listeners.booleanReturn true if there are any registered listeners.booleanWhether to fail after the first exception thrown by any listener.protected CollectionReturn a new concurrent container for listeners.booleanremoveListener(Object listener) Remove an event listener.voidsetFailFast(boolean failFast) Whether to fail after the first exception thrown by any listener.
-
Field Details
-
_listeners
-
-
Constructor Details
-
AbstractConcurrentEventManager
public AbstractConcurrentEventManager()Default constructor.
-
-
Method Details
-
isFailFast
public boolean isFailFast()Whether to fail after the first exception thrown by any listener. -
setFailFast
public void setFailFast(boolean failFast) Whether to fail after the first exception thrown by any listener. -
addListener
Register an event listener.- Specified by:
addListenerin interfaceEventManager
-
removeListener
Remove an event listener.- Specified by:
removeListenerin interfaceEventManager
-
hasListener
Return whether the given instance is in the list of listeners.- Specified by:
hasListenerin interfaceEventManager
-
hasListeners
public boolean hasListeners()Return true if there are any registered listeners.- Specified by:
hasListenersin interfaceEventManager
-
getListeners
Return a read-only list of listeners.- Specified by:
getListenersin interfaceEventManager
-
fireEvent
Fire the given event to all listeners.- Specified by:
fireEventin interfaceEventManager
-
fireEvent
Implement this method to fire the given event to the given listener.- Throws:
Exception
-
newListenerCollection
Return a new concurrent container for listeners. Uses aCopyOnWriteArrayListby default.
-