Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


  }

  public void testUndeclaredUnheckedException() throws Throwable {
    final RuntimeException unexpectedException = new RuntimeException();
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw unexpectedException;
      }
    };
    AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
View Full Code Here


  public void testCloneInvocationToProceedThreeTimes() throws Throwable {
    TestBean tb = new TestBean();
    ProxyFactory pc = new ProxyFactory(tb);
    pc.addInterface(ITestBean.class);

    MethodInterceptor twoBirthdayInterceptor = new MethodInterceptor() {
      public Object invoke(MethodInvocation mi) throws Throwable {
        // Clone the invocation to proceed three times
        // "The Moor's Last Sigh": this technology can cause premature aging
        MethodInvocation clone1 = ((ReflectiveMethodInvocation) mi).invocableClone();
        MethodInvocation clone2 = ((ReflectiveMethodInvocation) mi).invocableClone();
View Full Code Here

    pc.addInterface(ITestBean.class);

    /**
     * Changes the name, then changes it back.
     */
    MethodInterceptor nameReverter = new MethodInterceptor() {
      public Object invoke(MethodInvocation mi) throws Throwable {
        MethodInvocation clone = ((ReflectiveMethodInvocation) mi).invocableClone();
        String oldName = ((ITestBean) mi.getThis()).getName();
        clone.getArguments()[0] = oldName;
        // Original method invocation should be unaffected by changes to argument list of clone
View Full Code Here

    public static void reset() {
      methodNames.clear();
    }
   
    public PointcutForVoid() {
      setAdvice(new MethodInterceptor() {
        public Object invoke(MethodInvocation invocation) throws Throwable {
          methodNames.add(invocation.getMethod().getName());
          return invocation.proceed();
        }
      });
View Full Code Here

  private ITestBean getAdvisedProxy(TestBean target) {
    ProxyFactory pf = new ProxyFactory(new Class[]{ITestBean.class});
    pf.setProxyTargetClass(true);

    MethodInterceptor advice = new NopInterceptor();
    Pointcut pointcut = new Pointcut() {
      public ClassFilter getClassFilter() {
        return ClassFilter.TRUE;
      }
View Full Code Here

    // no exception
    tb.hashCode();
   
    final Exception ex = new UnsupportedOperationException("invoke");
    // Add evil interceptor to head of list
    config.addAdvice(0, new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw ex;
      }
    });
    assertEquals("Have correct advisor count", 2, config.getAdvisors().length);
View Full Code Here

    }

    public Object invoke(MethodInvocation invocation) throws Throwable
    {
        Injector inj = injector; // volatile read
        MethodInterceptor interceptor = inj != null ? inj.getInstance(key) : null;
        if (interceptor == null)
        {
            return invocation.proceed();
        }
        else
        {
            return interceptor.invoke(invocation);
        }
    }
View Full Code Here

        if (!(interceptors instanceof RandomAccess)) {
            // Make sure we are indexable
            interceptors = new ArrayList<MethodInterceptor>(interceptors);
        }
       
        MethodInterceptor nextInterceptor = interceptors.get(0);
       
        return nextInterceptor.invoke(new MethodInvocationImpl(args,
                thisMethod, self, interceptors, 0, proceed));
    }
View Full Code Here

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

                         TypeEncounter<T> encounter) {
        Class<? super T> klass = literal.getRawType();

        do {
            for (Method method : klass.getDeclaredMethods()) {
                final MethodInterceptor interceptor = CountedInterceptor.forMethod(metricRegistry,
                                                                                 klass, method);
                if (interceptor != null) {
                    encounter.bindInterceptor(Matchers.only(method), interceptor);
                }
            }
View Full Code Here

TOP

Related Classes of org.aopalliance.intercept.MethodInterceptor

Copyright © 2018 www.massapicom. 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.