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-1096 project-stage bridge for jsf
Date Mon, 21 Mar 2016 13:05:57 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master a77f4551a -> 53da24237


DELTASPIKE-1096 project-stage bridge for jsf


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

Branch: refs/heads/master
Commit: 53da242376fb19782196eca45076edffd9e9061a
Parents: a77f455
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Mar 21 14:03:17 2016 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon Mar 21 14:03:48 2016 +0100

----------------------------------------------------------------------
 .../InjectionAwareApplicationWrapper.java       | 17 +++++++++++-
 .../request/DeltaSpikeFacesContextWrapper.java  | 28 +++++++++++++++++++-
 2 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/53da2423/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
index 5665739..57dceae 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
@@ -26,6 +26,7 @@ import org.apache.deltaspike.proxy.spi.DeltaSpikeProxy;
 import javax.faces.FacesException;
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationWrapper;
+import javax.faces.application.ProjectStage;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.event.PreDestroyViewMapEvent;
@@ -39,15 +40,18 @@ public class InjectionAwareApplicationWrapper extends ApplicationWrapper
     private final boolean containerManagedValidatorsEnabled;
     private final boolean preDestroyViewMapEventFilterMode;
     private final boolean fullStateSavingFallbackEnabled;
+    private final ProjectStage projectStage;
 
     public InjectionAwareApplicationWrapper(
-        Application wrapped, JsfModuleConfig jsfModuleConfig, boolean preDestroyViewMapEventFilterMode)
+            Application wrapped, JsfModuleConfig jsfModuleConfig, boolean preDestroyViewMapEventFilterMode,
+            ProjectStage projectStage)
     {
         this.wrapped = wrapped;
         this.containerManagedConvertersEnabled = jsfModuleConfig.isContainerManagedConvertersEnabled();
         this.containerManagedValidatorsEnabled = jsfModuleConfig.isContainerManagedValidatorsEnabled();
         this.fullStateSavingFallbackEnabled = jsfModuleConfig.isFullStateSavingFallbackEnabled();
         this.preDestroyViewMapEventFilterMode = preDestroyViewMapEventFilterMode;
+        this.projectStage = projectStage;
     }
 
     @Override
@@ -96,6 +100,17 @@ public class InjectionAwareApplicationWrapper extends ApplicationWrapper
         return managedOrDefaultValidator(this.wrapped.createValidator(validatorId));
     }
 
+
+    @Override
+    public ProjectStage getProjectStage()
+    {
+        if (this.projectStage == null)
+        {
+            return getWrapped().getProjectStage();
+        }
+        return this.projectStage;
+    }
+
     private Validator managedOrDefaultValidator(Validator defaultResult)
     {
         if (!this.containerManagedValidatorsEnabled)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/53da2423/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
index 18578ab..3ee00dd 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
@@ -20,9 +20,11 @@ package org.apache.deltaspike.jsf.impl.listener.request;
 
 import java.lang.annotation.Annotation;
 import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver;
+import org.apache.deltaspike.core.api.projectstage.TestStage;
 import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+import org.apache.deltaspike.core.util.ProjectStageProducer;
 import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
 import org.apache.deltaspike.jsf.impl.config.view.DefaultErrorViewAwareExceptionHandlerWrapper;
 import org.apache.deltaspike.jsf.impl.injection.InjectionAwareApplicationWrapper;
@@ -31,6 +33,7 @@ import org.apache.deltaspike.jsf.impl.message.FacesMessageEntry;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.faces.application.Application;
 import javax.faces.application.FacesMessage;
+import javax.faces.application.ProjectStage;
 import javax.faces.context.ExceptionHandler;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -66,6 +69,7 @@ class DeltaSpikeFacesContextWrapper extends FacesContextWrapper
     private volatile Boolean isNavigationAwareApplicationWrapperActivated;
 
     private boolean preDestroyViewMapEventFilterMode;
+    private ProjectStage projectStage;
 
     DeltaSpikeFacesContextWrapper(FacesContext wrappedFacesContext, ClientWindow clientWindow)
     {
@@ -166,6 +170,28 @@ class DeltaSpikeFacesContextWrapper extends FacesContextWrapper
             this.preDestroyViewMapEventFilterMode = ClassDeactivationUtils.isActivated(SecurityAwareViewHandler.class);
             this.isNavigationAwareApplicationWrapperActivated =
                 ClassDeactivationUtils.isActivated(NavigationHandlerAwareApplication.class);
+            org.apache.deltaspike.core.api.projectstage.ProjectStage dsProjectStage =
+                ProjectStageProducer.getInstance().getProjectStage();
+
+            for (ProjectStage ps : ProjectStage.values())
+            {
+                if (ps.name().equals(dsProjectStage.getClass().getSimpleName()))
+                {
+                    this.projectStage = ps;
+                    break;
+                }
+            }
+
+            if (this.projectStage == null && dsProjectStage instanceof TestStage)
+            {
+                this.projectStage = ProjectStage.Development;
+            }
+
+            if (this.projectStage == null)
+            {
+                this.projectStage = ProjectStage.Production;
+            }
+
             this.initialized = true;
         }
     }
@@ -214,7 +240,7 @@ class DeltaSpikeFacesContextWrapper extends FacesContextWrapper
             wrappedApplication = new NavigationHandlerAwareApplication(wrappedApplication);
         }
         return new InjectionAwareApplicationWrapper(
-            wrappedApplication, this.jsfModuleConfig, this.preDestroyViewMapEventFilterMode);
+            wrappedApplication, this.jsfModuleConfig, this.preDestroyViewMapEventFilterMode,
this.projectStage);
     }
 
     @Override


Mime
View raw message