Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory.addAdvice()


    factory.setTarget(source);
    factory.setOpaque(true);
    factory.setInterfaces(projectionType, TargetClassAware.class);

    factory.addAdvice(new TargetClassAwareMethodInterceptor(source.getClass()));
    factory.addAdvice(getMethodInterceptor(source, projectionType));

    return (T) factory.getProxy();
  }

  /**
 
View Full Code Here


        }

        // Add an introduction that implements only the methods on ScopedObject.
        // Not sure if this is useful...
        ScopedObject scopedObject = new DefaultScopedObject(cbf, scopedTargetSource.getTargetBeanName());
        pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

        // Add the AopInfrastructureBean marker to indicate that the scoped proxy
        // itself is not subject to auto-proxying! Only its target bean is.
        // Not sure if this is needed....
        pf.addInterface(AopInfrastructureBean.class);
View Full Code Here

        // create the bean (if not already done)
        Object value = objectFactory.getObject();

        ProxyFactory factory = new ProxyFactory(value);
        factory.setProxyTargetClass(true);
        factory.addAdvice(new CurrentConversationAdvice(conversation, beanName));

        if (advices != null && advices.length > 0)
        {
          for (int i = 0; i < advices.length; i++)
          {
View Full Code Here

        if (advices != null && advices.length > 0)
        {
          for (int i = 0; i < advices.length; i++)
          {
            factory.addAdvice(advices[i]);
          }
        }

        value = factory.getProxy();
View Full Code Here

        }

        // Add an introduction that implements only the methods on ScopedObject.
        // Not sure if this is useful...
        ScopedObject scopedObject = new DefaultScopedObject(cbf, scopedTargetSource.getTargetBeanName());
        pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

        // Add the AopInfrastructureBean marker to indicate that the scoped proxy
        // itself is not subject to auto-proxying! Only its target bean is.
        // Not sure if this is needed....
        pf.addInterface(AopInfrastructureBean.class);
View Full Code Here

    if (type.isInterface()) {

      ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
      factory.addInterface(type);
      factory.addInterface(LastInvocationAware.class);
      factory.addAdvice(interceptor);

      return (T) factory.getProxy();
    }

    Enhancer enhancer = new Enhancer();
View Full Code Here

    ctx.refresh();

    EventPublicationInterceptor interceptor =
        (EventPublicationInterceptor) ctx.getBean("publisher");
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(0, interceptor);

    ITestBean testBean = (ITestBean) factory.getProxy();

    // invoke any method on the advised proxy to see if the interceptor has been invoked
    testBean.getAge();
View Full Code Here

  @Test
  public void testMethodValidationInterceptor() {
    MyValidBean bean = new MyValidBean();
    ProxyFactory proxyFactory = new ProxyFactory(bean);
    proxyFactory.addAdvice(new MethodValidationInterceptor());
    proxyFactory.addAdvisor(new AsyncAnnotationAdvisor());
    doTestProxyValidation((MyValidInterface) proxyFactory.getProxy());
  }

  @Test
View Full Code Here

  private static <T> T initProxy(Class<?> type, ControllerMethodInvocationInterceptor interceptor) {
    if (type.isInterface()) {
      ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
      factory.addInterface(type);
      factory.addInterface(MethodInvocationInfo.class);
      factory.addAdvice(interceptor);
      return (T) factory.getProxy();
    }
    else {
      Enhancer enhancer = new Enhancer();
      enhancer.setSuperclass(type);
View Full Code Here

            proxyFactory.addInterface(ifc);
          }
        }
      }
      if (jof.exposeAccessContext) {
        proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
      }
      proxyFactory.setTargetSource(targetSource);
      return proxyFactory.getProxy(jof.beanClassLoader);
    }
  }
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.