myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1516682 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: cdi/view/ViewScopeContextExtension.java cdi/view/ViewScopeContextImpl.java flow/cdi/FlowScopeCDIExtension.java flow/cdi/FlowScopedContextImpl.java
Date Fri, 23 Aug 2013 02:49:09 GMT
Author: lu4242
Date: Fri Aug 23 02:49:09 2013
New Revision: 1516682

URL: http://svn.apache.org/r1516682
Log:
MYFACES-3741 Implement CDI Flow Scope and MYFACES-3747 Implement new JSF 2.2 ViewScope specification
(mark FlowScoped and ViewScoped as passivated scopes and remove the bean proxy creation from
the Extension, because Extension and Context could be shared across applications in a shared
environment like TOMEE)

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeCDIExtension.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java?rev=1516682&r1=1516681&r2=1516682&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
Fri Aug 23 02:49:09 2013
@@ -25,7 +25,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
-import org.apache.myfaces.cdi.util.BeanProvider;
+import javax.faces.view.ViewScoped;
 
 /**
  * Handle ViewScope related features.
@@ -39,6 +39,7 @@ public class ViewScopeContextExtension i
     void beforeBeanDiscovery(
         @Observes final BeforeBeanDiscovery event, BeanManager beanManager)
     {
+        event.addScope(ViewScoped.class, true, true);
         // Register ViewScopeBeanHolder as a bean with CDI annotations, so the system
         // can take it into account, and use it later when necessary.
         AnnotatedType bean = beanManager.createAnnotatedType(ViewScopeBeanHolder.class);
@@ -58,9 +59,10 @@ public class ViewScopeContextExtension i
      */
     void initializeViewScopeContexts(@Observes AfterDeploymentValidation adv, BeanManager
beanManager)
     {
+        /*
         ViewScopeBeanHolder viewScopeBeanHolder
             = BeanProvider.getContextualReference(beanManager, ViewScopeBeanHolder.class,
false);
         
-        viewScopeContext.initViewScopeContext(viewScopeBeanHolder);
+        viewScopeContext.initViewScopeContext(viewScopeBeanHolder);*/
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java?rev=1516682&r1=1516681&r2=1516682&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextImpl.java
Fri Aug 23 02:49:09 2013
@@ -30,6 +30,7 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.PassivationCapable;
 import javax.faces.context.FacesContext;
 import javax.faces.view.ViewScoped;
+import org.apache.myfaces.cdi.util.BeanProvider;
 
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.view.ViewScopeProxyMap;
@@ -46,7 +47,7 @@ public class ViewScopeContextImpl implem
     /**
      * Contains the stored WindowScoped contextual instances.
      */
-    private ViewScopeBeanHolder windowBeanHolder;
+    //private ViewScopeBeanHolder windowBeanHolder;
 
     /**
      * needed for serialisation and passivationId
@@ -59,15 +60,36 @@ public class ViewScopeContextImpl implem
         this.beanManager = beanManager;
     }
 
+    protected ViewScopeBeanHolder getViewScopeBeanHolder()
+    {
+        return getViewScopeBeanHolder(FacesContext.getCurrentInstance());
+    }
+    
+    protected ViewScopeBeanHolder getViewScopeBeanHolder(FacesContext facesContext)
+    {
+        ViewScopeBeanHolder viewScopeBeanHolder = (ViewScopeBeanHolder) 
+            facesContext.getExternalContext().getApplicationMap().get(
+                "oam.view.ViewScopeBeanHolder");
+        if (viewScopeBeanHolder == null)
+        {
+            viewScopeBeanHolder = BeanProvider.getContextualReference(
+                beanManager, ViewScopeBeanHolder.class, false);
+            facesContext.getExternalContext().getApplicationMap().put(
+                "oam.flow.FlowScopeBeanHolder", viewScopeBeanHolder);
+        }
+        return viewScopeBeanHolder;
+    }
+
     /**
      * We need to pass the session scoped windowbean holder and the
      * requestscoped windowIdHolder in a later phase because
      * getBeans is only allowed from AfterDeploymentValidation onwards.
      */
+    /*
     void initViewScopeContext(ViewScopeBeanHolder windowBeanHolder)
     {
         this.windowBeanHolder = windowBeanHolder;
-    }
+    }*/
 
     //@Override
     public String getCurrentViewScopeId(boolean create)
@@ -98,7 +120,7 @@ public class ViewScopeContextImpl implem
         }
         if (viewScopeId != null)
         {
-            return windowBeanHolder.getContextualStorage(beanManager, viewScopeId);
+            return getViewScopeBeanHolder().getContextualStorage(beanManager, viewScopeId);
         }
         return null;
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeCDIExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeCDIExtension.java?rev=1516682&r1=1516681&r2=1516682&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeCDIExtension.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeCDIExtension.java
Fri Aug 23 02:49:09 2013
@@ -25,7 +25,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
-import org.apache.myfaces.cdi.util.BeanProvider;
+import javax.faces.flow.FlowScoped;
 
 /**
  *
@@ -38,6 +38,7 @@ public class FlowScopeCDIExtension imple
     void beforeBeanDiscovery(
         @Observes final BeforeBeanDiscovery event, BeanManager beanManager)
     {
+        event.addScope(FlowScoped.class, true, true);
         // Register FlowBuilderFactoryBean as a bean with CDI annotations, so the system
         // can take it into account, and use it later when necessary.
         AnnotatedType bean = beanManager.createAnnotatedType(FlowScopeBeanHolder.class);
@@ -52,9 +53,9 @@ public class FlowScopeCDIExtension imple
     
     void initializeFlowContexts(@Observes AfterDeploymentValidation adv, BeanManager beanManager)
     {
-        FlowScopeBeanHolder flowScopeBeanHolder = BeanProvider.getContextualReference(
-            beanManager, FlowScopeBeanHolder.class, false);
+        //FlowScopeBeanHolder flowScopeBeanHolder = BeanProvider.getContextualReference(
+        //    beanManager, FlowScopeBeanHolder.class, false);
         
-        flowScopedContext.initFlowContext(flowScopeBeanHolder);
+        //flowScopedContext.initFlowContext(flowScopeBeanHolder);
     }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java?rev=1516682&r1=1516681&r2=1516682&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
Fri Aug 23 02:49:09 2013
@@ -32,6 +32,7 @@ import javax.faces.context.FacesContext;
 import javax.faces.flow.Flow;
 import javax.faces.flow.FlowHandler;
 import javax.faces.flow.FlowScoped;
+import org.apache.myfaces.cdi.util.BeanProvider;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.cdi.util.ContextualStorage;
 
@@ -62,7 +63,7 @@ public class FlowScopedContextImpl imple
      */
     private BeanManager beanManager;
 
