Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-287

Clarify the order of CDI interceptors wrt. around-invoke method of target class

    XMLWordPrintable

Details

    • Clarification
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 1.0
    • 1.1.PFD
    • Interceptors
    • None

    Description

      Currently, the CDI specification doesn't define, when is the around-invoke method of a target class called, with regard to CDI interceptors.

      The spec. only says, in 9.4, towards the end:

      Interceptors declared using @Interceptors or in ejb-jar.xml are called before interceptors declared using interceptor bindings.

      Currently, the order happens to be (in EAP6):

      1. @Interceptors and ejb-jar.xml
      2. Around-invoke method
      3. CDI interceptors

      In the following example the order of interception would be:

      1. FirstInterceptor
      2. SomeClass.aroundInvoke
      3. ThirdInterceptor

        public class SomeClass {
          @ThirdInterceptorBinding // bound to ThirdInterceptor
          @Interceptors(FirstInterceptor.class)
          public int doSomething() {
            // ...
          }
        
          @AroundInvoke // comes second
          public Object aroundInvoke(InvocationContext invocationContext) throws Exception {
            return invocationContext.proceed();
          }
        }
        

      This problem manifests in this (currently skipped) test:
      https://github.com/weld/core/blob/1.1/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/retry/RetryInterceptorTest.java

      Attachments

        Issue Links

          Activity

            People

              pmuiratbleepbleep Pete Muir
              rsmeral Ron Šmeral (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: