3 Replies Latest reply on Mar 28, 2006 2:39 AM by thomas.diesler

    A handler that needs to be called before the EJB transaction

    ivanneto

      As far as I know, JBossWS handlers are run in the following order on the server-side: pre-handler chain (standard-jbossws-endpoint-config.xml/jbossws-endpoint-config.xml), handlers in webservices.xml, and then the post-handler chain (also in standard-jbossws-endpoint-config.xml/jbossws-endpoint-config.xml). In the case of an EJB 2.1 WS, these handlers are called using a 'HandlerCallback', and this callback is called only after the EJB transaction interceptor (in fact it's called after the TxInterceptorCMT/BMP and CallValidation interceptors). This complies with the JAXRPC 1.1 spec.

      I have a WS-AtomicTransaction handler that needs to be called _before_ the EJB transaction interceptor. I need this to be able to import the transaction context propagated with the SOAP request and bind it to the 'Invocation' that will pass through the EJB interceptor chain. The best place for this kind of handler to run is before the 'Invocation' instance is created, what is done at ServiceEndpointInvokerEJB21.invokeServiceEndpoint(). I've done an ad hoc solution, simply placing a hard-coded call to my handler before the creation of the 'Invocation'; something like:

      ServiceEndpointInvokerEJB21.invokeServiceEndpoint() {
       ...
       SOAPMessageContextImpl msgContext = MessageContextAssociation.peekMessageContext();
       TxServerHandler.handleInbound(msgContext); // My handler
       ...
       // Create the invocation and send it through the MBean server
      }
      


      I wish there was a better way to do so. Is there in JBossWS any handler chain that runs before the EJB transaction interceptor? Any suggestions on how to achieve this?

        • 1. Re: A handler that needs to be called before the EJB transac

          You can implement your own ServiceEndpointInvoker that subclasses from ServiceEndpointInvokerEJB21.

          Simply overwrite

          protected boolean callRequestHandlerChain(ServiceEndpointInfo seInfo)
           {
           // The handler chain is called from the HandlerCallback
           return true;
           }
          
           protected boolean callResponseHandlerChain(ServiceEndpointInfo seInfo)
           {
           // The handler chain is called from the HandlerCallback
           return true;
           }
          
           protected boolean callFaultHandlerChain(ServiceEndpointInfo seInfo, Exception ex)
           {
           // The handler chain is called from the HandlerCallback
           return true;
           }
          


          and insert your TXHandler.

          You'll need to reconfigure JBossWS service.xml in order to use your custom invoker:

          <mbean name="jboss.ws:service=ServiceEndpointManager" code="org.jboss.ws.server.ServiceEndpointManager">
           [...]
          
           <attribute name="ServiceEndpointInvokerEJB21">my.CustomEJB21Invoker</attribute>
           [..]
           </mbean>
          


          • 2. Re: A handler that needs to be called before the EJB transac
            jason.greene

            Yes, we are aware of this problem:

            http://jira.jboss.com/jira/browse/JBWS-737

            We need the ability to control whether a handler should be executed before or after transactional boundaries.


            -Jason

            • 3. Re: A handler that needs to be called before the EJB transac
              thomas.diesler

              I suggest to decouple the handlers in the configuration from the deployment handlers. The config handlers would be executed before the invocation.

              With a JSE the call sematics would not change. With an EJB endpoint, the cofig handlers would be excuted before any EJB interceptor the deployment handlers would be would be excuted triggered from the ServiceEndpointInterceptor (as it is now).

              This issues is also related to

              Dynamically inject ServiceEndpointInterceptor
              http://jira.jboss.com/jira/browse/JBWS-758