[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Spring Advice Not getting applied
|
It has been a while since I applied AspectJ to Spring beans. I have the following code:
package com.demo.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class DemoTracingAspect {
@Pointcut("execution(public * *(..))")
public void tracing() {}
@Pointcut("within(com.demo..*)")
public void inDemo() {}
@Around("tracing() && inDemo()")
public Object trace(ProceedingJoinPoint pjp) throws Throwable {
// Log log = LogFactory.getLog(pjp.getClass());
String invocationDescription = getInvocationDescription(pjp);
// log.trace("Entering " + invocationDescription);
System.out.println("Entering " + invocationDescription);
try {
Object rval = pjp.proceed();
// log.trace("Exiting " + invocationDescription);
System.out.println("Exiting " + invocationDescription);
return rval;
} catch (Throwable ex) {
// log.trace("Exception thrown in " + invocationDescription, ex);
System.out.println("Exception thrown in " + invocationDescription
+ "\n" + ex.getStackTrace());
throw ex;
}
}
/**
* Return a description for the given method invocation.
*
* @param invocation
* the invocation to describe
* @return the description
*/
protected String getInvocationDescription(ProceedingJoinPoint thisJoinPoint) {
return "method '" + thisJoinPoint.getSignature().getName()
+ "' of class ["
+ thisJoinPoint.getSignature().getClass().getName() + "]";
}
}
And the following Spring config:
<context:annotation-config/>
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean id="tracingAspect" class="com.demo.aop.DemoTracingAspect"/>
I have tried with & without proxy-target-class and no matter what the Aspect never gets applied.
Thoughts?