I have the following Spring AOP advice and I can't find out why it is called twice:
@Component
@Aspect
public class LoggingAspects {
Logger logger = LoggerFactory.getLogger(LoggingAspects.class);
@AfterReturning(pointcut = "execution(public * com.A.B.C.service.impl.*.browse(..))",
returning = "retVal")
public Object onBrowse(DomainClass retVal) {
logger.info("#######################Advice Called: +retVal);
return null;
}
}
The configuration is as simple as that:
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="loggingCASAspect" class="com.minervanetworks.xtv.stb.service.aspects.LoggingCASAspects"/>
I have also tried the following advice with the same result (called twice).
@AfterReturning(pointcut="@annotation(com.A.B.C.service.impl.LOG)", returning="retVal")
public Object onBrowse(JoinPoint jp, DomainClass retVal) {
logger.info("#######################Advice called! " + jp.toLongString()
+ " Target: " + jp.getTarget()
+ " Signature: " + jp.getSignature()
+ " Kind: " + jp.getKind()
+ " This: " + jp.getThis()
+ " Source Location: " + jp.getSourceLocation());
return null;
}
The debug info from the above logger is:
2011-10-26 11:56:01,887 [INFO][com.A.B.C.service.aspects.LoggingAspects] #######################Advice called! execution(public abstract com.A.B.C.domain.DomainClass com.A.B.C.service.ContentManager.browse(java.lang.String,java.lang.String,java.lang.String,java.lang.Boolean)) Target: com.A.B.C.service.impl.ContentManagerImpl@62ad191 Signature: DomainClass com.A.B.C.service.ContentManager.browse(String,String,String,Boolean) Kind: method-execution This: com.A.B.C.service.impl.ContentManagerImpl@62ad191 Source Location: org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint$SourceLocationImpl@d324de2
It is displayed twice with exactly the same values.