Package org.apache.openjpa.event
Class MethodLifecycleCallbacks
- java.lang.Object
-
- org.apache.openjpa.event.MethodLifecycleCallbacks
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,LifecycleCallbacks
- Direct Known Subclasses:
BeanLifecycleCallbacks
public class MethodLifecycleCallbacks extends java.lang.Object implements LifecycleCallbacks, java.io.Externalizable
Callback adapter that invokes a callback method via reflection.- Author:
- Steve Kim
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MethodLifecycleCallbacks(java.lang.Class cls, java.lang.String method, boolean arg)
Constructor.MethodLifecycleCallbacks(java.lang.reflect.Method method, boolean arg)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.reflect.Method
getCallbackMethod()
The callback method.protected static java.lang.reflect.Method
getMethod(java.lang.Class cls, java.lang.String method, java.lang.Class[] args)
Helper method to return the named method of the given class, throwing the proper exception on error.boolean
hasCallback(java.lang.Object obj, int eventType)
Return whether the given instance has a callback for the given event type.void
makeCallback(java.lang.Object obj, java.lang.Object arg, int eventType)
Invoke the callback for the given event type on the given instance.void
readExternal(java.io.ObjectInput in)
boolean
requiresArgument()
Returns if this callback expects another argumentjava.lang.String
toString()
void
writeExternal(java.io.ObjectOutput out)
-
-
-
Constructor Detail
-
MethodLifecycleCallbacks
public MethodLifecycleCallbacks(java.lang.Class cls, java.lang.String method, boolean arg)
Constructor. Supply callback class and its callback method name.- Parameters:
arg
- Whether we expect a further argument such as in AfterDetach
-
MethodLifecycleCallbacks
public MethodLifecycleCallbacks(java.lang.reflect.Method method, boolean arg)
Constructor. Supply callback method.
-
-
Method Detail
-
getCallbackMethod
public java.lang.reflect.Method getCallbackMethod()
The callback method.
-
requiresArgument
public boolean requiresArgument()
Returns if this callback expects another argument
-
hasCallback
public boolean hasCallback(java.lang.Object obj, int eventType)
Description copied from interface:LifecycleCallbacks
Return whether the given instance has a callback for the given event type.- Specified by:
hasCallback
in interfaceLifecycleCallbacks
-
makeCallback
public void makeCallback(java.lang.Object obj, java.lang.Object arg, int eventType) throws java.lang.Exception
Description copied from interface:LifecycleCallbacks
Invoke the callback for the given event type on the given instance.- Specified by:
makeCallback
in interfaceLifecycleCallbacks
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getMethod
protected static java.lang.reflect.Method getMethod(java.lang.Class cls, java.lang.String method, java.lang.Class[] args)
Helper method to return the named method of the given class, throwing the proper exception on error.
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
-