deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-774 map javax.faces.bean.ViewScoped to javax.faces.view.ViewScoped
Date Sun, 09 Nov 2014 22:11:34 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master e29829306 -> 7e4825269


DELTASPIKE-774 map javax.faces.bean.ViewScoped to javax.faces.view.ViewScoped


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

Branch: refs/heads/master
Commit: 7e4825269a2c58ed994974f17b0b30e2f4753d21
Parents: e298293
Author: gpetracek <gpetracek@apache.org>
Authored: Sun Nov 9 22:54:20 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sun Nov 9 23:03:15 2014 +0100

----------------------------------------------------------------------
 .../jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java  |  8 ++++++++
 .../jsf/impl/scope/view/ViewScopedExtension.java         |  7 +++++++
 .../org/apache/deltaspike/jsf/impl/util/JsfUtils.java    | 11 +++++++++++
 3 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7e482526/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java
index 960eaa5..2f92d4c 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/mapped/MappedJsf2ScopeExtension.java
@@ -21,7 +21,9 @@ package org.apache.deltaspike.jsf.impl.scope.mapped;
 import org.apache.deltaspike.core.api.projectstage.ProjectStage;
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.core.util.ProjectStageProducer;
+import org.apache.deltaspike.jsf.impl.util.JsfUtils;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -57,6 +59,12 @@ public class MappedJsf2ScopeExtension implements Extension, Deactivatable
                 javax.enterprise.context.SessionScoped.class);
         this.mappedJsfScopes.put(javax.faces.bean.RequestScoped.class,
                 javax.enterprise.context.RequestScoped.class);
+
+        if (JsfUtils.isViewScopeDelegationEnabled())
+        {
+            this.mappedJsfScopes.put(javax.faces.bean.ViewScoped.class,
+                ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped"));
+        }
     }
 
     protected void init(@Observes BeforeBeanDiscovery beforeBeanDiscovery)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7e482526/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/view/ViewScopedExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/view/ViewScopedExtension.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/view/ViewScopedExtension.java
index 245e43a..303e1fd 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/view/ViewScopedExtension.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/view/ViewScopedExtension.java
@@ -28,6 +28,7 @@ import javax.faces.bean.ViewScoped;
 
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+import org.apache.deltaspike.jsf.impl.util.JsfUtils;
 
 
 /**
@@ -58,6 +59,12 @@ public class ViewScopedExtension implements Extension, Deactivatable
     {
         isActivated = ClassDeactivationUtils.isActivated(getClass());
 
+        if (isActivated)
+        {
+            //this extension is only needed if the cdi-based view-scope handling isn't delegated
to jsf 2.2+
+            isActivated = !JsfUtils.isViewScopeDelegationEnabled();
+        }
+
         if (!isActivated)
         {
             return;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7e482526/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
index 7b1dabf..8e0686f 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
@@ -18,9 +18,11 @@
  */
 package org.apache.deltaspike.jsf.impl.util;
 
+import org.apache.deltaspike.core.api.config.ConfigResolver;
 import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext;
+import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
 import org.apache.deltaspike.jsf.impl.listener.phase.WindowMetaData;
 import org.apache.deltaspike.jsf.impl.message.FacesMessageEntry;
@@ -351,4 +353,13 @@ public abstract class JsfUtils
         }
         return true;
     }
+
+    /**
+     * @return true if JSF 2.2+ is available and the delegation mode isn't deactivated via
config, false otherwise
+     */
+    public static boolean isViewScopeDelegationEnabled()
+    {
+        return ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped") != null &&
!"false".equalsIgnoreCase(
+            ConfigResolver.getPropertyValue("deltaspike.scope.view.delegate", Boolean.TRUE.toString()));
+    }
 }


Mime
View raw message