Module org.eclipse.persistence.jpa
Class EntityListener<T>
- java.lang.Object
-
- org.eclipse.persistence.descriptors.DescriptorEventAdapter
-
- org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener<T>
-
- All Implemented Interfaces:
EventListener,DescriptorEventListener
- Direct Known Subclasses:
EntityClassListener
public class EntityListener<T> extends DescriptorEventAdapter
An EntityListener is placed on the owning entity's descriptor. Callback methods from an EntityListener require a signature on the method. Namely, they must have an Object parameter.- Since:
- Eclipselink 1.0
- Author:
- Guy Pelletier
-
-
Field Summary
Fields Modifier and Type Field Description static StringPOST_BUILDstatic StringPOST_CLONEstatic StringPOST_DELETEstatic StringPOST_INSERTstatic StringPOST_REFRESHstatic StringPOST_UPDATEstatic StringPRE_PERSISTstatic StringPRE_REMOVEstatic StringPRE_UPDATE_WITH_CHANGES
-
Constructor Summary
Constructors Modifier Constructor Description protectedEntityListener(Class<?> entityClass)INTERNAL:EntityListener(Class<T> listenerClass, Class<?> entityClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventMethod(String event, Method method)INTERNAL: You can have multiple event methods for the same event, however, only one event method per class is permitted.protected TconstructListenerInstance()Construct an instance of the wrapped entity listener This method will attempt to create the listener in a CDI injection friendly manner and if that fails, reflectively instantiate the classprotected TcreateEntityListenerAndInjectDependencies(Class<T> entityListenerClass)Create the wrapped listener and trigger CDI injection.Map<String,List<Method>>getAllEventMethods()INTERNAL:Class<?>getEntityClass()INTERNAL:protected List<Method>getEventMethods(int eventCode)INTERNAL:protected List<Method>getEventMethods(String event)INTERNAL:protected MethodgetLastEventMethod(String event)INTERNAL: Assumes a check for event methods for the given event has been called beforehand.TgetListener()Class<?>getListenerClass()INTERNAL:AbstractSessiongetOwningSession()INTERNAL:booleanhasCallbackMethods()INTERNAL:protected booleanhasEventMethods(int eventCode)INTERNAL:protected booleanhasEventMethods(String event)INTERNAL:protected booleanhasOverriddenEventMethod(Method eventMethod, int eventCode)INTERNAL:protected booleanhasOverriddenEventMethod(Method eventMethod, String eventCode)INTERNAL:protected booleanhasOverriddenEventMethod(List<Method> eventMethods, Method eventMethod)INTERNAL:booleanisOverriddenEvent(DescriptorEvent event, List<DescriptorEventManager> eventManagers)INTERNAL: Return true if listener has a lifecycle callback method that is overridden in a subclass.voidpostBuild(DescriptorEvent event)INTERNAL:voidpostClone(DescriptorEvent event)INTERNAL:voidpostDelete(DescriptorEvent event)INTERNAL:voidpostInsert(DescriptorEvent event)INTERNAL:voidpostRefresh(DescriptorEvent event)INTERNAL:voidpostUpdate(DescriptorEvent event)INTERNAL:voidprePersist(DescriptorEvent event)INTERNAL:voidpreRemove(DescriptorEvent event)INTERNAL:voidpreUpdateWithChanges(DescriptorEvent event)INTERNAL:voidsetAllEventMethods(Map<String,List<Method>> methods)INTERNAL:voidsetOwningSession(AbstractSession owningSession)INTERNAL:voidsetPostBuildMethod(Method method)INTERNAL:voidsetPostCloneMethod(Method method)INTERNAL:voidsetPostDeleteMethod(Method method)INTERNAL:voidsetPostInsertMethod(Method method)INTERNAL:voidsetPostRefreshMethod(Method method)INTERNAL:voidsetPostUpdateMethod(Method method)INTERNAL:voidsetPrePersistMethod(Method method)INTERNAL:voidsetPreRemoveMethod(Method method)INTERNAL:voidsetPreUpdateWithChangesMethod(Method method)INTERNAL:StringtoString()INTERNAL: Used in the debugger.protected voidvalidateMethod(Method method)INTERNAL:protected voidvalidateMethodModifiers(Method method)INTERNAL:-
Methods inherited from class org.eclipse.persistence.descriptors.DescriptorEventAdapter
aboutToDelete, aboutToInsert, aboutToUpdate, postMerge, postWrite, preDelete, preInsert, preUpdate, preWrite
-
-
-
-
Field Detail
-
POST_BUILD
public static final String POST_BUILD
- See Also:
- Constant Field Values
-
POST_CLONE
public static final String POST_CLONE
- See Also:
- Constant Field Values
-
POST_DELETE
public static final String POST_DELETE
- See Also:
- Constant Field Values
-
POST_INSERT
public static final String POST_INSERT
- See Also:
- Constant Field Values
-
POST_REFRESH
public static final String POST_REFRESH
- See Also:
- Constant Field Values
-
POST_UPDATE
public static final String POST_UPDATE
- See Also:
- Constant Field Values
-
PRE_PERSIST
public static final String PRE_PERSIST
- See Also:
- Constant Field Values
-
PRE_REMOVE
public static final String PRE_REMOVE
- See Also:
- Constant Field Values
-
PRE_UPDATE_WITH_CHANGES
public static final String PRE_UPDATE_WITH_CHANGES
- See Also:
- Constant Field Values
-
-
Method Detail
-
addEventMethod
public void addEventMethod(String event, Method method)
INTERNAL: You can have multiple event methods for the same event, however, only one event method per class is permitted.
-
createEntityListenerAndInjectDependencies
protected T createEntityListenerAndInjectDependencies(Class<T> entityListenerClass)
Create the wrapped listener and trigger CDI injection.- Parameters:
entityListenerClass- theEntityListenerclass- Returns:
- the class instance that has had injection run on it. If injection fails, null.
-
constructListenerInstance
protected T constructListenerInstance()
Construct an instance of the wrapped entity listener This method will attempt to create the listener in a CDI injection friendly manner and if that fails, reflectively instantiate the class- Returns:
- the entity listener instance
-
getEntityClass
public Class<?> getEntityClass()
INTERNAL:
-
setOwningSession
public void setOwningSession(AbstractSession owningSession)
INTERNAL:
-
getLastEventMethod
protected Method getLastEventMethod(String event)
INTERNAL: Assumes a check for event methods for the given event has been called beforehand.
-
getListener
public T getListener()
-
getListenerClass
public Class<?> getListenerClass()
INTERNAL:
-
getOwningSession
public AbstractSession getOwningSession()
INTERNAL:
-
hasCallbackMethods
public boolean hasCallbackMethods()
INTERNAL:
-
hasEventMethods
protected boolean hasEventMethods(int eventCode)
INTERNAL:
-
hasEventMethods
protected boolean hasEventMethods(String event)
INTERNAL:
-
hasOverriddenEventMethod
protected boolean hasOverriddenEventMethod(List<Method> eventMethods, Method eventMethod)
INTERNAL:
-
hasOverriddenEventMethod
protected boolean hasOverriddenEventMethod(Method eventMethod, int eventCode)
INTERNAL:
-
hasOverriddenEventMethod
protected boolean hasOverriddenEventMethod(Method eventMethod, String eventCode)
INTERNAL:
-
isOverriddenEvent
public boolean isOverriddenEvent(DescriptorEvent event, List<DescriptorEventManager> eventManagers)
INTERNAL: Return true if listener has a lifecycle callback method that is overridden in a subclass.- Specified by:
isOverriddenEventin interfaceDescriptorEventListener- Overrides:
isOverriddenEventin classDescriptorEventAdapter
-
postBuild
public void postBuild(DescriptorEvent event)
INTERNAL:- Specified by:
postBuildin interfaceDescriptorEventListener- Overrides:
postBuildin classDescriptorEventAdapter
-
postClone
public void postClone(DescriptorEvent event)
INTERNAL:- Specified by:
postClonein interfaceDescriptorEventListener- Overrides:
postClonein classDescriptorEventAdapter
-
postDelete
public void postDelete(DescriptorEvent event)
INTERNAL:- Specified by:
postDeletein interfaceDescriptorEventListener- Overrides:
postDeletein classDescriptorEventAdapter
-
postInsert
public void postInsert(DescriptorEvent event)
INTERNAL:- Specified by:
postInsertin interfaceDescriptorEventListener- Overrides:
postInsertin classDescriptorEventAdapter
-
postRefresh
public void postRefresh(DescriptorEvent event)
INTERNAL:- Specified by:
postRefreshin interfaceDescriptorEventListener- Overrides:
postRefreshin classDescriptorEventAdapter
-
postUpdate
public void postUpdate(DescriptorEvent event)
INTERNAL:- Specified by:
postUpdatein interfaceDescriptorEventListener- Overrides:
postUpdatein classDescriptorEventAdapter
-
prePersist
public void prePersist(DescriptorEvent event)
INTERNAL:- Specified by:
prePersistin interfaceDescriptorEventListener- Overrides:
prePersistin classDescriptorEventAdapter
-
preRemove
public void preRemove(DescriptorEvent event)
INTERNAL:- Specified by:
preRemovein interfaceDescriptorEventListener- Overrides:
preRemovein classDescriptorEventAdapter
-
preUpdateWithChanges
public void preUpdateWithChanges(DescriptorEvent event)
INTERNAL:- Specified by:
preUpdateWithChangesin interfaceDescriptorEventListener- Overrides:
preUpdateWithChangesin classDescriptorEventAdapter
-
setPostBuildMethod
public void setPostBuildMethod(Method method)
INTERNAL:
-
setPostCloneMethod
public void setPostCloneMethod(Method method)
INTERNAL:
-
setPostDeleteMethod
public void setPostDeleteMethod(Method method)
INTERNAL:
-
setPostInsertMethod
public void setPostInsertMethod(Method method)
INTERNAL:
-
setPostRefreshMethod
public void setPostRefreshMethod(Method method)
INTERNAL:
-
setPostUpdateMethod
public void setPostUpdateMethod(Method method)
INTERNAL:
-
setPrePersistMethod
public void setPrePersistMethod(Method method)
INTERNAL:
-
setPreRemoveMethod
public void setPreRemoveMethod(Method method)
INTERNAL:
-
setPreUpdateWithChangesMethod
public void setPreUpdateWithChangesMethod(Method method)
INTERNAL:
-
toString
public String toString()
INTERNAL: Used in the debugger.
-
validateMethod
protected void validateMethod(Method method)
INTERNAL:
-
validateMethodModifiers
protected void validateMethodModifiers(Method method)
INTERNAL:
-
-