Examples of addAdvisor()


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

    // 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;
     
      public void before(Method method, Object[] args, Object target) throws Throwable {
        JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
View Full Code Here

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

  }
 
  public void testCanGetSourceLocationFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      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());
        assertEquals(TestBean.class, sloc.getWithinType());
View Full Code Here

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

  }
 
  public void testCanGetStaticPartFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      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());
        assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind());
View Full Code Here

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

    advisor.setAdvice(interceptor);
    advisor.setPointcut(pointcut);

    ProxyFactory pf = new ProxyFactory();
    pf.setTarget(target);
    pf.addAdvisor(advisor);

    return (TestBean) pf.getProxy();
  }

  private void assertMatchesGetAge(MethodMatcher methodMatcher) {
View Full Code Here

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

 
  public void testNoIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();
   
    assertFalse("No introduction", proxy instanceof NamedBean);
    // Requires binding
View Full Code Here

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

  public void testNoIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();
   
    assertFalse("No introduction", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();
View Full Code Here

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

 
  public void testWithIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();
   
    assertTrue("Introduction was made", proxy instanceof NamedBean);
    // Requires binding
View Full Code Here

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

  public void testWithIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();
   
    assertTrue("Introduction was made", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();
View Full Code Here

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

    target.setAge(27);
    NopInterceptor nop = new NopInterceptor();
    ControlFlowPointcut cflow = new ControlFlowPointcut(One.class, "getAge");
    ProxyFactory pf = new ProxyFactory(target);
    ITestBean proxied = (ITestBean) pf.getProxy();
    pf.addAdvisor(new DefaultPointcutAdvisor(cflow, nop));
   
    // Not advised, not under One
    assertEquals(target.getAge(), proxied.getAge());
    assertEquals(0, nop.getCount());
   
View Full Code Here

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

    NopInterceptor nop = new NopInterceptor();
    ControlFlowPointcut cflow = new ControlFlowPointcut(One.class);
    Pointcut settersUnderOne = Pointcuts.intersection(Pointcuts.SETTERS, cflow);
    ProxyFactory pf = new ProxyFactory(target);
    ITestBean proxied = (ITestBean) pf.getProxy();
    pf.addAdvisor(new DefaultPointcutAdvisor(settersUnderOne, nop));
 
    // Not advised, not under One
    target.setAge(16);
    assertEquals(0, nop.getCount());
 
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.