Package org.springframework.aop.framework

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


  public void testWithCglibProxy() throws Exception {
    IJmxTestBean tb = createJmxTestBean();
    ProxyFactory pf = new ProxyFactory();
    pf.setTarget(tb);
    pf.addAdvice(new NopInterceptor());
    Object proxy = pf.getProxy();

    MetadataMBeanInfoAssembler assembler = (MetadataMBeanInfoAssembler) getAssembler();

    MBeanExporter exporter = new MBeanExporter();
View Full Code Here


    TransactionInterceptor ti = new TransactionInterceptor();
    ti.setTransactionManager(ptm);
    ti.setTransactionAttributeSources(tas);

    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(0, ti);
    return pf.getProxy();
  }

  /**
   * Template method to create an advised object given the
View Full Code Here

    assertEquals(ptm, ti.getTransactionManager());   
    ti.setTransactionAttributeSource(tas);
    assertEquals(tas, ti.getTransactionAttributeSource());

    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(0, ti);
    return pf.getProxy();
  }
 
/**
   * A TransactionInterceptor should be serializable if its
View Full Code Here

            public ITestBean getSpouse() {
                return this;
            }
      };
      ProxyFactory pf = new ProxyFactory(target);
      pf.addAdvice(new DelegatingIntroductionInterceptor(delegate));
      INestedTestBean proxy = (INestedTestBean) pf.getProxy();
     
      assertEquals(company, proxy.getCompany());
      ITestBean introduction = (ITestBean) proxy;
      assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
View Full Code Here

    factory.addInterface(Person.class);
    long time = 1000;
    TimeStamped ts = new SerializableTimeStamped(time);
 
    factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
    factory.addAdvice(new SerializableNopInterceptor());
   
    Person p = (Person) factory.getProxy();
   
    assertEquals(name, p.getName());
    assertEquals(time, ((TimeStamped) p).getTimeStamp());
View Full Code Here

  public void testSerializable() throws Exception {
    DerivedTestBean tb = new DerivedTestBean();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
    proxyFactory.addAdvice(cti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();

    ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
View Full Code Here

    TestBean tb = new TestBean();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
    cti.setConcurrencyLimit(concurrencyLimit);
    proxyFactory.addAdvice(cti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();

    Thread[] threads = new Thread[NR_OF_THREADS];
    for (int i = 0; i < NR_OF_THREADS; i++) {
View Full Code Here

    else {
      pf.setProxyTargetClass(true);
    }

    // Required everywhere we use AspectJ proxies
    pf.addAdvice(ExposeInvocationInterceptor.INSTANCE);

    for (Object a : advisors) {
      pf.addAdvisor((Advisor) a);
    }
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

    checkService();
    checkServiceInterface();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addInterface(getServiceInterface());
    if (isRegisterTraceInterceptor()) {
      proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
    }
    proxyFactory.setTarget(getService());
    return proxyFactory.getProxy(getBeanClassLoader());
  }
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.