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 Mon, 12 Aug 2019 20:20:49 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 b551695  refactored
b551695 is described below

commit b551695f1818bbcdc297a72b6cdca767a69c1023
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Mon Aug 12 22:20:46 2019 +0200

    refactored
---
 .../myfaces/flow/cdi/FlowScopeBeanHolder.java      | 16 +-----------
 .../myfaces/lifecycle/LifecycleFactoryImpl.java    | 30 +++++++++-------------
 .../TempDirFileCacheContractResourceLoader.java    |  1 -
 .../impl/FaceletCompositionContextImpl.java        | 13 +++-------
 4 files changed, 17 insertions(+), 43 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
index 32ee3d4..cf3f764 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
@@ -105,21 +105,7 @@ public class FlowScopeBeanHolder implements Serializable
      */
     public ContextualStorage getContextualStorage(BeanManager beanManager, String flowClientWindowId)
     {
-        ContextualStorage contextualStorage = storageMap.get(flowClientWindowId);
-        if (contextualStorage == null)
-        {
-            synchronized (this)
-            {
-                contextualStorage = storageMap.get(flowClientWindowId);
-                if (contextualStorage == null)
-                {
-                    contextualStorage = new ContextualStorage(beanManager, true, true);
-                    storageMap.put(flowClientWindowId, contextualStorage);
-                }
-            }
-        }
-
-        return contextualStorage;
+        return storageMap.computeIfAbsent(flowClientWindowId, k -> new ContextualStorage(beanManager,
true, true));
     }
     
     public ContextualStorage getContextualStorageNoCreate(BeanManager beanManager, String
flowClientWindowId)
diff --git a/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleFactoryImpl.java b/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleFactoryImpl.java
index f677393..e1b857f 100755
--- a/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleFactoryImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleFactoryImpl.java
@@ -39,7 +39,7 @@ public class LifecycleFactoryImpl extends LifecycleFactory
      * do not block, and it is more often retrieval (at begin of all requests) than addition
(when 
      * startup listener is called and configuration occur). 
      */
-    private final Map<String, Lifecycle> _lifecycles = new ConcurrentHashMap<String,
Lifecycle>();
+    private final Map<String, Lifecycle> _lifecycles = new ConcurrentHashMap<>();
 
     public LifecycleFactoryImpl()
     {
@@ -58,28 +58,22 @@ public class LifecycleFactoryImpl extends LifecycleFactory
     @Override
     public void addLifecycle(String id, Lifecycle lifecycle)
     {
-        //synchronized (_lifecycles)
-        //{
-            if (_lifecycles.get(id) != null)
-            {
-                throw new IllegalArgumentException("Lifecycle with id '" + id + "' already
exists.");
-            }
-            _lifecycles.put(id, lifecycle);
-        //}
+        if (_lifecycles.get(id) != null)
+        {
+            throw new IllegalArgumentException("Lifecycle with id '" + id + "' already exists.");
+        }
+        _lifecycles.put(id, lifecycle);
     }
 
     @Override
     public Lifecycle getLifecycle(String id) throws FacesException
     {
-        //synchronized (_lifecycles)
-        //{
-            Lifecycle lifecycle = _lifecycles.get(id);
-            if (lifecycle == null)
-            {
-                throw new IllegalArgumentException("Unknown lifecycle '" + id + "'.");
-            }
-            return lifecycle;
-        //}
+        Lifecycle lifecycle = _lifecycles.get(id);
+        if (lifecycle == null)
+        {
+            throw new IllegalArgumentException("Unknown lifecycle '" + id + "'.");
+        }
+        return lifecycle;
     }
 
     @Override
diff --git a/impl/src/main/java/org/apache/myfaces/resource/TempDirFileCacheContractResourceLoader.java
b/impl/src/main/java/org/apache/myfaces/resource/TempDirFileCacheContractResourceLoader.java
index a8880df..041f76f 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/TempDirFileCacheContractResourceLoader.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/TempDirFileCacheContractResourceLoader.java
@@ -266,7 +266,6 @@ public class TempDirFileCacheContractResourceLoader extends ContractResourceLoad
     
     public static class FileProducer 
     {
-        
         public volatile boolean created = false;
         
         public FileProducer()
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
index 5f76f38..fb20b24 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
@@ -1074,15 +1074,10 @@ public class FaceletCompositionContextImpl extends FaceletCompositionContext
         {
             // Store it in application map improve performance because it avoids FactoryFinde.getFactory(...)
call
             // which has synchronized blocks.
-            _visitContextFactory = (VisitContextFactory) _facesContext.getExternalContext().
-                    getApplicationMap().get(VISIT_CONTEXT_FACTORY);
-            if (_visitContextFactory == null)
-            {
-                VisitContextFactory factory = (VisitContextFactory)
-                        FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
-                _facesContext.getExternalContext().getApplicationMap().put(VISIT_CONTEXT_FACTORY,
factory);
-                _visitContextFactory = factory;
-            }
+            _visitContextFactory = (VisitContextFactory) _facesContext.getExternalContext().getApplicationMap()
+                    .computeIfAbsent(
+                            VISIT_CONTEXT_FACTORY,
+                            k -> FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY));
         }
         return _visitContextFactory;
     }


Mime
View raw message