Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Circular Advice Precedence Error

You will need to move around advice lexically between before and after advice. With the current formation, there is no way for AspectJ to order all three advice and still respect their relative precedence (which in case of advice in a single aspect is determined based on lexical ordering).

-Ramnivas

On Mon, Feb 22, 2010 at 4:47 PM, Candy Chiu <candy.chiu.ad@gmail.com> wrote:
I have two aspects:

public abstract aspect Print {

        declare precedence : Print, *;

public pointcut abstract setOfFunctions( Object o );
before( Object o ) : setOfFunctions( o )  {
System.out.println( "before [" + Thread.currentThread().getName() + "] [" + o + "] " + thisJoinPointStaticPart );
}

after( Object o ) : setOfFunctions( o )  {
System.out.println( "after [" + Thread.currentThread().getName() + "] [" + o + "] "  + thisJoinPointStaticPart );
}
void around( Object o )  : setOfFunctions( o )  {
System.out.println( "around enter [" + Thread.currentThread().getName() + "] [" + o + "] " + thisJoinPointStaticPart );
proceed(o);
System.out.println( "around enter [" + Thread.currentThread().getName() + "] [" + o + "] " + thisJoinPointStaticPart );
}
}

public abstract aspect AbstractReadOnlyConfigurableAspect { 
public interface IReadOnlyConfigurable {
boolean isReadOnly();
}
public abstract pointcut protectedArea( IReadOnlyConfigurable object );

void around( IReadOnlyConfigurable object ) : protectedArea( object )  {
if( object.isReadOnly() ) {
} else {
proceed( object );
}
}
}

Together, they gave me compilation error - circular advice precedence: can't determine precedence between two or more pieces of advice that apply to the same join point: method-execution(void org.talz.domain.Order.setP1(java.lang.String)).

If I comment out the before and after advice in Print, the code compiles.
If I comment out the around advice in Print, the code also compiles.

What is the reason of this behavior?  I'd expect the before advice to execute before the around advices which execute before the after advice.

Thanks!

_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top