4 Replies Latest reply on Mar 12, 2006 1:05 PM by starksm64

    EJB2 Interceptor Response Values

    tterm

      Hello,

      I don't know if this is the right forum for my question! If it is, sorry about that and maybe point me to the right forum.

      I created some interceptors for the client container and the server container to undertake a generic performance instrumentation for the EJB-container.

      Now the problem:

      The client interceptor puts some values in the invocation object (invocation.setValue(...)) for the server interceptor. The server interceptor should read those values. That's ok until here. But I need some response values from the server interceptor for the client interceptor.

      The AOP interceptors for EJB3 have the addResponseAttachment function. Is this also possible for the EJB2 interceptors?

      I hope my english is understandable and the question is not to bad.

      Thanks in advance
      Thomas

        • 1. Re: EJB2 Interceptor Response Values
          starksm64

          You have to return a value that is unwrapped as the legacy ejb invocation framework has no notion of reply context data.

          • 2. Re: EJB2 Interceptor Response Values
            tterm

            Hello Scott,

            Thank you for your fast response.

            But I don't understand exactly what you mean or how it works. What does this mean to return an unwrapped value. Maybe a small example would help.

            Thanks in advance
            Thomas

            • 3. Re: EJB2 Interceptor Response Values
              tterm

              Hello,

              I tried the following approach:

              I have a wrapper bean class where I can put in the original result from the bean and some other return values which are interessting for the client interceptor. The client interceptor then put the original response object back to the interceptor response.

              // ClientInterceptor invoke method
              public Object invoke(Invocation invocation) {
               Object obj = getNext().invoke(invocation);
               if (obj instance of ResultBean) {
               ResultBean resultBean = (ResultBean)obj;
               obj = resultBean.getOriginalResult();
               }
               return obj;
              }


              Is this a possible solution without to violate something in JBoss?

              Thanks in advance
              Thomas

              • 4. Re: EJB2 Interceptor Response Values
                starksm64

                Yes, this is what I meant by unwrappng the value in the client interceptor.