myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r920575 - in /myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator: core/ core/renderkit/ core/startup/ util/
Date Mon, 08 Mar 2010 23:51:45 GMT
Author: gpetracek
Date: Mon Mar  8 23:51:45 2010
New Revision: 920575

URL: http://svn.apache.org/viewvc?rev=920575&view=rev
Log:
[review-result] minor improvements

Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/AbstractStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java?rev=920575&r1=920574&r2=920575&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
Mon Mar  8 23:51:45 2010
@@ -138,6 +138,9 @@
     static final String DEACTIVATE_VALIDATION_PARAMETERS = WebXmlUtils
         .getInitParameter("DEACTIVATE_VALIDATION_PARAMETERS");
 
+    static final String DEACTIVATE_RENDER_KIT_FACTORY = WebXmlUtils
+        .getInitParameter("DEACTIVATE_RENDER_KIT_FACTORY");
+
     //there is nothing like DEACTIVATE_DEFAULT_VALIDATION_INTERCEPTOR
     //use ExtValContext.getContext().denyRendererInterceptor(...) within an extval-StartupListener
 

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java?rev=920575&r1=920574&r2=920575&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
Mon Mar  8 23:51:45 2010
@@ -21,6 +21,7 @@
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
 import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
 import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.ExtValInformation;
@@ -44,6 +45,7 @@
     protected final Log logger = LogFactory.getLog(getClass());
     private RenderKitFactory wrapped;
     private AbstractRenderKitWrapperFactory defaultRenderKitWrapperFactory;
+    private Boolean isDeactivated;
 
     public ExtValRenderKitFactory(RenderKitFactory renderKitFactory)
     {
@@ -57,7 +59,7 @@
 
     public void addRenderKit(String s, RenderKit renderKit)
     {
-        wrapped.addRenderKit(s, renderKit);
+        this.wrapped.addRenderKit(s, renderKit);
     }
 
     public RenderKit getRenderKit(FacesContext facesContext, String s)
@@ -72,6 +74,13 @@
 
         tryToInitDefaultRenderKitWrapperFactory();
 
+        checkRenderKitFactoryDeactivation();
+
+        if(this.isDeactivated)
+        {
+            return renderKit;
+        }
+
         //test early config in case of mojarra
         if(!this.defaultRenderKitWrapperFactory.isApplicationInitialized())
         {
@@ -81,6 +90,21 @@
         return tryToCreateWrapperWithWrapperFactory(renderKit);
     }
 
+    private void checkRenderKitFactoryDeactivation()
+    {
+        if(this.isDeactivated == null)
+        {
+            if(this.defaultRenderKitWrapperFactory.isApplicationInitialized())
+            {
+                this.isDeactivated = isRenderKitFactoryDeactivatedViaWebXml();
+            }
+            else
+            {
+                this.isDeactivated = isRenderKitFactoryDeactivatedViaVMParameter();
+            }
+        }
+    }
+
     private synchronized void tryToInitDefaultRenderKitWrapperFactory()
     {
         if(this.defaultRenderKitWrapperFactory == null)
@@ -119,6 +143,18 @@
 
     public Iterator<String> getRenderKitIds()
     {
-        return wrapped.getRenderKitIds();
+        return this.wrapped.getRenderKitIds();
+    }
+
+    private boolean isRenderKitFactoryDeactivatedViaWebXml()
+    {
+        return "true".equalsIgnoreCase(WebXmlParameter.DEACTIVATE_RENDER_KIT_FACTORY);
+    }
+
+    private boolean isRenderKitFactoryDeactivatedViaVMParameter()
+    {
+        return "true".equalsIgnoreCase(System
+                .getProperty(ExtValInformation.EXTENSIONS_VALIDATOR_BASE_PACKAGE_NAME +
+                    ".DEACTIVATE_RENDER_KIT_FACTORY", "false"));
     }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/AbstractStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/AbstractStartupListener.java?rev=920575&r1=920574&r2=920575&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/AbstractStartupListener.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/AbstractStartupListener.java
Mon Mar  8 23:51:45 2010
@@ -129,7 +129,7 @@
 
     protected boolean isStartupListenerDeactivated()
     {
-        return "true".equalsIgnoreCase(WebXmlUtils.getInitParameter(getClass().getName()
+ ":DEACTIVATED"));
+        return "true".equalsIgnoreCase(WebXmlUtils.getInitParameter(null, getClass().getName()
+ ":DEACTIVATED"));
     }
 
     protected void initProjectStageResolver()
@@ -148,4 +148,4 @@
     }
 
     protected abstract void init();
-}
\ No newline at end of file
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java?rev=920575&r1=920574&r2=920575&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java
Mon Mar  8 23:51:45 2010
@@ -38,7 +38,12 @@
 
     public static String getInitParameter(String prefix, String name)
     {
-        String value = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(prefix
+ "." + name);
+        String parameterName = name;
+        if(prefix != null)
+        {
+            parameterName = prefix + "." + name;
+        }
+        String value = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterName);
         return (value != null) ? value.replace(" ", "").trim() : null;
     }
 }



Mime
View raw message