Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor.invoke()


  @Override
  public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
    MethodInterceptor methodInterceptor = advised.getMethodInterceptor();
    if (advised.getMethodMatcher() != null
        && advised.getMethodMatcher().matches(method, advised.getTargetSource().getTarget().getClass())) {
      return methodInterceptor.invoke(new ReflectiveMethodInvocation(advised.getTargetSource().getTarget(),
          method, args));
    } else {
      return method.invoke(advised.getTargetSource().getTarget(), args);
    }
  }
View Full Code Here


    AdvisedSupport pc = new AdvisedSupport(new Class[] { ITestBean.class });
    pc.addAdvice(mi);
    AopProxy aop = createAopProxy(pc);

    // Really would like to permit null arg:can't get exact mi
    mi.invoke(null);
    //mi.invoke(new MethodInvocationImpl(aop, null, ITestBean.class,
    //  ITestBean.class.getMethod("getAge", null),
    //  null, l, r));
    //miControl.
    //miControl.setReturnValue(new Integer(age));
View Full Code Here

        {
            return invocation.proceed();
        }
        else
        {
            return interceptor.invoke(invocation);
        }
    }

    private final Key<? extends MethodInterceptor> key;
    private volatile Injector injector = null;
View Full Code Here

            interceptors = new ArrayList<MethodInterceptor>(interceptors);
        }
       
        MethodInterceptor nextInterceptor = interceptors.get(0);
       
        return nextInterceptor.invoke(new MethodInvocationImpl(args,
                thisMethod, self, interceptors, 0, proceed));
    }
   
    private class MethodInvocationImpl implements MethodInvocation {
        private final Object[] arguments;  // Live!
View Full Code Here

            }
           
            // Invoke the next interceptor
            MethodInterceptor nextInterceptor = interceptors.get(newIndex);
           
            return nextInterceptor.invoke(new MethodInvocationImpl(arguments,
                    method, myself, interceptors, newIndex, proceed));
        }
       
    }
View Full Code Here

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    MethodInterceptor delegate = getDelegate(invocation.getThis(), invocation.getMethod());
    if (delegate != null) {
      return delegate.invoke(invocation);
    }
    else {
      return invocation.proceed();
    }
  }
View Full Code Here

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(null), interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getHelper"));
    when(interceptor.invoke(invocation)).thenReturn("Foo");

    assertThat(methodInterceptor.invoke(invocation), is(instanceOf(Helper.class)));
  }

  /**
   * @see DATAREST-221
   */
 
View Full Code Here

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getString"));
    when(interceptor.invoke(invocation)).thenReturn("Foo");

    assertThat(methodInterceptor.invoke(invocation), is((Object) "Foo"));
  }

  /**
   * @see DATAREST-221
   */
 
View Full Code Here

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(interceptor.invoke(invocation)).thenReturn(null);

    assertThat(methodInterceptor.invoke(invocation), is(nullValue()));
  }

  /**
   * @see DATAREST-221
   */
 
View Full Code Here

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getPrimitive"));
    when(interceptor.invoke(invocation)).thenReturn(1L);

    assertThat(methodInterceptor.invoke(invocation), is((Object) 1L));
    verify(factory, times(0)).createProjection(anyObject(), (Class<?>) anyObject());
  }

  interface Helper {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.