Examples of DefaultPointcutAdvisor


Examples of org.springframework.aop.support.DefaultPointcutAdvisor

   
    HotSwappableTargetSource hts = new HotSwappableTargetSource(sp1);
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(Person.class);
    pf.setTargetSource(hts);
    pf.addAdvisor(new DefaultPointcutAdvisor(new SerializableNopInterceptor()));
    Person p = (Person) pf.getProxy();
   
    assertEquals(sp1.getName(), p.getName());
    hts.swap(sp2);
    assertEquals(sp2.getName(), p.getName());
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

    String name = "tony";

    TestBean target1 = new TestBean();
    target1.setAge(age1);
    ProxyFactory pf1 = new ProxyFactory(target1);
    pf1.addAdvisor(new DefaultPointcutAdvisor(new NopInterceptor()));
    pf1.addAdvisor(new DefaultPointcutAdvisor(new TimestampIntroductionInterceptor()));
    ITestBean tb = (ITestBean) pf1.getProxy();

    assertEquals(age1, tb.getAge());
    tb.setAge(age2);
    assertEquals(age2, tb.getAge());
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

    pc.setFrozen(true);
    Advised advised = (Advised) proxied;

    assertTrue(pc.isFrozen());
    try {
      advised.addAdvisor(new DefaultPointcutAdvisor(new NopInterceptor()));
      fail("Shouldn't be able to add Advisor when frozen");
    }
    catch (AopConfigException ex) {
      assertTrue(ex.getMessage().indexOf("frozen") > -1);
    }
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

    TestBean target = new TestBean();
    ProxyFactory pc = new ProxyFactory(target);
    pc.setInterfaces(new Class[] {ITestBean.class});
    pc.addAdvice(new NopInterceptor());
    MethodBeforeAdvice mba = new CountingBeforeAdvice();
    Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut(), mba);
    pc.addAdvisor(advisor);
    ITestBean proxied = (ITestBean) createProxy(pc);

    String proxyConfigString = ((Advised) proxied).toProxyConfigString();
    assertTrue(proxyConfigString.indexOf(advisor.toString()) != -1);
    assertTrue(proxyConfigString.indexOf("1 interface") != -1);
  }
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

    TestBean target = new TestBean();
    ProxyFactory pc = new ProxyFactory(target);
    pc.setInterfaces(new Class[] {ITestBean.class});
    pc.addAdvice(new NopInterceptor());
    CountingBeforeAdvice mba = new CountingBeforeAdvice();
    Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut().addMethodName("setAge"), mba);
    pc.addAdvisor(advisor);
    assertFalse("Opaque defaults to false", pc.isOpaque());
    pc.setOpaque(true);
    assertTrue("Opaque now true for this config", pc.isOpaque());
    ITestBean proxied = (ITestBean) createProxy(pc);
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

    pc.getProxy();
    assertEquals(1, l.activates);

    pc.removeListener(l);
    assertEquals(2, l.adviceChanges);
    pc.addAdvisor(new DefaultPointcutAdvisor(new NopInterceptor()));
    // No longer counting
    assertEquals(2, l.adviceChanges);
  }
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

      }
    }

    NameSaver saver = new NameSaver();

    pc.addAdvisor(new DefaultPointcutAdvisor(Pointcuts.SETTERS, nameReverter));
    pc.addAdvisor(new DefaultPointcutAdvisor(Pointcuts.SETTERS, saver));
    ITestBean it = (ITestBean) createProxy(pc);

    String name1 = "tony";
    String name2 = "gordon";
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

  public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
    ++afterTakesInt;
  }
 
  public static Advisor advisor() {
    return new DefaultPointcutAdvisor(
      new StaticMethodMatcherPointcut() {
        public boolean matches(Method method, Class targetClass) {
          return method.getParameterTypes().length == 1 &&
            method.getParameterTypes()[0].equals(Integer.class);
        }
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

  public void before(Method method, Object[] args, Object target) throws Throwable {
    ++beforeStringReturn;
  }
 
  public static Advisor advisor() {
    return new DefaultPointcutAdvisor(
      new StaticMethodMatcherPointcut() {
        public boolean matches(Method method, Class targetClass) {
          return method.getReturnType().equals(String.class);
        }
      },
View Full Code Here

Examples of org.springframework.aop.support.DefaultPointcutAdvisor

      public boolean equals(Object obj) {
        return true;
      }
    };
    pf.addAdvisor(new DefaultPointcutAdvisor(pointcut, advice));

    pf.setTarget(target);
    pf.setFrozen(true);
    pf.setExposeProxy(false);
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.