org.apache.openjpa.event
Class MethodLifecycleCallbacks

java.lang.Object
  extended by org.apache.openjpa.event.MethodLifecycleCallbacks
All Implemented Interfaces:
LifecycleCallbacks
Direct Known Subclasses:
BeanLifecycleCallbacks

public class MethodLifecycleCallbacks
extends Object
implements LifecycleCallbacks

Callback adapter that invokes a callback method via reflection.

Author:
Steve Kim

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.
 boolean requiresArgument()
          Returns if this callback expects another argument
 String toString()
           
 
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.



Copyright © 2006 Apache Software Foundation. All Rights Reserved.