Annotations - Defining Precedence
Defining You define precedence in a separate class annotated with @Precedence import org.jboss.aop.Precedence; import org.jboss.aop.PrecedenceInterceptor; @Precedence public class Precedence1 { @PrecedenceInterceptor public static SimpleInterceptor precedenceInterceptor1; @PrecedenceInterceptor public static SimpleInterceptor2 precedenceInterceptor2; } The @PrecedenceInterceptor is used to annotate fields where the type is an interceptor, and the orderings within the class define the relative sort order for the precedence. In other words this class defines that SimpleInterceptor comes before SimpleInterceptor2 Precedence2 also defines a set of precedences: @Precedence public class Precedence2 { @PrecedenceInterceptor public static SimpleInterceptor2 simple2; @PrecedenceAdvice ("advice") public static TestAspect advice; @PrecedenceInterceptor public static SimpleInterceptor3 simple3; @PrecedenceAdvice ("otherAdvice") public static TestAspect otherAdvice; } The @PredenceAdvice is used to annotate fields where the type is an aspect. The attribute value in the @PrecedenceAdvice annotation is the name of the advice method in the aspect, so: SimpleInterceptor2 comes before TestAspect.advice comes before SimpleInterceptor3 comes before TestAspect.otherAdvice The precedence entries are merged into an overall precedence entry, so that: SimpleInterceptor comes before SimpleInterceptor2 comes before TestAspect.advice comes before SimpleInterceptor3 comes before TestAspect.otherAdvice