Package org.springframework.aop.framework

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


    ts.getTimeStamp();
    long timestamp = 111L;
    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), SubTimeStamped.class));

    SubTimeStamped tsp = (SubTimeStamped) factory.getProxy();
    assertTrue(tsp.getTimeStamp() == timestamp);

    tsControl.verify();
View Full Code Here


    ts.getTimeStamp();
    long timestamp = 111L;
    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class));

    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertTrue(!(tsp instanceof SubTimeStamped));
    assertTrue(tsp.getTimeStamp() == timestamp);
View Full Code Here

    DelegatingIntroductionInterceptor ii = new DelegatingIntroductionInterceptor(new Test());
   
    TestBean target = new TestBean();
   
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts.getTimeStamp() == t);
View Full Code Here

    TestBean target = new TestBean();
   
    ProxyFactory pf = new ProxyFactory(target);
    IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
    assertTrue(ia.isPerInstance());
    pf.addAdvisor(0, ia);
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts instanceof TimeStamped);
View Full Code Here

    // Test removal
    ii.suppressInterface(TimeStamped.class);
    // Note that we need to construct a new proxy factory,
    // or suppress the interface on the proxy factory
    pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
    Object o = pf.getProxy();
    assertTrue(!(o instanceof TimeStamped));
  }
 
  public void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
View Full Code Here

    assertTrue(! (raw instanceof TimeStamped));
    ProxyFactory factory = new ProxyFactory(raw);
 
    TimeStamped ts = new SerializableTimeStamped(0);

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts) {
      public String toString() {
        throw new UnsupportedOperationException("Shouldn't be invoked");
      }
    }));
   
View Full Code Here

    ProxyFactory factory = new ProxyFactory(serializableTarget);
    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());
View Full Code Here

 
    // != t
    TestBean target = new TargetClass(t + 1);
 
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
 
    TimeStamped ts = (TimeStamped) pf.getProxy();
    // From introduction interceptor, not target
    assertTrue(ts.getTimeStamp() == t);
  }
View Full Code Here

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

    for (Object a : advisors) {
      pf.addAdvisor((Advisor) a);
    }

    pf.setExposeProxy(true);
    return pf.getProxy();
  }
View Full Code Here

      }
    }

    Advisor[] advisors = buildAdvisors(beanName, specificInterceptors);
    for (int i = 0; i < advisors.length; i++) {
      proxyFactory.addAdvisor(advisors[i]);
    }

    proxyFactory.setTargetSource(targetSource);
    customizeProxyFactory(proxyFactory);
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.