Module lettuce.core

Class AbstractInvocationHandler

java.lang.Object
io.lettuce.core.internal.AbstractInvocationHandler
All Implemented Interfaces:
InvocationHandler

public abstract class AbstractInvocationHandler
extends Object
implements InvocationHandler
Abstract base class for invocation handlers.
Since:
4.2
  • Constructor Details

    • AbstractInvocationHandler

      public AbstractInvocationHandler()
  • Method Details

    • invoke

      public final Object invoke​(Object proxy, Method method, Object[] args) throws Throwable

      Specified by:
      invoke in interface InvocationHandler
      Parameters:
      proxy - the proxy instance that the method was invoked on
      method - the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
      args - an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
      Returns:
      the invocation result value
      Throws:
      Throwable - the exception to throw from the method invocation on the proxy instance.
    • handleInvocation

      protected abstract Object handleInvocation​(Object proxy, Method method, Object[] args) throws Throwable
      invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) delegates to this method upon any method invocation on the proxy instance, except Object.equals(java.lang.Object), Object.hashCode() and Object.toString(). The result will be returned as the proxied method's return value.

      Unlike invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]), args will never be null. When the method has no parameter, an empty array is passed in.

      Parameters:
      proxy - the proxy instance that the method was invoked on
      method - the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
      args - an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
      Returns:
      the invocation result value
      Throws:
      Throwable - the exception to throw from the method invocation on the proxy instance.
    • equals

      public boolean equals​(Object obj)
      By default delegates to Object.equals(java.lang.Object) so instances are only equal if they are identical. proxy.equals(argument) returns true if:
      • proxy and argument are of the same type
      • and this method returns true for the InvocationHandler of argument

      Subclasses can override this method to provide custom equality.

      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • hashCode

      public int hashCode()
      By default delegates to Object.hashCode(). The dynamic proxies' hashCode() will delegate to this method. Subclasses can override this method to provide custom equality.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
    • toString

      public String toString()
      By default delegates to Object.toString(). The dynamic proxies' toString() will delegate to this method. Subclasses can override this method to provide custom string representation for the proxies.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.