Class 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 argument
      java.lang.String toString()  
      void writeExternal​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 interface LifecycleCallbacks
      • 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 interface LifecycleCallbacks
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 interface java.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 interface java.io.Externalizable
        Throws:
        java.io.IOException