[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Spring Advice Not getting applied

Hi Ron,

I don't see any beans to which the aspect should be applied. Have you declared those somewhere else?

-Ramnivas

On Tue, Nov 24, 2009 at 7:04 AM, Ron DiFrango <rdifrango@xxxxxxxxxxxxxxxxxxx> wrote:
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?_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users