Class GrapheneProxyHandler

java.lang.Object
org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler
All Implemented Interfaces:
InvocationHandler, MethodInterceptor
Direct Known Subclasses:
GrapheneContextualHandler

public abstract class GrapheneProxyHandler extends Object implements MethodInterceptor, InvocationHandler

Invocation handler which wraps the given target for invocation (as the target instance for future computation of target).

This handlers determines whenever the result of invocation can be proxied and if yes, it recursively wraps it with proxy using this invocation handler.

Author:
Lukas Fryc
  • Constructor Details

    • GrapheneProxyHandler

      public GrapheneProxyHandler(Object target)
      Returns invocation handler which wraps the given target instance.
      Parameters:
      target - the target of invocation
    • GrapheneProxyHandler

      public GrapheneProxyHandler(GrapheneProxy.FutureTarget future)
      Returns invocation handler which wraps the target for future computation.
      Parameters:
      future - the future target
  • Method Details

    • intercept

      @RuntimeType public static Object intercept(@This Object self, @FieldValue("__interceptor") MethodInterceptor interceptor, @Origin Method method, @AllArguments Object[] args) throws Throwable
      Throws:
      Throwable
    • invoke

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

      End point for handling invocations on proxy.

      Decides whenever the result of invocation is proxyable and if yes, it returns the proxy using new instance of GrapheneProxyHandler wrapping the result of invocation.

      The method specifically handles GrapheneProxyInstance.unwrap() method which returns the real target for invocation.

      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable
    • intercept

      protected Object intercept(Object obj, Method method, Object[] args) throws Throwable
      Throws:
      Throwable
    • isProxyable

      protected boolean isProxyable(Method method, Object[] args)
      Determines whenever the given invocation can be proxied.
      Parameters:
      method - the method which is invoked
      args - the arguments used for invocation
      Returns:
      true if the given invocation can be proxied; false otherwise
    • invokeReal

      protected Object invokeReal(Object target, Method method, Object[] args) throws Throwable

      Invokes the method on real target.

      Parameters:
      target - the target to be invoked
      method - the method to be invoked
      args - the arguments used for invocation
      Returns:
      the result of invocation on real target
      Throws:
      Throwable
    • getTarget

      protected Object getTarget()
      Computes the target for invocation - if future target is provided, it will be returned, othewise the target instance will be returned.
      Returns:
      the real target for invocation