You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/08/02 11:28:01 UTC

[myfaces] branch master updated (30efb69 -> 2e88c9e)

This is an automated email from the ASF dual-hosted git repository.

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


    from 30efb69  cosmetics
     new 6f5cf6b  cosmetics
     new 2e88c9e  cosmetics

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../myfaces/application/ResourceHandlerImpl.java   |  2 +-
 .../apache/myfaces/cdi/FacesScopeBeanHolder.java   |  2 +-
 .../cdi/view/ViewTransientScopeBeanHolder.java     |  4 +-
 .../apache/myfaces/context/RequestViewContext.java | 68 ++++++++--------------
 .../jsf/ComponentRelocatableResourceHandler.java   |  5 +-
 .../view/facelets/tag/jsf/ComponentSupport.java    | 15 +++--
 6 files changed, 39 insertions(+), 57 deletions(-)


[myfaces] 02/02: cosmetics

Posted by ta...@apache.org.
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

commit 2e88c9e4733c6becf69e45f8cc249255f21316d4
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Fri Aug 2 13:27:53 2019 +0200

    cosmetics
---
 .../apache/myfaces/context/RequestViewContext.java | 68 ++++++++--------------
 1 file changed, 25 insertions(+), 43 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/context/RequestViewContext.java b/impl/src/main/java/org/apache/myfaces/context/RequestViewContext.java
index e9464ec..2e29ddd 100644
--- a/impl/src/main/java/org/apache/myfaces/context/RequestViewContext.java
+++ b/impl/src/main/java/org/apache/myfaces/context/RequestViewContext.java
@@ -60,79 +60,64 @@ public class RequestViewContext
         this.requestViewMetadata = new RequestViewMetadata();
     }
 
-    static public RequestViewContext getCurrentInstance()
+    public static RequestViewContext getCurrentInstance()
     {
-        FacesContext ctx = FacesContext.getCurrentInstance();
-        return getCurrentInstance(ctx);
+        return getCurrentInstance(FacesContext.getCurrentInstance());
     }
     
-    static public RequestViewContext getCurrentInstance(FacesContext ctx)
+    public static RequestViewContext getCurrentInstance(FacesContext ctx)
     {
         return getCurrentInstance(ctx, ctx.getViewRoot());
     }
     
     @SuppressWarnings("unchecked")
-    static public RequestViewContext getCurrentInstance(FacesContext ctx, UIViewRoot root)
+    public static RequestViewContext getCurrentInstance(FacesContext ctx, UIViewRoot root)
     {
-        Map<UIViewRoot, RequestViewContext> map
-                = (Map<UIViewRoot, RequestViewContext>) ctx.getAttributes().get(VIEW_CONTEXT_KEY);
-        RequestViewContext rvc = null;        
-        if (map == null)
+        return getCurrentInstance(ctx, root, true);
+    }
+    
+    public static RequestViewContext getCurrentInstance(FacesContext ctx, UIViewRoot root, boolean create)
+    {
+        Map<UIViewRoot, RequestViewContext> map =
+                (Map<UIViewRoot, RequestViewContext>) ctx.getAttributes().get(VIEW_CONTEXT_KEY);
+        
+        if (create && map == null)
         {
             map = new HashMap<>();
-            rvc = new RequestViewContext();
-            map.put(root, rvc);
             ctx.getAttributes().put(VIEW_CONTEXT_KEY, map);
-            return rvc;
         }
-        else
+
+        if (map != null)
         {
-            rvc = map.get(root); 
-            if (rvc == null)
+            RequestViewContext rvc = map.get(root); 
+            if (create && rvc == null)
             {
                 rvc = new RequestViewContext();
                 map.put(root, rvc);
             }
             return rvc;
         }
-    }
-    
-    static public RequestViewContext getCurrentInstance(FacesContext ctx, UIViewRoot root, boolean create)
-    {
-        if (create)
-        {
-            return getCurrentInstance(ctx, root);
-        }
-        Map<UIViewRoot, RequestViewContext> map
-                = (Map<UIViewRoot, RequestViewContext>) ctx.getAttributes().get(VIEW_CONTEXT_KEY);
-        if (map != null)
-        {
-            return map.get(root);
-        }
+
         return null;
     }
     
-    static public RequestViewContext newInstance(RequestViewMetadata rvm)
+    public static RequestViewContext newInstance(RequestViewMetadata rvm)
     {
         RequestViewContext clone = new RequestViewContext(rvm.cloneInstance());
         return clone;
     }
     
-    static public void setCurrentInstance(FacesContext ctx, UIViewRoot root, RequestViewContext rvc)
+    public static void setCurrentInstance(FacesContext ctx, UIViewRoot root, RequestViewContext rvc)
     {
         Map<UIViewRoot, RequestViewContext> map
                 = (Map<UIViewRoot, RequestViewContext>) ctx.getAttributes().get(VIEW_CONTEXT_KEY);
         if (map == null)
         {
             map = new HashMap<>();
-            rvc = new RequestViewContext();
-            map.put(root, rvc);
             ctx.getAttributes().put(VIEW_CONTEXT_KEY, map);
         }
-        else
-        {
-            map.put(root, rvc);
-        }
+
+        map.put(root, rvc);
     }
 
     public boolean isResourceDependencyAlreadyProcessed(ResourceDependency dependency)
@@ -171,16 +156,13 @@ public class RequestViewContext
             renderTargetMap = new HashMap<>(8);
         }
         renderTargetMap.put(target, value);
+
         if (renderTargetMapComponents == null)
         {
             renderTargetMapComponents = new HashMap<>(8);
         }
