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 MethodgetCallbackMethod()The callback method.protected static MethodgetMethod(Class cls, String method, Class[] args)Helper method to return the named method of the given class, throwing the proper exception on error.booleanhasCallback(Object obj, int eventType)Return whether the given instance has a callback for the given event type.voidmakeCallback(Object obj, Object arg, int eventType)Invoke the callback for the given event type on the given instance.voidreadExternal(ObjectInput in)booleanrequiresArgument()Returns if this callback expects another argumentStringtoString()voidwriteExternal(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:LifecycleCallbacksReturn whether the given instance has a callback for the given event type.- Specified by:
hasCallbackin interfaceLifecycleCallbacks
-
makeCallback
public void makeCallback(Object obj, Object arg, int eventType) throws Exception
Description copied from interface:LifecycleCallbacksInvoke the callback for the given event type on the given instance.- Specified by:
makeCallbackin 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:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
-