Examples of AspectJProxyFactory


Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

    @Override
    protected void buildDocument(Context context, Item item)
            throws SQLException, IOException
    {
        AspectJProxyFactory pf = new AspectJProxyFactory(item);
        pf.setProxyTargetClass(true);
        pf.addAdvice(new CrisItemWrapper());
        // ProxyFactory pf = new ProxyFactory(item);
        super.buildDocument(context, (Item) pf.getProxy());
    }
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

  }

  public void testProgrammaticProxyCreation() {
    ITestBean testBean = new TestBean();

    AspectJProxyFactory factory = new AspectJProxyFactory();
    factory.setTarget(testBean);

    CounterAspect myCounterAspect = new CounterAspect();
    factory.addAspect(myCounterAspect);

    ITestBean proxyTestBean = factory.getProxy();

    assertTrue("Expected a proxy", proxyTestBean instanceof Advised);
    proxyTestBean.setAge(20);
    assertEquals("Programmatically created proxy shouldn't match bean()", 0, myCounterAspect.count);
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

  @Test
  public void testProgrammaticProxyCreation() {
    ITestBean testBean = new TestBean();

    AspectJProxyFactory factory = new AspectJProxyFactory();
    factory.setTarget(testBean);

    CounterAspect myCounterAspect = new CounterAspect();
    factory.addAspect(myCounterAspect);

    ITestBean proxyTestBean = factory.getProxy();

    assertTrue("Expected a proxy", proxyTestBean instanceof Advised);
    proxyTestBean.setAge(20);
    assertEquals("Programmatically created proxy shouldn't match bean()", 0, myCounterAspect.count);
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

   
    @Test
    public void testProgramaticPointcut() {
        final RepositoryPointcutInterface targetPointcutInterface = new RepositoryPointcutInterfaceImpl();
       
        final AspectJProxyFactory portletPreferencesProxyFactory = new AspectJProxyFactory(targetPointcutInterface);
       
        final Method interceptorMethod = ReflectionUtils.findMethod(CountingMethodInterceptor.class, "countInvocation", ProceedingJoinPoint.class);
        final AspectJAroundAdvice aspectJAroundAdvice = new AspectJAroundAdvice(
                interceptorMethod,
                repositoryPointcutInterfaceExecutionPointcut,
                new SingletonAspectInstanceFactory(this.countingMethodInterceptor));
       
        portletPreferencesProxyFactory.addAdvice(aspectJAroundAdvice);

        final RepositoryPointcutInterface proxiedPointcutInterface = (RepositoryPointcutInterface) portletPreferencesProxyFactory.getProxy();

        assertEquals(0, countingMethodInterceptor.getCount());
        proxiedPointcutInterface.methodOne("test");
        assertEquals(1, countingMethodInterceptor.getCount());
        proxiedPointcutInterface.methodOne("test");
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

   
    @Test
    public void testProgramaticPointcut2() {
        final RepositoryPointcutInterface targetPointcutInterface = new RepositoryPointcutInterfaceImpl();
       
        final AspectJProxyFactory portletPreferencesProxyFactory = new AspectJProxyFactory(targetPointcutInterface);
        portletPreferencesProxyFactory.addAdvice(countingMethodInterceptorRepositoryAdvice);
        final RepositoryPointcutInterface proxiedPointcutInterface = (RepositoryPointcutInterface) portletPreferencesProxyFactory.getProxy();

        assertEquals(0, countingMethodInterceptor.getCount());
        proxiedPointcutInterface.methodOne("test");
        assertEquals(1, countingMethodInterceptor.getCount());
        proxiedPointcutInterface.methodOne("test");
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

        final Object result = pjp.proceed();
        if (result == null) {
            return result;
        }
       
        final AspectJProxyFactory portletPreferencesProxyFactory = new AspectJProxyFactory(result);
       
        for (final Advice advice : this.advices) {
            portletPreferencesProxyFactory.addAdvice(advice);
        }
       
        return portletPreferencesProxyFactory.getProxy();
    }
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectJProxyFactory

    // Bloqueando o acesso a instaciar diretamente a classe
  }
 
  @SuppressWarnings("unchecked")
  public <T> T criarProxy(T target, Class<?>... aspects) {
    AspectJProxyFactory proxy = new AspectJProxyFactory(target);
    proxy.setProxyTargetClass(true);
    for (Class<?> aspectClass : aspects) {
      proxy.addAspect(aspectClass);
    }
    return (T) proxy.getProxy();
  }
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.