myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Tue, 13 Aug 2019 14:49:37 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new ec89242  refactored
ec89242 is described below

commit ec892423e30282d89f4a4dd84d1f4a3db9da2e13
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Aug 13 16:49:29 2019 +0200

    refactored
---
 .../apache/myfaces/config/FacesConfigurator.java   | 39 ++++++----------------
 .../myfaces/el/ELResolverBuilderForFaces.java      |  2 +-
 .../el/resolver/CompositeComponentELResolver.java  | 10 +++++-
 .../myfaces/renderkit/html/HtmlHeadRenderer.java   | 10 ++++--
 .../myfaces/renderkit/html/HtmlRenderKitImpl.java  |  2 +-
 .../renderkit/html/base/HtmlFormRendererBase.java  | 15 ++++++---
 .../renderkit/html/base/HtmlLinkRendererBase.java  | 11 ++++--
 .../myfaces/view/facelets/ViewPoolProcessor.java   |  2 +-
 .../CompositeComponentBeanValidationTest.java      |  3 +-
 9 files changed, 51 insertions(+), 43 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
index 6b9aae8..1599537 100755
--- a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
@@ -194,6 +194,7 @@ public class FacesConfigurator
     private FacesConfigData _dispenser;
 
     private RuntimeConfig _runtimeConfig;
+    private MyfacesConfig _myfacesConfig;
     
     private Application _application;
     
@@ -216,6 +217,9 @@ public class FacesConfigurator
         {
             _externalContext.getApplicationMap().put(INJECTED_BEAN_STORAGE_KEY, new CopyOnWriteArrayList());
         }
