2 Replies Latest reply on Jan 16, 2013 3:46 AM by Remus Vitan

    InvocationContext propagation between different invocation of same interceptor

    Remus Vitan Newbie


      i have an interceptor that is invoked around methods ejbMethod1 and ejbMethod2

      ejbMethod1calls ejbMethod2 so the stack looks this way : (sort of ...)

      interceptor -> ... -> ejbMethod1 ->  ... - > interceptor -> ... -> ejbMethod2

                          <- ... <-                    <- ... <-                    <- ... <-


      In this kind of stack i would like to put some data in the context data during interceptor execution

      but i want to do it only the most wide interceptor since only there the transaction has ended

      (business logging information, which of course should be logged only if the whole transaction has been commited succesfully)


      of course, the method ejbMethod2 might be called directly so its invocation interceptor is the widest one in that case


      i have found a solution (which i think might work) here :



      does anybody know if this solution is safe ? (managing the chain of contexts using threadlocal, is it guaranteed that the calls will reside in the same thread ?)


      or maybe , is there a well-known solution for this ?