Repository: tomee
Updated Branches:
  refs/heads/master f8d9492aa -> a319d9812


starting conversation scope respecting conversation filter - todo: respect 
mapping but not sure it is a good feature


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a319d981
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a319d981
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a319d981

Branch: refs/heads/master
Commit: a319d98120d076f351ddee07b51e1d238e965c53
Parents: f8d9492
Author: Romain Manni-Bucau <[email protected]>
Authored: Sun Mar 22 19:35:23 2015 +0100
Committer: Romain Manni-Bucau <[email protected]>
Committed: Sun Mar 22 19:35:23 2015 +0100

----------------------------------------------------------------------
 .../openejb/cdi/CdiAppContextsService.java      | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/a319d981/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index 7b0f4fe..e6aa8b0 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -68,9 +68,9 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
 
     private static final Logger logger = 
Logger.getInstance(LogCategory.OPENEJB.createChild("cdi"), 
CdiAppContextsService.class);
 
-    private final ThreadLocal<ServletRequestContext> requestContext = new 
ThreadLocal<ServletRequestContext>();
+    private final ThreadLocal<ServletRequestContext> requestContext = new 
ThreadLocal<>();
 
-    private final ThreadLocal<SessionContext> sessionContext = new 
ThreadLocal<SessionContext>();
+    private final ThreadLocal<SessionContext> sessionContext = new 
ThreadLocal<>();
     private final UpdatableSessionContextManager sessionCtxManager = new 
UpdatableSessionContextManager();
 
     /**
@@ -116,7 +116,7 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
             if (conversationService == null) {
                 conversationContext = null;
             } else {
-                conversationContext = new ThreadLocal<ConversationContext>();
+                conversationContext = new ThreadLocal<>();
             }
         } else {
             conversationService = null;
@@ -367,7 +367,7 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
                 final String cid = request.getParameter("cid");
                 if (session != null) {
                     initSessionContext(session);
-                    if (conversationService != null && 
!isConversationSkipped(request)) {
+                    if (autoConversationCheck && conversationService != null 
&& !isConversationSkipped(request)) {
                         if (cid != null) {
                             final ConversationManager conversationManager = 
webBeansContext.getConversationManager();
                             final ConversationImpl c = 
conversationManager.getPropogatedConversation(cid, session.getId());
@@ -381,7 +381,7 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
                     }
                 }
 
-                if (cid == null && !isTimeout()) {
+                if (cid == null && !isTimeout() && !autoConversationCheck) {
                     // transient but active
                     initConversationContext(request);
                 }
@@ -404,6 +404,9 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
                 if (cid != null) {
                     final ConversationManager conversationManager = 
webBeansContext.getConversationManager();
                     final ConversationImpl c = 
conversationManager.getPropogatedConversation(cid, session.getId());
+                    if (!autoConversationCheck) { // lazy association
+                        initConversationContext(rc.getServletRequest());
+                    }
                     if (c != null) {
                         if (c.isTransient()) {
                             throw new IllegalStateException("Conversation " + 
cid + " missing");
@@ -611,12 +614,10 @@ public class CdiAppContextsService extends 
AbstractContextsService implements Co
                 context = existingContext;
             }
         }
-        if (context != null) {
-            conversationContext.set(context);
-            context.setActive(true);
-            if (event != null) {
-                webBeansContext.getBeanManagerImpl().fireEvent(event, 
InitializedLiteral.CONVERSATION);
-            }
+        conversationContext.set(context);
+        context.setActive(true);
+        if (event != null) {
+            webBeansContext.getBeanManagerImpl().fireEvent(event, 
InitializedLiteral.CONVERSATION);
         }
         return context;
     }

Reply via email to