You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/03/30 21:21:01 UTC

svn commit: r1307577 - in /tomcat/tc7.0.x/trunk: ./ java/javax/el/ExpressionFactory.java

Author: markt
Date: Fri Mar 30 19:21:01 2012
New Revision: 1307577

URL: http://svn.apache.org/viewvc?rev=1307577&view=rev
Log:
Refactoring. Move class name discovery into separate helper method. (kkolinko)

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/javax/el/ExpressionFactory.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1307310

Modified: tomcat/tc7.0.x/trunk/java/javax/el/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/ExpressionFactory.java?rev=1307577&r1=1307576&r2=1307577&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/ExpressionFactory.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/ExpressionFactory.java Fri Mar 30 19:21:01 2012
@@ -115,48 +115,11 @@ public abstract class ExpressionFactory 
      * @return the new ExpressionFactory
      */
     public static ExpressionFactory newInstance(Properties properties) {
-        String className = null;
         ExpressionFactory result = null;
         
         ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        String className = discoverClassName(tccl);
 
-        // First services API
-        className = getClassNameServices(tccl);
-        if (className == null) {
-            if (IS_SECURITY_ENABLED) {
-                className = AccessController.doPrivileged(
-                        new PrivilegedAction<String>() {
-                            @Override
-                            public String run() {
-                                return getClassNameJreDir();
-                            }
-                        }
-                );
-            } else {
-                // Second el.properties file
-                className = getClassNameJreDir();
-            }
-        }
-        if (className == null) {
-            if (IS_SECURITY_ENABLED) {
-                className = AccessController.doPrivileged(
-                        new PrivilegedAction<String>() {
-                            @Override
-                            public String run() {
-                                return getClassNameSysProp();
-                            }
-                        }
-                );
-            } else {
-                // Third system property 
-                className = getClassNameSysProp();
-            }
-        }
-        if (className == null) {
-            // Fourth - default
-            className = "org.apache.el.ExpressionFactoryImpl";
-        }
-        
         try {
             Class<?> clazz = null;
             if (tccl == null) {
@@ -215,6 +178,55 @@ public abstract class ExpressionFactory 
         return result;
     }
     
+    /**
+     * Discover the name of class that implements ExpressionFactory.
+     *
+     * @param tccl
+     *            {@code ClassLoader}
+     * @return Class name. There is default, so it is never {@code null}.
+     */
+    private static String discoverClassName(ClassLoader tccl) {
+        String className = null;
+
+        // First services API
+        className = getClassNameServices(tccl);
+        if (className == null) {
+            if (IS_SECURITY_ENABLED) {
+                className = AccessController.doPrivileged(
+                        new PrivilegedAction<String>() {
+                            @Override
+                            public String run() {
+                                return getClassNameJreDir();
+                            }
+                        }
+                );
+            } else {
+                // Second el.properties file
+                className = getClassNameJreDir();
+            }
+        }
+        if (className == null) {
+            if (IS_SECURITY_ENABLED) {
+                className = AccessController.doPrivileged(
+                        new PrivilegedAction<String>() {
+                            @Override
+                            public String run() {
+                                return getClassNameSysProp();
+                            }
+                        }
+                );
+            } else {
+                // Third system property
+                className = getClassNameSysProp();
+            }
+        }
+        if (className == null) {
+            // Fourth - default
+            className = "org.apache.el.ExpressionFactoryImpl";
+        }
+        return className;
+    }
+
     private static String getClassNameServices(ClassLoader tccl) {
         InputStream is = null;
         



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org