-        List<UIComponent> componentList = renderTargetMapComponents.get(target);
-        if (componentList == null)
-        {
-            componentList = new ArrayList<>(8);
-            renderTargetMapComponents.put(target, componentList);
-        }
+        
+        List<UIComponent> componentList = renderTargetMapComponents.computeIfAbsent(target, k -> new ArrayList<>(8));
         if (!componentList.contains(component))
         {
             componentList.add(component);


[myfaces] 01/02: cosmetics

Posted by ta...@apache.org.
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

commit 6f5cf6b93e7050d80becb4e74013a8af5d55fbaf
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Fri Aug 2 13:15:02 2019 +0200

    cosmetics
---
 .../apache/myfaces/application/ResourceHandlerImpl.java   |  2 +-
 .../java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java |  2 +-
 .../myfaces/cdi/view/ViewTransientScopeBeanHolder.java    |  4 ++--
 .../tag/jsf/ComponentRelocatableResourceHandler.java      |  5 +++--
 .../myfaces/view/facelets/tag/jsf/ComponentSupport.java   | 15 +++++++--------
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
index 5f6c48e..b32f2c3 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
@@ -1827,7 +1827,7 @@ public class ResourceHandlerImpl extends ResourceHandler
         if (map == null)
         {
             map = new HashMap<>();
-            facesContext.getViewRoot().getTransientStateHelper().putTransient(RENDERED_RESOURCES_SET,map);
+            facesContext.getViewRoot().getTransientStateHelper().putTransient(RENDERED_RESOURCES_SET, map);
         }
         return map;
     }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
index 4e5e244..64aebe1 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeBeanHolder.java
@@ -82,7 +82,7 @@ public class FacesScopeBeanHolder
             map = (Map<Object, Object>) info.getContextualInstance();
             if (map == null)
             {
-                map = new HashMap<Object,Object>();
+                map = new HashMap<>();
                 info.setContextualInstance(map);
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
index 11e70cc..1b87a0a 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeBeanHolder.java
@@ -72,13 +72,13 @@ public class ViewTransientScopeBeanHolder
             ContextualInstanceInfo info = contextualStorage.getStorage().get(VIEW_TRANSIENT_SCOPE_MAP_INFO);
             if (info == null)
             {
-                info = new ContextualInstanceInfo<Object>();
+                info = new ContextualInstanceInfo<>();
                 contextualStorage.getStorage().put(VIEW_TRANSIENT_SCOPE_MAP_INFO, info);
             }
             map = (Map<Object, Object>) info.getContextualInstance();
             if (map == null)
             {
-                map = new HashMap<Object,Object>();
+                map = new HashMap<>();
                 info.setContextualInstance(map);
             }
         }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentRelocatableResourceHandler.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentRelocatableResourceHandler.java
index 1490e5b..409efe3 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentRelocatableResourceHandler.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentRelocatableResourceHandler.java
@@ -35,10 +35,10 @@ public class ComponentRelocatableResourceHandler implements RelocatableResourceH
     public static final ComponentRelocatableResourceHandler INSTANCE = new ComponentRelocatableResourceHandler();
     
     @Override
-    public UIComponent findChildByTagId(FaceletContext ctx, UIComponent parent,
-            String id)
+    public UIComponent findChildByTagId(FaceletContext ctx, UIComponent parent, String id)
     {
         UIComponent c = null;
+        
         UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
         if (root.getFacetCount() > 0)
         {
@@ -49,6 +49,7 @@ public class ComponentRelocatableResourceHandler implements RelocatableResourceH
                 c = ComponentSupport.findChildByTagId(facet, id);
             }
         }
+        
         return c;
     }
     
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
index 34a51e5..cc8f85b 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
@@ -496,11 +496,13 @@ public final class ComponentSupport
         // doing the same trick as with metadata: use a double __ and add a prefix (f).
         // Note this id will never be printed into the response, because this is just a container.
         FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
+
         UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
         if (uniqueIdVendor == null)
         {
             uniqueIdVendor = ComponentSupport.getViewRoot(ctx, parent);
         }
+
         if (uniqueIdVendor != null)
         {
             // UIViewRoot implements UniqueIdVendor, so there is no need to cast to UIViewRoot
@@ -517,8 +519,10 @@ public final class ComponentSupport
                       .append("__f_")
                       .append(cleanFacetName).toString()));
         }
+
         panel.getAttributes().put(FACET_CREATED_UIPANEL_MARKER, Boolean.TRUE);
         panel.getAttributes().put(ComponentSupport.COMPONENT_ADDED_BY_HANDLER_MARKER, Boolean.TRUE);
+
         return panel;
     }
     
@@ -600,8 +604,7 @@ public final class ComponentSupport
         int separator = expr.indexOf(separatorChar);
         if (separator == -1)
         {
-            return ComponentSupport.findComponentChildOrFacetFrom(
-                    parent, expr, null);
+            return ComponentSupport.findComponentChildOrFacetFrom(parent, expr, null);
         }
         else
         {
@@ -728,12 +731,8 @@ public final class ComponentSupport
         if (fcc.isUsingPSSOnThisView() && !fcc.isRefreshTransientBuildOnPSSPreserveState())
         {
             UIViewRoot root = getViewRoot(ctx, parent);
-            FaceletState map = (FaceletState) root.getAttributes().get(FACELET_STATE_INSTANCE);
-            if (map == null)
-            {
-                map = new FaceletState();
-                root.getAttributes().put(FACELET_STATE_INSTANCE, map);
-            }
+            FaceletState map = (FaceletState) root.getAttributes().computeIfAbsent(FACELET_STATE_INSTANCE,
+                    k -> new FaceletState());
             map.putState(uniqueId, value);
         }
     }