[jboss-cvs] jboss-seam/src/main/org/jboss/seam/webservice ...

Shane Bryzak sbryzak at redhat.com
Sat Jun 23 22:36:11 EDT 2007


  User: sbryzak2
  Date: 07/06/23 22:36:11

  Modified:    src/main/org/jboss/seam/webservice  SOAPRequestHandler.java
  Log:
  conversation propagation
  
  Revision  Changes    Path
  1.3       +55 -39    jboss-seam/src/main/org/jboss/seam/webservice/SOAPRequestHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SOAPRequestHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/webservice/SOAPRequestHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- SOAPRequestHandler.java	24 Jun 2007 01:52:17 -0000	1.2
  +++ SOAPRequestHandler.java	24 Jun 2007 02:36:11 -0000	1.3
  @@ -13,11 +13,14 @@
   import javax.xml.ws.handler.soap.SOAPHandler;
   import javax.xml.ws.handler.soap.SOAPMessageContext;
   
  -import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.contexts.ServletLifecycle;
  +import org.jboss.seam.core.ConversationPropagation;
  +import org.jboss.seam.core.Manager;
   import org.jboss.seam.log.LogProvider;
   import org.jboss.seam.log.Logging;
  +import org.jboss.seam.servlet.ServletRequestSessionMap;
  +import org.jboss.seam.web.ServletContexts;
   
   /**
    * A SOAP request handler for controling Seam's lifecycle and managing
  @@ -28,12 +31,7 @@
   public class SOAPRequestHandler implements SOAPHandler
   {
      /**
  -    * The MessageContext is stored in event scope under this key
  -    */
  -   public static final String MESSAGE_CONTEXT = "org.jboss.seam.ws.messageContext";
  -   
  -   /**
  -    * The QName for the conversation ID element
  +    * The QName of the conversation ID element in the SOAP request header
       */
      public static final QName CIDQN = new QName("http://www.jboss.org/seam/ws", "conversationId", "seam");
      
  @@ -71,12 +69,14 @@
         {
            HttpServletRequest request = (HttpServletRequest) messageContext.get(MessageContext.SERVLET_REQUEST);      
            ServletLifecycle.beginRequest(request);
  -         Contexts.getEventContext().set(MESSAGE_CONTEXT, messageContext);
  +
  +         ServletContexts.instance().setRequest(request);
            
            String conversationId = extractConversationId(messageContext);
  +         ConversationPropagation.instance().setConversationId( conversationId );
  +         Manager.instance().restoreConversation();
            
  -         // put the clientid in the message context
  -         messageContext.put("conversationId", conversationId);
  +         ServletLifecycle.resumeConversation(request);             
      
            return true;
         }
  @@ -87,47 +87,63 @@
         }
      }
      
  -   private String extractConversationId(MessageContext msgContext)
  -      throws SOAPException
  -   {
  -      SOAPMessageContext smc = (SOAPMessageContext) msgContext;
  -      SOAPHeader header = smc.getMessage().getSOAPHeader();
  -      
  -      Iterator iter = header.getChildElements(CIDQN);
  -      if (iter.hasNext())
  -      {
  -         SOAPElement element = (SOAPElement) iter.next();
  -         return element.getTextContent();
  -      }
  -      else
  -      {
  -         return null;
  -      }
  -   }
  -
      /**
  -    * Our outbound message handler.  This is where we set the outbound conversation ID
  +    * Sets the conversation ID in the outbound SOAP message.
       * 
  -    * @param msgContext The message context
  +    * @param messageContext The message context
       * @return boolean true if processing should continue
       */
  -   public boolean handleOutbound(MessageContext msgContext)
  +   public boolean handleOutbound(MessageContext messageContext)
      {
         try
         {                
  -         SOAPMessageContext smc = (SOAPMessageContext) msgContext;
  +         HttpServletRequest request = (HttpServletRequest) messageContext.get(MessageContext.SERVLET_REQUEST);
  +         
  +         String conversationId = Manager.instance().getCurrentConversationId();
  +         if (conversationId != null)
  +         {
  +            SOAPMessageContext smc = (SOAPMessageContext) messageContext;
            
            SOAPElement element = smc.getMessage().getSOAPHeader().addChildElement(CIDQN);
  -         element.addTextNode(msgContext.get("org.jboss.seam.conversationId").toString());
  +            element.addTextNode(conversationId);
            
            smc.getMessage().saveChanges();
         }
  +         
  +         Manager.instance().endRequest( new ServletRequestSessionMap(request) );
  +         
  +         return true;
  +      }
         catch (SOAPException ex)
         {
  -         throw new IllegalStateException("Cannot handle response", ex);
  +         log.error("Exception processing outbound message", ex);
  +         return false;
  +      }
         }
   
  -      return true;
  +   /**
  +    * Extracts the conversation ID from an incoming SOAP message
  +    * 
  +    * @param messageContext
  +    * @return The conversation ID, or null if there is no conversation ID set
  +    * @throws SOAPException
  +    */
  +   private String extractConversationId(MessageContext messageContext)
  +      throws SOAPException
  +   {
  +      SOAPMessageContext smc = (SOAPMessageContext) messageContext;
  +      SOAPHeader header = smc.getMessage().getSOAPHeader();
  +      
  +      Iterator iter = header.getChildElements(CIDQN);
  +      if (iter.hasNext())
  +      {
  +         SOAPElement element = (SOAPElement) iter.next();
  +         return element.getTextContent();
  +      }
  +      else
  +      {
  +         return null;
  +      }
      }
   
      /**
  
  
  



More information about the jboss-cvs-commits mailing list