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