Change the advice order to after/before/around:
@Aspect
abstract class ProfilingAbstractAspect {
@Pointcut
public abstract void afterScope();
@Pointcut
public abstract void beforeScope();
@Pointcut
public abstract void aroundScope();
@After("afterScope()")
public void afterProfile() {
System.out.println("after");
}
@Before("beforeScope()")
public void beginProfile(JoinPoint jp) {
System.out.println("before");
}
@Around("aroundScope()")
public Object aroundProfile(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("around");
return pjp.proceed();
}
}
There is some discussion of this here:
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02138.html
and links to bugs from the post following that:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=30439
https://bugs.eclipse.org/bugs/show_bug.cgi?id=40655
Andy
2009/7/16 Dan Becker <[email protected]>
> How does one get rid the circular advice precedence error when the pointcut
> points to a single method, and the concrete-aspect comes from a single
> Advice class?
>
> The error:
> "error at myPath\ProfilingAbstractAspect.java::0 circular advice
> precedence: can't determine precedence between two or more pieces of advice
> that apply to the same join point"
>
> The advice class:
> @Aspect
> public abstract class ProfilingAbstractAspect {
> @Pointcut
> public abstract void beforeScope();
> @Pointcut
> public abstract void afterScope();
> @Pointcut
> public abstract void aroundScope();
>
> @Before("beforeScope()")
> public void beginProfile(JoinPoint jp) {
> ...
> }
> @After("afterScope()")
> public void afterProfile() {
> ...
> }
> @Around("aroundScope()")
> public Object aroundProfile(ProceedingJoinPoint pjp) throws Throwable {
> ...
> }
> }
>
>
> The aop.xml definition of concrete aspects and join point:
> <aspects>
> <concrete-aspect name="myPath.ProfilingServlet"
> extends="myPath.ProfilingAbstractAspect">
> <pointcut name="beforeScope" expression="execution(*
> myPath.Servlet.doService(..))"
> precedence="myPath.ProfilingAbstractAspect,*"/>
> <pointcut name="afterScope" expression="execution(*
> myPath.Servlet.doService(..))"
> precedence="myPath.ProfilingAbstractAspect,*"/>
> <pointcut name="aroundScope" expression="execution(*
> myPath.Servlet.doService(..))"
> precedence="myPath.ProfilingAbstractAspect,*"/>
> </concrete-aspect>
> </aspects>
>
> --
> Thanks, Dan
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users