Hello,

I have created a simple Aspect which logs a method entry and method exit. I have managed to get it to work using schema based AOP support. However the same code does not execute when I change the configuration to use @AspectJ annotation support. Can anyone please explain where I am going wrong with my configuration?

This configuration works:

Code:
<bean id="profiler" class="com.someCompany.someApp.logging.ProfilingAspect" />
<aop:config>
     <aop:aspect ref="profiler">
          <aop:pointcut id="profileServiceMethods" expression="com.someCompany.someApp.SystemArchitecture.businessService()"/>
          <aop:around pointcut-ref="profileServiceMethods" method="profile"/>
     </aop:aspect>
</aop:config>
However, this configuration does not work:

Code:
<aop:aspectj-autoproxy/>
<bean id="profiler" class="com.someCompany.someApp.logging.ProfilingAspect" />
This is my Aspect code which logs the method entry/exit points:
Code:
package com.someCompany.someApp.logging;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class ProfilingAspect {

	@Around("com.someCompany.someApp.SystemArchitecture.businessService()")
    public Object profile(ProceedingJoinPoint pjp) throws Throwable {
	Logger log = LogManager.getLogger(pjp.getSignature().getDeclaringType());
    	long startTimeMillis = System.currentTimeMillis();
    	String methodName = pjp.getSignature().getName();
    	StringBuffer buffer = null;
    	if (log.isTraceEnabled()) {
    		buffer = new StringBuffer("Entering: [");
    		buffer.append(methodName).append("] id: [").append(startTimeMillis).append("]");
    		log.trace(buffer.toString());
    	}
	try {
		return pjp.proceed();
	} finally {
		long totalTimeMillis = System.currentTimeMillis() - startTimeMillis;
		if (log.isTraceEnabled()) {
			buffer = new StringBuffer("Exiting: [");
	    		buffer.append(methodName).append("] id: [").append(startTimeMillis);
	    		buffer.append("] total time: [").append(totalTimeMillis).append(" ms]");
	    		log.trace(buffer.toString());
		}
	}
    }
}
This is my common point cut definition class:

Code:
package com.someCompany.someApp;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class SystemArchitecture {

  @Pointcut("execution(* com.someCompany.someApp.service..*.*(..))")
  public void businessService() {}
}
Thanks in Advance
Al