Package org.springframework.aop.framework

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


  public static void main(String[] args) {
    StubBank target = new StubBank();
    LoggingAdvice advice = new LoggingAdvice();
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(advice);
    Bank bank = (Bank) pf.getProxy();
    bank.debit("abc", 100);
    bank.credit("abc", 200);
  }
View Full Code Here


  }

  protected Object configuredProxy(SimpleRemoteSlsbInvokerInterceptor si, Class<?> ifc) throws NamingException {
    si.afterPropertiesSet();
    ProxyFactory pf = new ProxyFactory(new Class<?>[] {ifc});
    pf.addAdvice(si);
    return pf.getProxy();
  }


  @Test
View Full Code Here

    Context mockContext = mockContext(jndiName, ejb);

    LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);

    ProxyFactory pf = new ProxyFactory(new Class<?>[] { BusinessMethods.class } );
    pf.addAdvice(si);
    BusinessMethods target = (BusinessMethods) pf.getProxy();

    assertTrue(target.targetMethod() == retVal);

    verify(mockContext).close();
View Full Code Here

    Context mockContext = mockContext(jndiName, ejb);

    LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);

    ProxyFactory pf = new ProxyFactory(new Class<?>[] { BusinessMethods.class } );
    pf.addAdvice(si);
    BusinessMethods target = (BusinessMethods) pf.getProxy();

    assertTrue(target.targetMethod() == retVal);

    verify(mockContext).close();
View Full Code Here

    Context mockContext = mockContext(jndiName, ejb);

    LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);

    ProxyFactory pf = new ProxyFactory(new Class<?>[] { LocalInterfaceWithBusinessMethods.class } );
    pf.addAdvice(si);
    LocalInterfaceWithBusinessMethods target = (LocalInterfaceWithBusinessMethods) pf.getProxy();

    try {
      target.targetMethod();
      fail("Should have thrown exception");
View Full Code Here

      proxyFactory.setProxyTargetClass(proxyTargetClass);
    }

    DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
    introduction.suppressInterface(TargetSource.class);
    proxyFactory.addAdvice(introduction);

    return proxyFactory.getProxy(classLoader);
  }

  /**
 
View Full Code Here

    JmxTestBean bean = new JmxTestBean();
    bean.setName("Rob Harrop");

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(bean);
    factory.addAdvice(new NopInterceptor());
    factory.setInterfaces(IJmxTestBean.class);

    IJmxTestBean proxy = (IJmxTestBean) factory.getProxy();
    String name = "bean:mmm=whatever";
View Full Code Here

    checkServiceInterface();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addInterface(getServiceInterface());
    if (this.registerTraceInterceptor != null ?
        this.registerTraceInterceptor.booleanValue() : this.interceptors == null) {
      proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
    }
    if (this.interceptors != null) {
      AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
      for (int i = 0; i < this.interceptors.length; i++) {
        proxyFactory.addAdvisor(adapterRegistry.wrap(this.interceptors[i]));
View Full Code Here

    AnnotationTransactionAttributeSource tas = new AnnotationTransactionAttributeSource();
    TransactionInterceptor ti = new TransactionInterceptor(ptm, tas);

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    proxyFactory.addAdvice(ti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();
    assertEquals(1, ptm.commits);
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

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.