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);
}
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());
}
Aggregations