2 Replies Latest reply on Dec 15, 2009 6:14 PM by Pete Muir

    interceptor ordering in beans.xml

    Arbi Sookazian Master

      the interceptor ordering is non-global — it is determined by the order in which interceptors are listed at the class
      level.

      source: Weld 1.0.0 ref doc


      <beans
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
      http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
      <interceptors>
      <class>org.mycompany.myapp.SecurityInterceptor</class>
      <class>org.mycompany.myapp.TransactionInterceptor</class>
      </interceptors>
      </beans>



      so the one of the reasons of specifying this markup is so you can enable/disable interceptors in different envmts and specify the global order of execution.


      is there a way to override this global order for specific classes?  Say there's an exceptional use case that requires (hypothetically) that tx interceptor exec prior to security interceptor.  How would I handle that?  Use @Interceptors and specify as follows?:


      @Interceptors({TransactionInterceptor.class, SecurityInterceptor.class})
      public class ShoppingCart {
      public void checkout() { ... }
      }