I am trying to create an Aspect advisor using the aop. I need to configure it using javaConfig and NOT using xml
I have the following Aspect (taken form the Spring tutorial)
I am using javaConfig to configure all spring related BeansCode:package org.try; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.core.Ordered; @Aspect public class ConcurrentOperationExecutor implements Ordered { private int order = 1; public int getOrder() { return this.order; } public void setOrder(int order) { this.order = order; } @Around("@annotation(org.try.Advised)") public Object doConcurrentOperation(ProceedingJoinPoint pjp) throws Throwable { System.out.println("IN ASPECT SUCCESS!!!!!!!!!!!!!!!!!!! " + pjp.getSignature().getDeclaringTypeName() + " " + pjp.getSignature().toLongString()); return pjp.proceed(); } }
but I cant get the Aspect to be configured as an Advisor.
my javaConfig:
In the xml file I have the following tag:Code:@Bean public ConcurrentOperationExecutor concurrentOperationExecutor() { ConcurrentOperationExecutor coe = new ConcurrentOperationExecutor(); coe.setOrder(1); return coe; }
I tried to put the configuration in the xml file this way:Code:<aop:aspectj-autoproxy/>
but it seems that the Advisor works but doesnt catch all annotated methods. It catches some annotated methods and it misses some others.Code:<bean id="concurrentOperationExecutor" class="org.try.ConcurrentOperationExecutor"> <property name="order" value="1" /> </bean>
I believe it has something to do with all the rest of the beans configured using javaconfig.
We also have a regular transaction advisor using annotations that works without problems (using @SpringAdvisor) on the bean.
Did anyone else try to use JavaConfig with Spring AOP and advisors?


Reply With Quote