I have the following Spring AOP tip, and I cannot find out why it is called twice:
@Component @Aspect public class LoggingAspects { Logger logger = LoggerFactory.getLogger(LoggingAspects.class); @AfterReturning(pointcut = "execution(public * com.ABCservice.impl.*.browse(..))", returning = "retVal") public Object onBrowse(DomainClass retVal) { logger.info("#######################Advice Called: +retVal); return null; } }
The configuration is just as simple:
<aop:aspectj-autoproxy></aop:aspectj-autoproxy> <bean id="loggingCASAspect" class="com.minervanetworks.xtv.stb.service.aspects.LoggingCASAspects"/>
I also tried the following advice with the same result (twice called).
@AfterReturning(pointcut="@annotation(com.ABCservice.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; }
Debug information from the specified registrar:
2011-10-26 11:56:01,887 [INFO][com.ABCservice.aspects.LoggingAspects] #######################Advice called! execution(public abstract com.ABCdomain.DomainClass com.ABCservice.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.ABCservice.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.
source share