[seam-commits] Seam SVN: r11874 - in modules/remoting/trunk/src/main: resources/org/jboss/seam/remoting and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Dec 22 04:21:04 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-12-22 04:21:03 -0500 (Tue, 22 Dec 2009)
New Revision: 11874

Modified:
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
   modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
fixed conversation management stuff, now we just need a transaction...


Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java	2009-12-22 02:19:09 UTC (rev 11873)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java	2009-12-22 09:21:03 UTC (rev 11874)
@@ -9,7 +9,6 @@
 import java.util.Set;
 
 import javax.enterprise.context.Conversation;
-import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
@@ -24,7 +23,6 @@
 import org.jboss.seam.remoting.RequestContext;
 import org.jboss.seam.remoting.RequestHandler;
 import org.jboss.seam.remoting.wrapper.Wrapper;
-import org.jboss.seam.remoting.wrapper.WrapperFactory;
 import org.jboss.weld.Container;
 import org.jboss.weld.context.ContextLifecycle;
 import org.jboss.weld.context.ConversationContext;
@@ -45,7 +43,7 @@
    @Inject BeanManager beanManager;
    @Inject ConversationManager conversationManager;
    @Inject ModelRegistry registry;
-   @Inject Instance<Conversation> conversationInstance;
+   @Inject Conversation conversation;
    
    @SuppressWarnings("unchecked")
    public void handle(HttpServletRequest request, HttpServletResponse response)
@@ -73,19 +71,21 @@
             
       ConversationContext conversationContext = null;
       try
-      {
+      {         
          // Initialize the conversation context
          conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
-         conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
-         conversationContext.setActive(true);  
          
          if (ctx.getConversationId() != null && !ctx.getConversationId().isEmpty())
          { 
+            conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
+            conversationContext.setActive(true);  
             conversationManager.beginOrRestoreConversation(ctx.getConversationId());
          }
          else
          {
-            conversationManager.beginOrRestoreConversation(null);
+            conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), 
+                  ((org.jboss.weld.conversation.ConversationImpl) conversation).getUnderlyingId()));
+            conversationContext.setActive(true);
          }
          
          Set<Model> models = new HashSet<Model>(); 
@@ -109,13 +109,13 @@
          {
             if (model.getAction() != null && model.getAction().getException() != null)
             {
-               out.write(ENVELOPE_TAG_OPEN);
-               out.write(BODY_TAG_OPEN);         
+               response.getOutputStream().write(ENVELOPE_TAG_OPEN);
+               response.getOutputStream().write(BODY_TAG_OPEN);         
                MarshalUtils.marshalException(model.getAction().getException(), 
-                     model.getAction().getContext(), out);
-               out.write(BODY_TAG_CLOSE);
-               out.write(ENVELOPE_TAG_CLOSE);
-               out.flush();
+                     model.getAction().getContext(), response.getOutputStream());
+               response.getOutputStream().write(BODY_TAG_CLOSE);
+               response.getOutputStream().write(ENVELOPE_TAG_CLOSE);
+               response.getOutputStream().flush();
                return;
             }
          }
@@ -125,12 +125,12 @@
             model.evaluate();
          }
          
-         Conversation conversation = conversationInstance.get();
-         ctx.setConversationId(conversation.getId());      
+         ctx.setConversationId(conversation.isTransient() ? null : conversation.getId());
          marshalResponse(models, ctx, response.getOutputStream());
       }
       finally
       {
+         conversationManager.cleanupConversation();
          if (conversationContext != null)
          {
             conversationContext.setBeanStore(null);
@@ -217,6 +217,7 @@
       throws Exception
    {
       Model model = registry.getModel(modelElement.attributeValue("uid"));
+      models.add(model);
       model.setCallId(callId); 
       model.setAction(null);
       

Modified: modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js	2009-12-22 02:19:09 UTC (rev 11873)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js	2009-12-22 09:21:03 UTC (rev 11874)
@@ -472,10 +472,9 @@
     var contextNode = cn(headerNode, "context");
     if (contextNode) {
       Seam.unmarshalContext(contextNode, ctx);
-      if (ctx.getConversationId() && Seam.context.getConversationId() == null)
-        Seam.context.setConversationId(ctx.getConversationId());
     }
   }
+  Seam.context.setConversationId(ctx.getConversationId() ? ctx.getConversationId() : null);  
   if (bodyNode) {
     var n = cn(bodyNode, "result");
     if (n) {



More information about the seam-commits mailing list