-
Jun 17th, 2011, 12:26 PM
#1
Aspect execute twice for Transactional Service methods
Hi, I want to perform some specific action when a method in a Service is executed. I create an Aspect that intercepts by execution the method, but if Service has Transactional = true the Aspect is executed twice. If Transactional = false the Aspect executes only once as I need.
The code of the Aspect (for testing the problem) is
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*
@Aspect
class TestAspect
{
@Around("execution (* *.*Service.*SM(..))")
Object testExecution (ProceedingJoinPoint method)
{
println "before method"
Object o = method.proceed()
println "after method"
return o
}
}
I debugged the code, when the Aspect is invoked the first time and the Line Object o = method.proceed() is executed, if the Service where the method belongs has Transactional = true, the Aspect reenters provoking double messages before and after.
Can I some how avoid the double execution of the Aspect for Transactional Service?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules