Package org.apache.openjpa.event
Class LifecycleEventManager
java.lang.Object
org.apache.openjpa.event.LifecycleEventManager
- All Implemented Interfaces:
Serializable
,CallbackModes
- Direct Known Subclasses:
ValidatingLifecycleEventManager
Manager that can be used to track and notify listeners on lifecycle events.
This class is optimized for event firing rather than for adding and
removing listeners, which are O(n) operations. This class also does not
maintain perfect set semantics for listeners; it is possible to wind up
having the same listener invoked multiple times for a single event if it
is added to this manager multiple times with different classes, or with
a base class and its subclass.
- Since:
- 0.3.3
- Author:
- Steve Kim, Abe White
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface that facades to other lifecycle listener interfaces can implement to choose which events to respond to based on their delegate.static class
Extended list that tracks what event types its elements care about. -
Field Summary
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(Object listener, Class<?>[] classes) Register a lifecycle listener for the given classes.fireEvent
(Object source, Object related, ClassMetaData meta, int type) Fire lifecycle event to all registered listeners.fireEvent
(Object source, ClassMetaData meta, int type) Fire lifecycle event to all registered listeners without an argument.boolean
hasAttachListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasClearListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasDeleteListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasDetachListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasDirtyListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasLoadListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasPersistListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasStoreListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
hasUpdateListeners
(Object source, ClassMetaData meta) Return whether there are listeners or callbacks for the given source.boolean
isActive
(ClassMetaData meta) Whether this LifeCycleEventManager has had at least one listener or callback registered.boolean
Whether to fail after first exception when firing events to listeners.void
removeListener
(Object listener) Remove the given listener.void
setFailFast
(boolean failFast) Whether to fail after first exception when firing events to listeners.
-
Constructor Details
-
LifecycleEventManager
public LifecycleEventManager()
-
-
Method Details
-
isActive
Whether this LifeCycleEventManager has had at least one listener or callback registered. Used for a quick test when firing events.- Returns:
- boolean
-
isFailFast
public boolean isFailFast()Whether to fail after first exception when firing events to listeners. -
setFailFast
public void setFailFast(boolean failFast) Whether to fail after first exception when firing events to listeners. -
addListener
Register a lifecycle listener for the given classes. If the classes array is null, register for all classes. -
removeListener
Remove the given listener. -
hasPersistListeners
Return whether there are listeners or callbacks for the given source. -
hasDeleteListeners
Return whether there are listeners or callbacks for the given source. -
hasClearListeners
Return whether there are listeners or callbacks for the given source. -
hasLoadListeners
Return whether there are listeners or callbacks for the given source. -
hasStoreListeners
Return whether there are listeners or callbacks for the given source. -
hasUpdateListeners
Return whether there are listeners or callbacks for the given source. -
hasDirtyListeners
Return whether there are listeners or callbacks for the given source. -
hasDetachListeners
Return whether there are listeners or callbacks for the given source. -
hasAttachListeners
Return whether there are listeners or callbacks for the given source. -
fireEvent
Fire lifecycle event to all registered listeners without an argument. -
fireEvent
Fire lifecycle event to all registered listeners.
-