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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Dec 10 05:56:24 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-12-10 05:56:24 -0500 (Thu, 10 Dec 2009)
New Revision: 11805

Modified:
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Call.java
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/MarshalUtils.java
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
Log:
fix model fetch response


Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Call.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Call.java	2009-12-10 10:55:30 UTC (rev 11804)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Call.java	2009-12-10 10:56:24 UTC (rev 11805)
@@ -174,8 +174,8 @@
    {
       CreationalContext ctx = beanManager.createCreationalContext(targetBean);
       
-      // Create an instance of the component
-      Object instance = targetBean.create(ctx); 
+      // Get an instance of the component
+      Object instance = beanManager.getReference(targetBean, targetBean.getBeanClass(), ctx);;      
 
       if (instance == null)
       {

Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/MarshalUtils.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/MarshalUtils.java	2009-12-10 10:55:30 UTC (rev 11804)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/MarshalUtils.java	2009-12-10 10:56:24 UTC (rev 11805)
@@ -26,6 +26,10 @@
 
    private static final byte[] VALUE_TAG_OPEN = "<value>".getBytes();
    private static final byte[] VALUE_TAG_CLOSE = "</value>".getBytes();
+   
+   private static final byte[] ALIASED_VALUE_TAG_OPEN_START = "<value alias=\"".getBytes();
+   private static final byte[] ALIASED_VALUE_TAG_OPEN_END = "\">".getBytes();
+   private static final byte[] ALIASED_VALUE_TAG_CLOSE = "</value>".getBytes();
 
    private static final byte[] EXCEPTION_TAG_OPEN = "<exception>".getBytes();
    private static final byte[] EXCEPTION_TAG_CLOSE = "</exception>".getBytes();
@@ -87,10 +91,12 @@
       {
          Model.BeanProperty property = model.getBeanProperties().get(alias);
          
-         out.write(VALUE_TAG_OPEN);
+         out.write(ALIASED_VALUE_TAG_OPEN_START);
+         out.write(alias.getBytes());
+         out.write(ALIASED_VALUE_TAG_OPEN_END);
          model.getCallContext().createWrapperFromObject(property.getValue(), "")
             .marshal(out);
-         out.write(VALUE_TAG_CLOSE);         
+         out.write(ALIASED_VALUE_TAG_CLOSE);         
       }      
 
       out.write(RequestHandler.REFS_TAG_OPEN);

Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java	2009-12-10 10:55:30 UTC (rev 11804)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java	2009-12-10 10:56:24 UTC (rev 11805)
@@ -49,8 +49,8 @@
       
       @SuppressWarnings("unchecked")
       public void evaluate(CreationalContext ctx)
-      {
-         Object instance = bean.create(ctx);
+      {         
+         Object instance = beanManager.getReference(bean, bean.getBeanClass(), ctx);
          
          if (propertyName != null)
          {
@@ -120,8 +120,7 @@
     * store the values in the BeanProperty map.
     */
    public void evaluate()
-   {
-      
+   {      
       for (String alias : beanProperties.keySet())
       {         
          BeanProperty property = beanProperties.get(alias);

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-10 10:55:30 UTC (rev 11804)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java	2009-12-10 10:56:24 UTC (rev 11805)
@@ -1,5 +1,7 @@
 package org.jboss.seam.remoting.model;
 
+import static org.jboss.weld.jsf.JsfHelper.getHttpSession;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -13,6 +15,7 @@
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 
 import org.dom4j.Document;
 import org.dom4j.Element;
@@ -22,7 +25,11 @@
 import org.jboss.seam.remoting.RequestContext;
 import org.jboss.seam.remoting.RequestHandler;
 import org.jboss.seam.remoting.wrapper.Wrapper;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.ConversationContext;
 import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.servlet.ConversationBeanStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,11 +70,20 @@
       Document doc = xmlReader.read(new StringReader(requestData));
       final Element env = doc.getRootElement();
       final RequestContext ctx = new RequestContext(env.element("header"));
+            
+      // Initialize the conversation context
+      ConversationContext 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())
       { 
          conversationManager.beginOrRestoreConversation(ctx.getConversationId());
       }
+      else
+      {
+         conversationManager.beginOrRestoreConversation(null);
+      }
       
       Set<Model> models = new HashSet<Model>();
       Call action = null;      
@@ -154,6 +170,11 @@
       }      
       else
       {      
+         for (Model model : models)
+         {
+            model.evaluate();
+         }
+         
          ctx.setConversationId(conversation.getId());      
          marshalResponse(models, ctx, response.getOutputStream());
       }



More information about the seam-commits mailing list