Package org.springframework.aop.framework

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


  @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
  public void testMethodValidationPostProcessor() {
View Full Code Here


    // Will be set by advice during a method call
    final int newAge = 23;

    ProxyFactory pf = new ProxyFactory(raw);
    pf.setExposeProxy(true);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      private int depth;

      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
View Full Code Here

      }
    }

    Advisor[] advisors = buildAdvisors(beanName, specificInterceptors);
    for (Advisor advisor : advisors) {
      proxyFactory.addAdvisor(advisor);
    }

    proxyFactory.setTargetSource(targetSource);
    customizeProxyFactory(proxyFactory);
View Full Code Here

  @Test
  public void testCanGetSourceLocationFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
        SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
        assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
View Full Code Here

  @Test
  public void testCanGetStaticPartFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
        StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart();
        assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart());
View Full Code Here

  @Test
  public void toShortAndLongStringFormedCorrectly() throws Exception {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
        // makeEncSJP, although meant for computing the enclosing join point,
        // it serves our purpose here
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

    logAdvice.reset();

    ProxyFactory factory = new ProxyFactory(target);
    factory.setProxyTargetClass(proxyTargetClass);
    factory.addAdvisor(advisor);
    TestService bean = (TestService) factory.getProxy();

    assertEquals(0, logAdvice.getCountThrows());
    try {
      bean.sayHello();
View Full Code Here

    TimeStamped ts = mock(TimeStamped.class);
    long timestamp = 111L;
    given(ts.getTimeStamp()).willReturn(timestamp);

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

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

    TimeStamped ts = mock(SubTimeStamped.class);
    long timestamp = 111L;
    given(ts.getTimeStamp()).willReturn(timestamp);

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

    SubTimeStamped tsp = (SubTimeStamped) factory.getProxy();
    assertTrue(tsp.getTimeStamp() == timestamp);
  }
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.