Methods Summary |
---|
public void | addEventMethod(java.lang.String event, java.lang.reflect.Method method)INTERNAL:
validateMethod(method);
if (m_methods.containsKey(event)) {
throw ValidationException.multipleLifecycleCallbackMethodsForSameLifecycleEvent(getListenerClass(), method, getEventMethod(event));
} else {
m_methods.put(event, method);
}
|
public java.lang.Class | getEntityClass()INTERNAL:
return m_entityClass;
|
protected java.lang.reflect.Method | getEventMethod(int eventCode)INTERNAL:
String eventString = m_eventStrings.get(eventCode);
if (eventString != null) {
return getEventMethod(eventString);
} else {
return null;
}
|
protected java.lang.reflect.Method | getEventMethod(java.lang.String event)INTERNAL:
return m_methods.get(event);
|
protected java.lang.String | getEventMethodName(java.lang.String eventName)INTERNAL:
Method method = getEventMethod(eventName);
if (method != null) {
return method.getName();
} else {
return null;
}
|
public java.lang.Class | getListenerClass()INTERNAL:
return m_listener.getClass();
|
public java.util.Hashtable | getMethods()INTERNAL:
return m_methods;
|
public java.lang.String | getPostBuildMethodName()INTERNAL:
return getEventMethodName(POST_BUILD);
|
public java.lang.String | getPostCloneMethodName()INTERNAL:
return getEventMethodName(POST_CLONE);
|
public java.lang.String | getPostDeleteMethodName()INTERNAL:
return getEventMethodName(POST_DELETE);
|
public java.lang.String | getPostInsertMethodName()INTERNAL:
return getEventMethodName(POST_INSERT);
|
public java.lang.String | getPostRefreshMethodName()INTERNAL:
return getEventMethodName(POST_REFRESH);
|
public java.lang.String | getPostUpdateMethodName()INTERNAL:
return getEventMethodName(POST_UPDATE);
|
public java.lang.String | getPrePersistMethodName()INTERNAL:
return getEventMethodName(PRE_PERSIST);
|
public java.lang.String | getPreRemoveMethodName()INTERNAL:
return getEventMethodName(PRE_REMOVE);
|
public java.lang.String | getPreUpdateWithChangesMethodName()INTERNAL:
return getEventMethodName(PRE_UPDATE_WITH_CHANGES);
|
public boolean | hasCallbackMethods()INTERNAL:
return m_methods.size() > 0;
|
public boolean | hasOverriddenEventMethod(java.lang.reflect.Method eventMethod, int eventCode)INTERNAL:
return hasOverriddenEventMethod(getEventMethod(eventCode), eventMethod);
|
protected boolean | hasOverriddenEventMethod(java.lang.reflect.Method eventMethod1, java.lang.reflect.Method eventMethod2)INTERNAL:
return (eventMethod1 != null && eventMethod1.getName().equals(eventMethod2.getName()));
|
public boolean | hasOverriddenEventMethod(java.lang.reflect.Method eventMethod, java.lang.String eventCode)INTERNAL:
return hasOverriddenEventMethod(getEventMethod(eventCode), eventMethod);
|
public void | initializeCallbackMethods(java.lang.ClassLoader classLoader)INTERNAL:
Sub-classes should implement where necessary.
|
protected void | invokeMethod(java.lang.reflect.Method method, java.lang.Object onObject, java.lang.Object[] objectList, oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
//if (method != null && ! isSessionPostBuildEvent(event)) {
if (method != null) {
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
AccessController.doPrivileged(new PrivilegedMethodInvoker(method, onObject, objectList));
} catch (PrivilegedActionException exception) {
Exception throwableException = exception.getException();
if (throwableException instanceof IllegalAccessException) {
throw ValidationException.invalidCallbackMethod(onObject.getClass(), method.toString());
} else {
Throwable cause = throwableException.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else {
throw (Error) cause;
} }
}
} else {
PrivilegedAccessHelper.invokeMethod(method, onObject, objectList);
}
} catch (IllegalAccessException exception) {
// WIP throw a better exception string.
throw ValidationException.invalidCallbackMethod(onObject.getClass(), method.toString());
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else {
throw (Error) cause;
}
}
}
|
protected void | invokeMethod(java.lang.String event, oracle.toplink.essentials.descriptors.DescriptorEvent descriptorEvent)INTERNAL:
Object[] objectList = { descriptorEvent.getSource() };
invokeMethod(getEventMethod(event), m_listener, objectList, descriptorEvent);
|
public boolean | isEntityClassListener()INTERNAL:
return false;
|
public boolean | isOverriddenEvent(oracle.toplink.essentials.descriptors.DescriptorEvent event, java.util.Vector eventManagers)INTERNAL:
Return true is listener has a lifecycle callback method that is
overridden in a subclass.
int eventCode = event.getEventCode();
if (! m_overriddenEvents.containsKey(eventCode)) {
m_overriddenEvents.put(eventCode, false); // default
Method eventMethod = getEventMethod(eventCode);
if (eventMethod != null) {
for (DescriptorEventManager eventManager : (Vector<DescriptorEventManager>) eventManagers) {
MetadataEntityListener childListener = (MetadataEntityListener) eventManager.getEntityEventListener();
// We can't override ourself ...
if (childListener == this) {
break;
} else {
if (childListener.hasOverriddenEventMethod(eventMethod, eventCode)) {
m_overriddenEvents.put(eventCode, true);
break; // stop looking
}
}
}
}
}
return m_overriddenEvents.get(eventCode);
|
protected boolean | isSessionPostBuildEvent(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
if (((String) m_eventStrings.get(event.getEventCode())).equals(POST_BUILD)) {
return ! event.getSession().isUnitOfWork();
}
return false;
|
protected boolean | noCallbackMethodAlreadySetFor(java.lang.String event, java.lang.reflect.Method method)INTERNAL:
Checks if the user already set this call back method via XML. We
need to check because the set methods on the superclass will throw
an exception when multiple methods are added for the callback.
Method cbMethod = (Method) getMethods().get(event);
if (cbMethod == null) {
return true;
} else {
return ! cbMethod.getName().equals(method.getName());
}
|
public void | postBuild(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_BUILD, event);
|
public void | postClone(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_CLONE, event);
|
public void | postDelete(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_DELETE, event);
|
public void | postInsert(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_INSERT, event);
|
public void | postRefresh(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_REFRESH, event);
|
public void | postUpdate(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(POST_UPDATE, event);
|
public void | prePersist(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(PRE_PERSIST, event);
|
public void | preRemove(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(PRE_REMOVE, event);
|
public void | preUpdateWithChanges(oracle.toplink.essentials.descriptors.DescriptorEvent event)INTERNAL:
invokeMethod(PRE_UPDATE_WITH_CHANGES, event);
|
public void | setEntityClass(java.lang.Class entityClass)INTERNAL:
m_entityClass = entityClass;
|
public void | setListener(java.lang.Object listener)INTERNAL:
m_listener = listener;
|
public void | setPostBuildMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_BUILD, method);
|
public void | setPostCloneMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_CLONE, method);
|
public void | setPostDeleteMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_DELETE, method);
|
public void | setPostInsertMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_INSERT, method);
|
public void | setPostRefreshMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_REFRESH, method);
|
public void | setPostUpdateMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(POST_UPDATE, method);
|
public void | setPrePersistMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(PRE_PERSIST, method);
|
public void | setPreRemoveMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(PRE_REMOVE, method);
|
public void | setPreUpdateWithChangesMethod(java.lang.reflect.Method method)INTERNAL:
addEventMethod(PRE_UPDATE_WITH_CHANGES, method);
|
protected void | validateMethod(java.lang.reflect.Method method)INTERNAL:
int numberOfParameters = method.getParameterTypes().length;
if (numberOfParameters == 1 && method.getParameterTypes()[0].isAssignableFrom(m_entityClass)) {
// So far so good, now check the method modifiers.
validateMethodModifiers(method);
} else {
Class parameterClass = (numberOfParameters == 0) ? null : method.getParameterTypes()[0];
throw ValidationException.invalidEntityListenerCallbackMethodArguments(m_entityClass, parameterClass, m_listener.getClass(), method.getName());
}
|
protected void | validateMethodModifiers(java.lang.reflect.Method method)INTERNAL:
int modifiers = method.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers)) {
throw ValidationException.invalidCallbackMethodModifier(getListenerClass(), method.getName());
}
|