Search in sources :

Example 1 with SingletonAspectInstanceFactory

use of org.springframework.aop.aspectj.SingletonAspectInstanceFactory in project uPortal by Jasig.

the class AspectJAroundAdviceFactory method createInstance.

@Override
protected AspectJAroundAdvice createInstance() throws Exception {
    final Class<? extends Object> aspectType = this.aspect.getClass();
    final Method method = ReflectionUtils.findMethod(aspectType, this.method, this.args);
    final SingletonAspectInstanceFactory aif = new SingletonAspectInstanceFactory(this.aspect);
    return new AspectJAroundAdvice(method, pointcut, aif);
}
Also used : AspectJAroundAdvice(org.springframework.aop.aspectj.AspectJAroundAdvice) SingletonAspectInstanceFactory(org.springframework.aop.aspectj.SingletonAspectInstanceFactory) Method(java.lang.reflect.Method)

Example 2 with SingletonAspectInstanceFactory

use of org.springframework.aop.aspectj.SingletonAspectInstanceFactory in project uPortal by Jasig.

the class AspectJExpressionTest method testProgramaticPointcut.

@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");
    assertEquals(2, countingMethodInterceptor.getCount());
}
Also used : AspectJAroundAdvice(org.springframework.aop.aspectj.AspectJAroundAdvice) AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) SingletonAspectInstanceFactory(org.springframework.aop.aspectj.SingletonAspectInstanceFactory) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)2 AspectJAroundAdvice (org.springframework.aop.aspectj.AspectJAroundAdvice)2 SingletonAspectInstanceFactory (org.springframework.aop.aspectj.SingletonAspectInstanceFactory)2 Test (org.junit.Test)1 AspectJProxyFactory (org.springframework.aop.aspectj.annotation.AspectJProxyFactory)1