+        
+        _myfacesConfig = MyfacesConfig.getCurrentInstance(_externalContext);
+        _runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
     }
 
     /**
@@ -664,13 +668,9 @@ public class FacesConfigurator
         application.setSearchExpressionHandler(ClassUtils.buildApplicationObject(SearchExpressionHandler.class,
                 dispenser.getSearchExpressionHandlerIterator(),
                 application.getSearchExpressionHandler()));
-        
-        RuntimeConfig runtimeConfig = getRuntimeConfig();
-        
+                
         for (SystemEventListener systemEventListener : dispenser.getSystemEventListeners())
         {
-
-
             try
             {
                 //note here used to be an instantiation to deal with the explicit source
type in the registration,
@@ -684,7 +684,7 @@ public class FacesConfigurator
                 javax.faces.event.SystemEventListener listener = (javax.faces.event.SystemEventListener)

                         ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass());
                 _callInjectAndPostConstruct(listener);
-                runtimeConfig.addInjectedObject(listener);
+                _runtimeConfig.addInjectedObject(listener);
                 if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length()
> 0)
                 {
                     application.subscribeToEvent(
@@ -804,7 +804,7 @@ public class FacesConfigurator
                 for (String contract : mapping.getContractList())
                 {
                     String[] contracts = StringUtils.trim(StringUtils.splitShortString(contract,
' '));
-                    runtimeConfig.addContractMapping(urlPattern, contracts);
+                    _runtimeConfig.addContractMapping(urlPattern, contracts);
                 }
             }
         }
@@ -840,21 +840,6 @@ public class FacesConfigurator
         }
     }
 
-
-    protected RuntimeConfig getRuntimeConfig()
-    {
-        if (_runtimeConfig == null)
-        {
-            _runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
-        }
-        return _runtimeConfig;
-    }
-
-    public void setRuntimeConfig(RuntimeConfig runtimeConfig)
-    {
-        _runtimeConfig = runtimeConfig;
-    }
-
     private void configureRuntimeConfig()
     {
         RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
@@ -932,8 +917,7 @@ public class FacesConfigurator
             }
         }
 
-        String elResolverComparatorClass =
-                MyfacesConfig.getCurrentInstance(_externalContext).getElResolverComparator();
+        String elResolverComparatorClass = _myfacesConfig.getElResolverComparator();
         if (elResolverComparatorClass != null && !elResolverComparatorClass.isEmpty())
         {
             try
@@ -958,8 +942,7 @@ public class FacesConfigurator
             runtimeConfig.setELResolverComparator(null);
         }
 
-        String elResolverPredicateClass =
-                MyfacesConfig.getCurrentInstance(_externalContext).getElResolverPredicate();
+        String elResolverPredicateClass = _myfacesConfig.getElResolverPredicate();
         if (elResolverPredicateClass != null && !elResolverPredicateClass.isEmpty())
         {
             try
@@ -1250,8 +1233,8 @@ public class FacesConfigurator
 
             // if ProjectStage is Development, install the DebugPhaseListener
             FacesContext facesContext = getFacesContext();
-            if (facesContext.isProjectStage(ProjectStage.Development) &&
-                    MyfacesConfig.getCurrentInstance(facesContext).isDebugPhaseListenerEnabled())
+            if (facesContext.isProjectStage(ProjectStage.Development)
+                    && _myfacesConfig.isDebugPhaseListenerEnabled())
             {
                 lifecycle.addPhaseListener(new DebugPhaseListener());
             }
diff --git a/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilderForFaces.java b/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilderForFaces.java
index 0c0376d..f294922 100644
--- a/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilderForFaces.java
+++ b/impl/src/main/java/org/apache/myfaces/el/ELResolverBuilderForFaces.java
@@ -101,7 +101,7 @@ public class ELResolverBuilderForFaces extends ELResolverBuilder
             list.add(ImplicitObjectResolver.makeResolverForFaces());
         }
             
-        list.add(new CompositeComponentELResolver());
+        list.add(new CompositeComponentELResolver(config));
 
         addFromRuntimeConfig(list);
 
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/CompositeComponentELResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/CompositeComponentELResolver.java
index 9d25ff5..4eab220 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/CompositeComponentELResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/CompositeComponentELResolver.java
@@ -52,6 +52,13 @@ public final class CompositeComponentELResolver extends ELResolver
     
     private static final String COMPOSITE_COMPONENT_ATTRIBUTES_MAPS = 
         "org.apache.myfaces.COMPOSITE_COMPONENT_ATTRIBUTES_MAPS";
+    
+    private MyfacesConfig myfacesConfig;
+    
+    public CompositeComponentELResolver(MyfacesConfig myfacesConfig)
+    {
+        this.myfacesConfig = myfacesConfig;
+    }
 
     @Override
     public Class<?> getCommonPropertyType(ELContext context, Object base)
@@ -84,7 +91,8 @@ public final class CompositeComponentELResolver extends ELResolver
             {
                 return null;
             }
-            if (!MyfacesConfig.getCurrentInstance(facesContext).isStrictJsf2CCELResolver())
+
+            if (!myfacesConfig.isStrictJsf2CCELResolver())
             {
                 // handle JSF 2.2 spec revisions:
                 // code resembles that found in Mojarra because it originates from
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
index 644539b..9d829d4 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
@@ -48,6 +48,13 @@ public class HtmlHeadRenderer extends Renderer
     private final static String[] HEAD_PASSTHROUGH_ATTRIBUTES = { HTML.DIR_ATTR,
             HTML.LANG_ATTR, PROFILE_ATTR};
 
+    private MyfacesConfig myfacesConfig;
+    
+    public HtmlHeadRenderer()
+    {
+        myfacesConfig = MyfacesConfig.getCurrentInstance();
+    }
+    
     @Override
     public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
     {
@@ -77,8 +84,7 @@ public class HtmlHeadRenderer extends Renderer
         
         writer.endElement(HTML.HEAD_ELEM);
 
-        if (MyfacesConfig.getCurrentInstance(facesContext).isEarlyFlushEnabled()
-                && facesContext.isProjectStage(ProjectStage.Production))
+        if (myfacesConfig.isEarlyFlushEnabled() && facesContext.isProjectStage(ProjectStage.Production))
         {
             writer.flush();
         }
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
index 9b4f333..5cc2c6c 100755
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
@@ -70,7 +70,7 @@ public class HtmlRenderKitImpl extends RenderKit implements LazyRenderKit
         _renderers = new ConcurrentHashMap<>(64, 0.75f, 1);
         _responseStateManager = new HtmlResponseStateManager();
         _clientBehaviorRenderers = new HashMap<>();
-        myfacesConfig = MyfacesConfig.getCurrentInstance(FacesContext.getCurrentInstance());
+        myfacesConfig = MyfacesConfig.getCurrentInstance();
     }
 
     // ~ Methods ------------------------------------------------------------------------------------
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlFormRendererBase.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlFormRendererBase.java
index c04a072..bb2b0a3 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlFormRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlFormRendererBase.java
@@ -49,6 +49,13 @@ public class HtmlFormRendererBase extends HtmlRenderer
 
     private static final String SHARED_STRING_BUILDER = HtmlFormRendererBase.class.getName()
+ ".SHARED_STRING_BUILDER";
     
+    private MyfacesConfig myfacesConfig;
+    
+    public HtmlFormRendererBase()
+    {
+        myfacesConfig = MyfacesConfig.getCurrentInstance();
+    }
+    
     @Override
     public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
     {
@@ -145,9 +152,8 @@ public class HtmlFormRendererBase extends HtmlRenderer
         // included for backward compatibility to the 1.1.1 patch (JIRA MYFACES-1276)
         // However, might be needed in the future
         beforeFormElementsStart(facesContext, component);
-        
-        MyfacesConfig config = MyfacesConfig.getCurrentInstance(facesContext);
-        if (config.isRenderFormViewStateAtBegin())
+
+        if (myfacesConfig.isRenderFormViewStateAtBegin())
         {
             renderViewStateAndHiddenFields(facesContext, component);
         }
@@ -177,8 +183,7 @@ public class HtmlFormRendererBase extends HtmlRenderer
 
         beforeFormElementsEnd(facesContext, component);
 
-        MyfacesConfig config = MyfacesConfig.getCurrentInstance(facesContext);
-        if (!config.isRenderFormViewStateAtBegin())
+        if (!myfacesConfig.isRenderFormViewStateAtBegin())
         {
             renderViewStateAndHiddenFields(facesContext, component);
         }
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
index 8377aa9..4d5ef12 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
@@ -64,6 +64,13 @@ public abstract class HtmlLinkRendererBase extends HtmlRenderer
     private static final String SB_ADD_CHILD_PARAMETERS = HtmlLinkRendererBase.class.getName()
+
             "#addChildParameters";
 
+    private MyfacesConfig myfacesConfig;
+    
+    public HtmlLinkRendererBase()
+    {
+        myfacesConfig = MyfacesConfig.getCurrentInstance();
+    }
+    
     @Override
     public boolean getRendersChildren()
     {
@@ -703,8 +710,6 @@ public abstract class HtmlLinkRendererBase extends HtmlRenderer
                                           String charEncoding)
             throws IOException
     {
-        boolean strictXhtmlLinks
-                = MyfacesConfig.getCurrentInstance(facesContext).isStrictXhtmlLinks();
         List<UIComponent> childrenList = null;
         if (getChildCount(linkComponent) > 0)
         {
@@ -722,7 +727,7 @@ public abstract class HtmlLinkRendererBase extends HtmlRenderer
             UIParameter param = validParams.get(i);
             String name = param.getName();
             Object value = param.getValue();
-            addParameterToHref(name, value, hrefBuf, firstParameter, charEncoding, strictXhtmlLinks);
+            addParameterToHref(name, value, hrefBuf, firstParameter, charEncoding, myfacesConfig.isStrictXhtmlLinks());
             firstParameter = false;
         }
     }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/ViewPoolProcessor.java b/impl/src/main/java/org/apache/myfaces/view/facelets/ViewPoolProcessor.java
index 1b8ec22..14908be 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/ViewPoolProcessor.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/ViewPoolProcessor.java
@@ -190,7 +190,7 @@ public class ViewPoolProcessor
                 initialize = false;
             }
             
-            if (MyfacesConfig.getCurrentInstance(context).isStrictJsf2FaceletsCompatibility())
+            if (myfacesConfig.isStrictJsf2FaceletsCompatibility())
             {
                 Logger.getLogger(ViewPoolProcessor.class.getName()).log(
                     Level.INFO, MyfacesConfig.STRICT_JSF_2_FACELETS_COMPATIBILITY +
diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
index bf7b640..8d1b237 100644
--- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
+++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
@@ -24,6 +24,7 @@ import javax.el.ValueExpression;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import javax.faces.el.CompositeComponentExpressionHolder;
+import org.apache.myfaces.config.MyfacesConfig;
 
 import org.apache.myfaces.el.resolver.CompositeComponentELResolver;
 import org.apache.myfaces.view.facelets.FaceletTestCase;
@@ -59,7 +60,7 @@ public class CompositeComponentBeanValidationTest extends FaceletTestCase
         UIComponent compositeComponent = form.getChildren().get(0);
 
         // "resolve" #{cc.attrs}
-        CompositeComponentELResolver resolver = new CompositeComponentELResolver();
+        CompositeComponentELResolver resolver = new CompositeComponentELResolver(MyfacesConfig.getCurrentInstance());
         Object attrs = resolver.getValue(facesContext.getELContext(), compositeComponent,
"attrs");
         
         // the resolved value has to be a CompositeComponentExpressionHolder


Mime
View raw message