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 Wed, 18 Mar 2020 09:46:41 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 ca70224  refactored
ca70224 is described below

commit ca702245312cea8a96e333aaf6f1815b646c59e2
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Wed Mar 18 10:46:35 2020 +0100

    refactored
---
 .../el/resolver/FacesCompositeELResolver.java      | 27 ++++++++-----
 .../myfaces/el/resolver/FlashELResolver.java       | 15 ++++---
 .../el/resolver/ImportConstantsELResolver.java     |  2 +-
 .../myfaces/el/resolver/ImportHandlerResolver.java | 47 ++++++++++++----------
 .../el/resolver/ResourceBundleResolver.java        |  4 --
 5 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/FacesCompositeELResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/FacesCompositeELResolver.java
index 3506e9c..5442eac 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/FacesCompositeELResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/FacesCompositeELResolver.java
@@ -45,15 +45,15 @@ import java.util.Arrays;
  */
 public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolver.CompositeELResolver
 {
+    public static final String SCOPE = FacesCompositeELResolver.class.getName() + ".Scope";
+    
     private final Scope _scope;
 
     public enum Scope
     {
         Faces, JSP, NONE
     }
-    
-    public static final String SCOPE = "org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope";
-    
+
     public FacesCompositeELResolver(final Scope scope)
     {
         if (scope == null)
@@ -65,7 +65,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
 
     private static FacesContext facesContext(final ELContext context)
     {
-        FacesContext facesContext = (FacesContext)context.getContext(FacesContext.class);
+        FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
         if (facesContext == null)
         {
             facesContext = FacesContext.getCurrentInstance();
@@ -81,6 +81,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return null;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -91,7 +92,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
@@ -111,6 +112,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return null;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -118,11 +120,10 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
             prevScope = getScope(requestMap);
             setScope(requestMap);
             return super.getFeatureDescriptors(context, base);
-
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
@@ -141,6 +142,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return null;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -151,7 +153,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
@@ -170,6 +172,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return null;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -180,7 +183,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
@@ -199,6 +202,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return false;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -209,7 +213,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
@@ -228,6 +232,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         {
             return;
         }
+
         final Map<Object, Object> requestMap = facesContext.getAttributes();
         Scope prevScope = null;
         try
@@ -239,7 +244,7 @@ public final class FacesCompositeELResolver extends org.apache.myfaces.el.resolv
         }
         finally
         {
-            if(prevScope != null)
+            if (prevScope != null)
             {
                 setScope(requestMap, prevScope);
             }
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/FlashELResolver.java b/impl/src/main/java/org/apache/myfaces/el/resolver/FlashELResolver.java
index 5ec75f6..82bffbd 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/FlashELResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/FlashELResolver.java
@@ -66,12 +66,12 @@ public class FlashELResolver extends ELResolver
         }
 
         String strProperty = property.toString();
-
         if (FLASH.equals(strProperty))
         {
             throw new PropertyNotWritableException();
         }
-        else if (base instanceof Flash)
+
+        if (base instanceof Flash)
         {
             context.setPropertyResolved(true);
             try
@@ -89,7 +89,6 @@ public class FlashELResolver extends ELResolver
     public boolean isReadOnly(ELContext context, Object base, Object property)
             throws NullPointerException, PropertyNotFoundException, ELException
     {
-
         if (property == null)
         {
             throw new PropertyNotFoundException();
@@ -100,13 +99,13 @@ public class FlashELResolver extends ELResolver
         }
 
         String strProperty = property.toString();
-
         if (FLASH.equals(strProperty))
         {
             context.setPropertyResolved(true);
             return true;
         }
-        else if (base instanceof Flash)
+
+        if (base instanceof Flash)
         {
             context.setPropertyResolved(true);
         }
@@ -262,7 +261,6 @@ public class FlashELResolver extends ELResolver
     public Class<?> getType(ELContext context, Object base, Object property)
             throws NullPointerException, PropertyNotFoundException, ELException
     {
-
         if (property == null)
         {
             throw new PropertyNotFoundException();
@@ -291,7 +289,7 @@ public class FlashELResolver extends ELResolver
     @Override
     public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object
base)
     {
-        ArrayList<FeatureDescriptor> descriptors = new ArrayList<FeatureDescriptor>(1);
+        ArrayList<FeatureDescriptor> descriptors = new ArrayList<>(1);
 
         descriptors.add(makeDescriptor(FLASH,
                 "Represents the current flash scope", Object.class));
@@ -338,7 +336,8 @@ public class FlashELResolver extends ELResolver
         {
             return Object.class;
         }
-        else if (FLASH.equals(base.toString()))
+
+        if (FLASH.equals(base.toString()))
         {
             return Object.class;
         }
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
index 5fddb9c..74c0720 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportConstantsELResolver.java
@@ -52,7 +52,7 @@ public final class ImportConstantsELResolver extends ELResolver
 
     private static final String IMPORT_CONSTANTS = "oam.importConstants";
     
-    private Map<String, Map<String, Object>> constantsTypeMap = new ConcurrentHashMap<String,
Map<String, Object>>();
+    private Map<String, Map<String, Object>> constantsTypeMap = new ConcurrentHashMap<>();
 
     @Override
     public Object getValue(final ELContext context, final Object base,
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportHandlerResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportHandlerResolver.java
index caf9294..23a5bc6 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/ImportHandlerResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/ImportHandlerResolver.java
@@ -83,32 +83,35 @@ public class ImportHandlerResolver extends ScopedAttributeResolver
     public Object getValue(final ELContext context, final Object base, final Object property)
         throws NullPointerException, PropertyNotFoundException, ELException
     {
-        if (EL_CLASS != null && EL_CLASS_CONSTRUCTOR != null 
-                        && GET_IMPORT_HANDLER_METHOD != null && IMPORT_HANDLER_RESOLVE_CLASS_METHOD
!= null ) 
+        if (EL_CLASS == null
+                || EL_CLASS_CONSTRUCTOR == null 
+                || GET_IMPORT_HANDLER_METHOD == null
+                || IMPORT_HANDLER_RESOLVE_CLASS_METHOD == null)
         {
-            Object importHandler = null;
-            try 
+            return null;
+        }
+
+        try 
+        {
+            // In an EL 3+ environment, the ELContext will have a getImportHandler() method
+            Object importHandler = GET_IMPORT_HANDLER_METHOD.invoke(context);
+            if (importHandler != null) 
             {
-                // In an EL 3+ environment, the ELContext will have a getImportHandler()
method
-                importHandler = GET_IMPORT_HANDLER_METHOD.invoke(context);
-                if (importHandler != null) 
+                Class<?> clazz = (Class<?>) IMPORT_HANDLER_RESOLVE_CLASS_METHOD.invoke(
+                        importHandler, property.toString());
+                if (clazz != null) 
                 {
-                    Class<?> clazz;
-                    clazz = (Class<?>) IMPORT_HANDLER_RESOLVE_CLASS_METHOD
-                        .invoke(importHandler, property.toString());
-                    if (clazz != null) 
-                    {
-                        context.setPropertyResolved(true);
-                        return EL_CLASS_CONSTRUCTOR.newInstance(clazz);
-                    }
+                    context.setPropertyResolved(true);
+                    return EL_CLASS_CONSTRUCTOR.newInstance(clazz);
                 }
-            } 
-            catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| SecurityException
-                    | InstantiationException ex) 
-            {
-                //No op
-            }            
-        }
+            }
+        } 
+        catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| SecurityException
+                | InstantiationException ex) 
+        {
+            //No op
+        }            
+
         return null;
     }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/ResourceBundleResolver.java
b/impl/src/main/java/org/apache/myfaces/el/resolver/ResourceBundleResolver.java
index 901b588..5a542cc 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/ResourceBundleResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/ResourceBundleResolver.java
@@ -79,7 +79,6 @@ public final class ResourceBundleResolver extends ELResolver
 
         // base is null and property is a String value, check for resource bundle.
         final ResourceBundle bundle = getResourceBundle(context, (String)property);
-
         if (bundle != null)
         {
             throw new PropertyNotWritableException("ResourceBundles are read-only");
@@ -104,7 +103,6 @@ public final class ResourceBundleResolver extends ELResolver
         }
 
         final ResourceBundle bundle = getResourceBundle(context, (String)property);
-
         if (bundle != null)
         {
             context.setPropertyResolved(true);
@@ -132,7 +130,6 @@ public final class ResourceBundleResolver extends ELResolver
         }
 
         final ResourceBundle bundle = getResourceBundle(context, (String)property);
-
         if (bundle != null)
         {
             context.setPropertyResolved(true);
@@ -160,7 +157,6 @@ public final class ResourceBundleResolver extends ELResolver
         }
 
         final ResourceBundle bundle = getResourceBundle(context, (String)property);
-
         if (bundle != null)
         {
             context.setPropertyResolved(true);


Mime
View raw message