org.apache.openjpa.event
Class MethodLifecycleCallbacks

java.lang.Object
  extended by 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
MethodLifecycleCallbacks(Class cls, String method, boolean arg)
          Constructor.
MethodLifecycleCallbacks(Method method, boolean arg)
          Constructor.
 
Method Summary
 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 argument
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodLifecycleCallbacks

public MethodLifecycleCallbacks(Class cls,
                                String method,
                                boolean arg)
Constructor. Supply callback class and its callback method name.


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 interface LifecycleCallbacks

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 interface LifecycleCallbacks
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object

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 interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.