Class DescriptorEventManager
java.lang.Object
org.eclipse.persistence.core.descriptors.CoreDescriptorEventManager<DescriptorEvent>
org.eclipse.persistence.descriptors.DescriptorEventManager
- All Implemented Interfaces:
Serializable,Cloneable
public class DescriptorEventManager
extends CoreDescriptorEventManager<DescriptorEvent>
implements Cloneable, Serializable
Purpose: The event manager allows for a descriptor to specify that an object should be notified when a EclipseLink event occurs. It also determines how the object will be notified. To specify an event a method name can be registered to be called on the object when the event occurs. Events can be used to extend the EclipseLink reading and writing behavior.
These events include:
- pre/postWrite - occurs when an object is written (occurs even if no changes to the object).
- pre/postInsert - occurs when an object is inserted.
- pre/postUpdate - occurs when an object is updated (occurs even if no changes to the object).
- pre/postDeleted - occurs when an object is deleted.
- postBuild/postRefresh - occurs after a object has been built/refreshed from its database row.
- aboutTo/Insert/Update - occurs when an object is about to be inserted/update allows for row modification.
- postClone - occurs when an object is registered/cloned in a unit of work.
- postMerge - occurs when an object is merged with its original in a unit of work.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intprotected List<DescriptorEventListener>protected ClassDescriptorprotected List<SerializableDescriptorEventHolder>protected DescriptorEventListenerprotected List<DescriptorEventManager>protected List<DescriptorEventListener>protected List<DescriptorEventManager>protected List<DescriptorEventListener>protected AtomicReferenceArray<Method>protected AtomicReferenceArray<String>protected booleanprotected booleanprotected booleanPERF: Cache if any events listener exist.protected List<DescriptorEventListener>Listeners that are fired after all other listeners are firedprotected static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionINTERNAL: Returns a new DescriptorEventManager for the specified ClassDescriptor. -
Method Summary
Modifier and TypeMethodDescriptionvoidPUBLIC: EJB 3.0 support for default listeners.voidPUBLIC: EJB 3.0 support for lifecycle callback events defined on an entity listener class.voidINTERNAL:voidaddInternalListener(DescriptorEventListener listener) INTERNAL:voidaddListener(DescriptorEventListener listener) PUBLIC: Listener objects can be registered with the event manager to be notified when an event occurs on any instance of the descriptor's class.clone()INTERNAL: Clone the manager and its private parts.booleanINTERNAL: EJB 3.0 support.booleanINTERNAL: EJB 3.0 support.voidexecuteEvent(DescriptorEvent event) INTERNAL: Execute the given selector with the event as argument.protected MethodfindMethod(int selector) Find the method corresponding to the event selector.INTERNAL: bug 251180 - Missing method org.eclipse.persistence.descriptors.DescriptorEventManager#setAboutToDeleteSelectorINTERNAL:INTERNAL:INTERNAL: EJB 3.0 support.protected ClassDescriptorINTERNAL:INTERNAL: used by JPA project caching to store DescriptorEventListener representations that can build the underlying DescriptorEventListener and add it to the EventManager.INTERNAL: EJB 3.0 support.INTERNAL: EJB 3.0 support.PUBLIC: Returns the Listener objects that have been added.protected AtomicReferenceArray<Method>protected AtomicReferenceArray<String>PUBLIC: The name of the method called after an object is builtPUBLIC: The name of the method called after an object is clonedPUBLIC: The name of the method called after an object is deletedPUBLIC: The name of the method called after an object is insertedPUBLIC: The name of the method called after an object is mergedPUBLIC: The name of the method called after an object is refreshedPUBLIC: The name of the method called after an object is updatedPUBLIC: The name of the method called after an object is writtenPUBLIC: The name of the method called before an object is deletedPUBLIC: The name of the method called before an object is insertedPUBLIC: The name of the method called before the create operation is applied to an objectPUBLIC: The name of the method called before the remove operation is applied to an objectPUBLIC: The name of the method called before an object is updatedPUBLIC: The name of the method called before an object is writtenbooleanINTERNAL: Return if the event manager has any event listeners, or event methods.protected booleanbooleanINTERNAL: This method will return true, if this event manager has default listeners and does not exclude them.booleanINTERNAL: EJB 3.0 support.booleanINTERNAL: EJB 3.0 support.booleanINTERNAL: Internal event support.voidinitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Configure inherited selectors.protected voidINTERNAL: EJB 3.0 support.protected voidINTERNAL: Notify the EJB 3.0 event listeners.protected voidnotifyListener(DescriptorEventListener listener, DescriptorEvent event) INTERNAL: Big ugly case statement to notify listeners.voidnotifyListeners(DescriptorEvent event) INTERNAL: Notify the event listeners.voidprocessDescriptorEventHolders(org.eclipse.persistence.internal.sessions.AbstractSession session, ClassLoader classLoader) INTERNAL: This method was added to allow JPA project caching so that DescriptorEventListeners could be serialized and re-added to the EventManager using a SerializableDescriptorEventHolder.voidremoteInitialization(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Used to initialize a remote DescriptorEventManager.voidremoveListener(DescriptorEventListener listener) PUBLIC: Remove a event listener.voidsetAboutToDeleteSelector(String aboutToDeleteSelector) PUBLIC: A method can be registered to be called when an object's row it about to be inserted.voidsetAboutToInsertSelector(String aboutToInsertSelector) PUBLIC: A method can be registered to be called when an object's row it about to be inserted.voidsetAboutToUpdateSelector(String aboutToUpdateSelector) PUBLIC: A method can be registered to be called when an object's row it about to be updated.voidsetDescriptor(ClassDescriptor descriptor) INTERNAL: Set the descriptor.voidsetDescriptorEventHolders(List<SerializableDescriptorEventHolder> descriptorEventHolders) INTERNAL: used by JPA project caching to store DescriptorEventListener representations that can build the underlying DescriptorEventListener and add it to the EventManager.voidPUBLIC: EJB 3.0 support for lifecycle callback events defined on an entity class.protected voidsetEventListeners(List<DescriptorEventListener> eventListeners) protected voidsetEventMethods(AtomicReferenceArray<Method> eventMethods) protected voidsetEventSelectors(AtomicReferenceArray<String> eventSelectors) voidsetExcludeDefaultListeners(boolean excludeDefaultListeners) INTERNAL: EJB 3.0 support.voidsetExcludeSuperclassListeners(boolean excludeSuperclassListeners) INTERNAL: EJB 3.0 support.protected voidsetHasAnyEventListeners(boolean hasAnyEventListeners) INTERNAL: Set if the event manager has any event listeners, or event methods.voidsetPostBuildSelector(String postBuildSelector) PUBLIC: A method can be registered to be called on a object that has just been built from the database.voidsetPostCloneSelector(String postCloneSelector) PUBLIC: A method can be registered to be called on a object that has just been cloned into a unit of work.voidsetPostDeleteSelector(String postDeleteSelector) PUBLIC: A method can be registered to be called on a object that has just been deleted from the database.voidsetPostInsertSelector(String postInsertSelector) PUBLIC: A method can be registered to be called on a object that has just been inserted into the database.voidsetPostMergeSelector(String postMergeSelector) PUBLIC: A method can be registered to be called on a object that has just been merge from a unit of work.voidsetPostRefreshSelector(String postRefreshSelector) PUBLIC: A method can be registered to be called on a object that has just been refreshed from the database.voidsetPostUpdateSelector(String postUpdateSelector) PUBLIC: A method can be registered to be called on a object that has just been updated into the database.voidsetPostWriteSelector(String postWriteSelector) PUBLIC: A method can be registered to be called on a object that has just been written to the database.voidsetPreDeleteSelector(String preDeleteSelector) PUBLIC: A method can be registered to be called on a object that is going to be deleted from the database.voidsetPreInsertSelector(String preInsertSelector) PUBLIC: A method can be registered to be called on a object that is going to be inserted into the database.voidsetPrePersistSelector(String prePersistSelector) PUBLIC: A method can be registered to be called on a object when that object has the create operation applied to it.voidsetPreRemoveSelector(String preRemoveSelector) PUBLIC: A method can be registered to be called on a object when that object has the remove operation applied to it.voidsetPreUpdateSelector(String preUpdateSelector) PUBLIC: A method can be registered to be called on a object that is going to be updated into the database.voidsetPreWriteSelector(String preWriteSelector) PUBLIC: A method can be registered to be called on a object that is going to be written to the database.
-
Field Details
-
descriptor
-
eventSelectors
-
eventMethods
-
eventListeners
-
defaultEventListeners
-
entityListenerEventListeners
-
entityEventListener
-
internalListeners
Listeners that are fired after all other listeners are fired -
entityEventManagers
-
entityListenerEventManagers
-
excludeDefaultListeners
protected boolean excludeDefaultListeners -
excludeSuperclassListeners
protected boolean excludeSuperclassListeners -
descriptorEventHolders
-
hasAnyEventListeners
protected boolean hasAnyEventListenersPERF: Cache if any events listener exist. -
PreWriteEvent
public static final int PreWriteEvent- See Also:
-
PostWriteEvent
public static final int PostWriteEvent- See Also:
-
PreDeleteEvent
public static final int PreDeleteEvent- See Also:
-
PostDeleteEvent
public static final int PostDeleteEvent- See Also:
-
PreInsertEvent
public static final int PreInsertEvent- See Also:
-
PostInsertEvent
public static final int PostInsertEvent- See Also:
-
PreUpdateEvent
public static final int PreUpdateEvent- See Also:
-
PostUpdateEvent
public static final int PostUpdateEvent- See Also:
-
PostBuildEvent
public static final int PostBuildEvent- See Also:
-
PostRefreshEvent
public static final int PostRefreshEvent- See Also:
-
PostCloneEvent
public static final int PostCloneEvent- See Also:
-
PostMergeEvent
public static final int PostMergeEvent- See Also:
-
AboutToInsertEvent
public static final int AboutToInsertEvent- See Also:
-
AboutToUpdateEvent
public static final int AboutToUpdateEvent- See Also:
-
AboutToDeleteEvent
public static final int AboutToDeleteEvent- See Also:
-
PrePersistEvent
public static final int PrePersistEvent- See Also:
-
PreRemoveEvent
public static final int PreRemoveEvent- See Also:
-
PreUpdateWithChangesEvent
public static final int PreUpdateWithChangesEvent- See Also:
-
NumberOfEvents
protected static final int NumberOfEvents- See Also:
-
-
Constructor Details
-
DescriptorEventManager
public DescriptorEventManager()INTERNAL: Returns a new DescriptorEventManager for the specified ClassDescriptor.
-
-
Method Details
-
addDefaultEventListener
PUBLIC: EJB 3.0 support for default listeners. -
addEntityListenerEventListener
PUBLIC: EJB 3.0 support for lifecycle callback events defined on an entity listener class. -
addListener
PUBLIC: Listener objects can be registered with the event manager to be notified when an event occurs on any instance of the descriptor's class. -
addInternalListener
INTERNAL: -
addEntityListenerHolder
INTERNAL: -
clone
INTERNAL: Clone the manager and its private parts. -
processDescriptorEventHolders
public void processDescriptorEventHolders(org.eclipse.persistence.internal.sessions.AbstractSession session, ClassLoader classLoader) INTERNAL: This method was added to allow JPA project caching so that DescriptorEventListeners could be serialized and re-added to the EventManager using a SerializableDescriptorEventHolder.- Parameters:
classLoader-
-
excludeDefaultListeners
public boolean excludeDefaultListeners()INTERNAL: EJB 3.0 support. Returns true if this event manager should exclude the invocation of the default listeners for this descriptor. -
excludeSuperclassListeners
public boolean excludeSuperclassListeners()INTERNAL: EJB 3.0 support. Returns true is this event manager should exclude the invocation of the listeners defined by the entity listener classes for the superclasses of this descriptor. -
executeEvent
INTERNAL: Execute the given selector with the event as argument.- Specified by:
executeEventin classCoreDescriptorEventManager<DescriptorEvent>- Throws:
DescriptorException- - the method cannot be found or executed
-
findMethod
Find the method corresponding to the event selector. The method MUST take DescriptorEvent as argument, Session is also supported as argument for backward compatibility.- Throws:
DescriptorException
-
getAboutToDeleteSelector
INTERNAL: bug 251180 - Missing method org.eclipse.persistence.descriptors.DescriptorEventManager#setAboutToDeleteSelector -
getAboutToInsertSelector
INTERNAL: -
getAboutToUpdateSelector
INTERNAL: -
getDefaultEventListeners
INTERNAL: EJB 3.0 support. Returns the default listeners. -
getDescriptor
INTERNAL: -
getDescriptorEventHolders
INTERNAL: used by JPA project caching to store DescriptorEventListener representations that can build the underlying DescriptorEventListener and add it to the EventManager. -
setDescriptorEventHolders
public void setDescriptorEventHolders(List<SerializableDescriptorEventHolder> descriptorEventHolders) INTERNAL: used by JPA project caching to store DescriptorEventListener representations that can build the underlying DescriptorEventListener and add it to the EventManager. -
getEntityEventListener
INTERNAL: EJB 3.0 support. Returns the entity event listener. -
getEntityListenerEventListeners
INTERNAL: EJB 3.0 support. Returns the entity listener event listeners. -
getEventListeners
PUBLIC: Returns the Listener objects that have been added.- See Also:
-
getEventMethods
-
getEventSelectors
-
getPostBuildSelector
PUBLIC: The name of the method called after an object is built -
getPostCloneSelector
PUBLIC: The name of the method called after an object is cloned -
getPostDeleteSelector
PUBLIC: The name of the method called after an object is deleted -
getPostInsertSelector
PUBLIC: The name of the method called after an object is inserted -
getPostMergeSelector
PUBLIC: The name of the method called after an object is merged -
getPostRefreshSelector
PUBLIC: The name of the method called after an object is refreshed -
getPostUpdateSelector
PUBLIC: The name of the method called after an object is updated -
getPostWriteSelector
PUBLIC: The name of the method called after an object is written -
getPrePersistSelector
PUBLIC: The name of the method called before the create operation is applied to an object -
getPreDeleteSelector
PUBLIC: The name of the method called before an object is deleted -
getPreInsertSelector
PUBLIC: The name of the method called before an object is inserted -
getPreRemoveSelector
PUBLIC: The name of the method called before the remove operation is applied to an object -
getPreUpdateSelector
PUBLIC: The name of the method called before an object is updated -
getPreWriteSelector
PUBLIC: The name of the method called before an object is written -
hasAnyEventListeners
public boolean hasAnyEventListeners()INTERNAL: Return if the event manager has any event listeners, or event methods. If nothing is listening to event they can be avoided.- Specified by:
hasAnyEventListenersin classCoreDescriptorEventManager<DescriptorEvent>
-
hasAnyListeners
protected boolean hasAnyListeners() -
hasDefaultEventListeners
public boolean hasDefaultEventListeners()INTERNAL: This method will return true, if this event manager has default listeners and does not exclude them. Default listeners are always added to every event manager to allow users to turn them on a later time if so desired. -
hasEntityEventListener
public boolean hasEntityEventListener()INTERNAL: EJB 3.0 support. Return true if this event manager has any entity event listeners. -
hasInternalEventListeners
public boolean hasInternalEventListeners()INTERNAL: Internal event support. Return true if this event manager has any internal listener event listeners. -
hasEntityListenerEventListeners
public boolean hasEntityListenerEventListeners()INTERNAL: EJB 3.0 support. Return true if this event manager has any entity listener event listeners. -
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Configure inherited selectors. -
initializeEJB30EventManagers
protected void initializeEJB30EventManagers()INTERNAL: EJB 3.0 support. Builds our chains of descriptor event managers that will need to be notified. The chains are cache so we only need to build them once. -
notifyEJB30Listeners
INTERNAL: Notify the EJB 3.0 event listeners. -
notifyListener
protected void notifyListener(DescriptorEventListener listener, DescriptorEvent event) throws DescriptorException INTERNAL: Big ugly case statement to notify listeners.- Throws:
DescriptorException
-
notifyListeners
INTERNAL: Notify the event listeners. -
remoteInitialization
public void remoteInitialization(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Used to initialize a remote DescriptorEventManager. -
removeListener
PUBLIC: Remove a event listener. -
setAboutToDeleteSelector
PUBLIC: A method can be registered to be called when an object's row it about to be inserted. This uses the optional event argument of the DatabaseRow. This is different from pre/postInsert because it occurs after the row has already been built. This event can be used to modify the row before insert, such as adding a user inserted by. -
setAboutToInsertSelector
PUBLIC: A method can be registered to be called when an object's row it about to be inserted. This uses the optional event argument of the DatabaseRow. This is different from pre/postInsert because it occurs after the row has already been built. This event can be used to modify the row before insert, such as adding a user inserted by. -
setAboutToUpdateSelector
PUBLIC: A method can be registered to be called when an object's row it about to be updated. This uses the optional event argument of the DatabaseRow. This is different from pre/postUpdate because it occurs after the row has already been built, and it ONLY called if the update is required (changed within a unit of work), as the other occur ALWAYS. This event can be used to modify the row before insert, such as adding a user inserted by. -
setDescriptor
INTERNAL: Set the descriptor. -
setEntityEventListener
PUBLIC: EJB 3.0 support for lifecycle callback events defined on an entity class. -
setEventListeners
-
setEventMethods
-
setEventSelectors
-
setExcludeDefaultListeners
public void setExcludeDefaultListeners(boolean excludeDefaultListeners) INTERNAL: EJB 3.0 support. Default listeners apply to all entities in a persistence unit. Set this flag to true to exclude the invocation of the default listeners for this descriptor. -
setExcludeSuperclassListeners
public void setExcludeSuperclassListeners(boolean excludeSuperclassListeners) INTERNAL: EJB 3.0 support. If multiple entity classes in an inheritance hierarchy define entity listeners, the listeners defined for a superclass are invoked before the listeners defined for its subclasses. Set this flag to true to exclude the invocation of the listeners defined by the entity listener classes for the superclasses of this descriptor. -
setHasAnyEventListeners
protected void setHasAnyEventListeners(boolean hasAnyEventListeners) INTERNAL: Set if the event manager has any event listeners, or event methods. If nothing is listening to event they can be avoided. -
setPostBuildSelector
PUBLIC: A method can be registered to be called on a object that has just been built from the database. This uses the optional event argument for the DatabaseRow. This event can be used to correctly initialize an object's non-persistent attributes or to perform complex optimizations or mappings. This event is called whenever an object is built. -
setPostCloneSelector
PUBLIC: A method can be registered to be called on a object that has just been cloned into a unit of work. This uses the optional event argument for the original object (the source object is the clone). This event can be used to correctly initialize an object's non-persistent attributes. -
setPostDeleteSelector
PUBLIC: A method can be registered to be called on a object that has just been deleted from the database. This event can notify/remove any dependents on the object. -
setPostInsertSelector
PUBLIC: A method can be registered to be called on a object that has just been inserted into the database. This event can be used to notify any dependent on the object, or to update information not accessible until the object has been inserted. -
setPostMergeSelector
PUBLIC: A method can be registered to be called on a object that has just been merge from a unit of work. This uses the optional event argument of the original object which is the object being merged from, the source object is the object being merged into. This event can be used to correctly initialize an object's non-persistent attributes. -
setPostRefreshSelector
PUBLIC: A method can be registered to be called on a object that has just been refreshed from the database. This uses the optional event argument of the DatabaseRow. This event can be used to correctly initialize an object's non-persistent attributes or to perform complex optimizations or mappings. This event is only called on refreshes of existing objects. -
setPostUpdateSelector
PUBLIC: A method can be registered to be called on a object that has just been updated into the database. -
setPostWriteSelector
PUBLIC: A method can be registered to be called on a object that has just been written to the database. This event is raised on any registered object in a unit of work, even if it has not changed, refer to the "aboutToUpdate" selector if it is required for the event to be raised only when the object has been changed. This will be called on all inserts and updates, after the "postInsert/Update" event has been raised. This event can be used to notify any dependent on the object. -
setPreDeleteSelector
PUBLIC: A method can be registered to be called on a object that is going to be deleted from the database. This event can notify/remove any dependents on the object. -
setPreInsertSelector
PUBLIC: A method can be registered to be called on a object that is going to be inserted into the database. This event can be used to notify any dependent on the object or acquire the object's id through a custom mechanism. -
setPrePersistSelector
PUBLIC: A method can be registered to be called on a object when that object has the create operation applied to it. -
setPreRemoveSelector
PUBLIC: A method can be registered to be called on a object when that object has the remove operation applied to it. -
setPreUpdateSelector
PUBLIC: A method can be registered to be called on a object that is going to be updated into the database. This event is raised on any registered object in a unit of work, even if it has not changed, refer to the "aboutToUpdate" selector if it is required for the event to be raised only when the object has been changed. This event can be used to notify any dependent on the object. -
setPreWriteSelector
PUBLIC: A method can be registered to be called on a object that is going to be written to the database. This event is raised on any registered object in a unit of work, even if it has not changed, refer to the "aboutToUpdate" selector if it is required for the event to be raised only when the object has been changed. This will be called on all inserts and updates, before the "preInsert/Update" event has been raised. This event can be used to notify any dependent on the object.
-