-    private FlowScopeBeanHolder flowScopeBeanHolder;
+    //private FlowScopeBeanHolder flowScopeBeanHolder;
     
     public FlowScopedContextImpl(BeanManager beanManager)
     {
@@ -70,9 +71,30 @@ public class FlowScopedContextImpl imple
         passivatingScope = beanManager.isPassivatingScope(getScope());
     }
     
+    /*
     public void initFlowContext(FlowScopeBeanHolder flowScopeBeanHolder)
     {
         this.flowScopeBeanHolder = flowScopeBeanHolder;
+    }*/
+    
+    protected FlowScopeBeanHolder getFlowScopeBeanHolder()
+    {
+        return getFlowScopeBeanHolder(FacesContext.getCurrentInstance());
+    }
+    
+    protected FlowScopeBeanHolder getFlowScopeBeanHolder(FacesContext facesContext)
+    {
+        FlowScopeBeanHolder flowScopeBeanHolder = (FlowScopeBeanHolder) 
+            facesContext.getExternalContext().getApplicationMap().get(
+                "oam.flow.FlowScopeBeanHolder");
+        if (flowScopeBeanHolder == null)
+        {
+            flowScopeBeanHolder = BeanProvider.getContextualReference(
+                beanManager, FlowScopeBeanHolder.class, false);
+            facesContext.getExternalContext().getApplicationMap().put(
+                "oam.flow.FlowScopeBeanHolder", flowScopeBeanHolder);
+        }
+        return flowScopeBeanHolder;
     }
     
     public String getCurrentClientWindowFlowId(FacesContext facesContext)
@@ -103,7 +125,7 @@ public class FlowScopedContextImpl imple
             throw new ContextNotActiveException("FlowScopedContextImpl: no current active
flow");
         }
 
-        return flowScopeBeanHolder.getContextualStorage(beanManager, clientWindowFlowId);
+        return getFlowScopeBeanHolder().getContextualStorage(beanManager, clientWindowFlowId);
     }
 
     public Class<? extends Annotation> getScope()
@@ -144,7 +166,7 @@ public class FlowScopedContextImpl imple
         checkActive(facesContext);
 
         
-        List<String> activeFlowMapKeys = flowScopeBeanHolder.getActiveFlowMapKeys(facesContext);
+        List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
         for (String flowMapKey : activeFlowMapKeys)
         {
             ContextualStorage storage = getContextualStorage(false, flowMapKey);
@@ -183,7 +205,7 @@ public class FlowScopedContextImpl imple
             }
         }
 
-        List<String> activeFlowMapKeys = flowScopeBeanHolder.getActiveFlowMapKeys(facesContext);
+        List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
         for (String flowMapKey : activeFlowMapKeys)
         {
             ContextualStorage storage = getContextualStorage(false, flowMapKey);
@@ -230,7 +252,7 @@ public class FlowScopedContextImpl imple
     public boolean destroy(Contextual bean)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        List<String> activeFlowMapKeys = flowScopeBeanHolder.getActiveFlowMapKeys(facesContext);
+        List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
         for (String flowMapKey : activeFlowMapKeys)
         {
             ContextualStorage storage = getContextualStorage(false, flowMapKey);



Mime
View raw message