Spring Aspects advices being performed twice in Grails App
I have a grails app and I've added an @After advice on a grails service method
class OrderManagementService {
static transactional = true
开发者_JS百科 public void confirmOrder() {
}
}
@Aspect
public class NotVeryUsefulAspect {
@Pointcut("execution(* OrderManagementService.confirmOrder())")
public void orderManagementConfirmOrder(){}
@After("orderManagementConfirmOrder()")
public void doSomething(){
System.out.println("My First Advice is working :-)");
}
@Around("orderManagementConfirmOrder()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("Around Method Invoked");
return pjp.proceed();
}
}
however when this method is perform this both advices are invoked twice so in the output I have
Around Method Invoked Around Method Invoked My First Advice is working :-) My First Advice is working :-)
I think this has to do with the CGLIB proxy of the grails services
this is my resource.xml
aop:aspectj-autoproxy proxy-target-class="false"
bean id="myAspect" class="org.xyz.NotVeryUsefulAspect"
aop:config proxy-target-class="true"
inside of xml
any one come across this and have a solution to make it work correctly cheers
精彩评论