myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1519808 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow: cdi/DefaultCDIFacesFlowProvider.java impl/DefaultFacesFlowProvider.java
Date Tue, 03 Sep 2013 19:42:49 GMT
Author: lu4242
Date: Tue Sep  3 19:42:49 2013
New Revision: 1519808

URL: http://svn.apache.org/r1519808
Log:
MYFACES-3741 Implement CDI Flow Scope (fix case when return flow is being calculated)

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/impl/DefaultFacesFlowProvider.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java?rev=1519808&r1=1519807&r2=1519808&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/DefaultCDIFacesFlowProvider.java
Tue Sep  3 19:42:49 2013
@@ -40,6 +40,8 @@ public class DefaultCDIFacesFlowProvider
     
     private final static String CURRENT_FLOW_SCOPE_MAP = "oam.flow.SCOPE_MAP";
     
+    static final char SEPARATOR_CHAR = '.';
+    
     @Override
     public Iterator<Flow> getAnnotatedFlows(FacesContext facesContext)
     {
@@ -70,6 +72,9 @@ public class DefaultCDIFacesFlowProvider
             FlowScopeBeanHolder beanHolder = CDIUtils.lookup(beanManager, FlowScopeBeanHolder.class);
             beanHolder.createCurrentFlowScope(context);
         }
+        String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+                flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
+        context.getAttributes().remove(mapKey);
     }
     
     @Override
@@ -81,6 +86,9 @@ public class DefaultCDIFacesFlowProvider
             FlowScopeBeanHolder beanHolder = CDIUtils.lookup(beanManager, FlowScopeBeanHolder.class);
             beanHolder.destroyCurrentFlowScope(context);
         }
+        String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+                flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
+        context.getAttributes().remove(mapKey);
     }
     
     public Map<Object, Object> getCurrentFlowScope(FacesContext facesContext)
@@ -88,14 +96,16 @@ public class DefaultCDIFacesFlowProvider
         Flow flow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
         if (flow != null)
         {
+            String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+                flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
             Map<Object, Object> map = (Map<Object, Object>) facesContext.getAttributes().get(
-                CURRENT_FLOW_SCOPE_MAP);
+                mapKey);
             if (map == null)
             {
                 map = new FlowScopeMap(getBeanManager(), flow.getClientWindowFlowId(
                     facesContext.getExternalContext().getClientWindow()));
                 
-                facesContext.getAttributes().put(CURRENT_FLOW_SCOPE_MAP, map);
+                facesContext.getAttributes().put(mapKey, map);
             }
             return map;
         }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/impl/DefaultFacesFlowProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/impl/DefaultFacesFlowProvider.java?rev=1519808&r1=1519807&r2=1519808&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/impl/DefaultFacesFlowProvider.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/impl/DefaultFacesFlowProvider.java
Tue Sep  3 19:42:49 2013
@@ -54,7 +54,9 @@ public class DefaultFacesFlowProvider ex
     public void doAfterEnterFlow(FacesContext facesContext, Flow flow)
     {
         // Reset current flow scope map
-        facesContext.getAttributes().remove(CURRENT_FLOW_SCOPE_MAP);
+        String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+            flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();        
+        facesContext.getAttributes().remove(mapKey);
     }
 
     @Override
@@ -64,8 +66,10 @@ public class DefaultFacesFlowProvider ex
             facesContext.getExternalContext().getClientWindow());
         String fullToken = FLOW_SESSION_MAP_SUBKEY_PREFIX + SEPARATOR_CHAR + flowMapKey;
 
+        String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+            flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
         Map<Object, Object> map = (Map<Object, Object>) facesContext.getAttributes().get(
-            CURRENT_FLOW_SCOPE_MAP);
+            mapKey);
         if (map != null)
         {
             map.clear();
@@ -83,18 +87,20 @@ public class DefaultFacesFlowProvider ex
         facesContext.getExternalContext().getSessionMap().remove(fullToken);
         
         // Reset current flow scope map
-        facesContext.getAttributes().remove(CURRENT_FLOW_SCOPE_MAP);
+        facesContext.getAttributes().remove(mapKey);
     }
 
     @Override
     public Map<Object, Object> getCurrentFlowScope(FacesContext facesContext)
     {
-        Map<Object, Object> map = (Map<Object, Object>) facesContext.getAttributes().get(
-            CURRENT_FLOW_SCOPE_MAP);
-        if (map == null)
+        Flow flow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
+        Map<Object, Object> map = null;
+        if (flow != null)
         {
-            Flow flow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
-            if (flow != null)
+            String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
+                flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
+            map = (Map<Object, Object>) facesContext.getAttributes().get(mapKey);
+            if (map == null)
             {
                 String flowMapKey = flow.getClientWindowFlowId(
                     facesContext.getExternalContext().getClientWindow());
@@ -103,7 +109,7 @@ public class DefaultFacesFlowProvider ex
                 //String fullToken = FLOW_SESSION_MAP_SUBKEY_PREFIX + SEPARATOR_CHAR + flowMapKey;
                 //map = createOrRestoreMap(facesContext, fullToken);
                 
-                facesContext.getAttributes().put(CURRENT_FLOW_SCOPE_MAP, map);
+                facesContext.getAttributes().put(mapKey, map);
             }
         }
         return map;



Mime
View raw message