openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1648255 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
Date Sun, 28 Dec 2014 21:29:02 GMT
Author: rmannibucau
Date: Sun Dec 28 21:29:01 2014
New Revision: 1648255

URL: http://svn.apache.org/r1648255
Log:
starting conversation scope if needed when begin is called

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java?rev=1648255&r1=1648254&r2=1648255&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationImpl.java
Sun Dec 28 21:29:01 2014
@@ -143,7 +143,7 @@ public class ConversationImpl implements
                 //Gets current conversation context instance.
                 //Each conversation has its own conversation context instance.
                 //Sets at the beginning of each JSF request.
-                manager.addConversationContext(this, (ConversationContext) webBeansContext.getBeanManagerImpl().getContext(ConversationScoped.class));
+                manager.addConversationContext(this, getOrStartConversationScope());
                 
             }
             catch (ContextNotActiveException cnae)
@@ -163,7 +163,22 @@ public class ConversationImpl implements
             throw new IllegalStateException();
         }
     }
-    
+
+    private ConversationContext getOrStartConversationScope()
+    {
+        ConversationContext context = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class);
+        if (context == null)
+        {
+            webBeansContext.getContextsService().startContext(ConversationScoped.class, null);
+            context = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class);
+        }
+        if (!context.isActive())
+        {
+            context.setActive(true);
+        }
+        return context;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -191,7 +206,8 @@ public class ConversationImpl implements
                 }
             }
             updateTimeOut();
-            conversationManager.addConversationContext(this, (ConversationContext) webBeansContext.getBeanManagerImpl().getContext(ConversationScoped.class));
+
+            conversationManager.addConversationContext(this, getOrStartConversationScope());
         }
     }
     



Mime
View raw message