Author: kkolinko
Date: Fri Mar 30 08:47:15 2012
New Revision: 1307310
URL: http://svn.apache.org/viewvc?rev=1307310&view=rev
Log:
Refactoring. Move classname discovery into separate helper method.
Modified:
tomcat/trunk/java/javax/el/ExpressionFactory.java
Modified: tomcat/trunk/java/javax/el/ExpressionFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ExpressionFactory.java?rev=1307310&r1=1307309&r2=1307310&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ExpressionFactory.java (original)
+++ tomcat/trunk/java/javax/el/ExpressionFactory.java Fri Mar 30 08:47:15 2012
@@ -115,47 +115,10 @@ 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();
-
- // 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";
- }
+ String className = discoverClassName(tccl);
try {
Class<?> clazz = 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: [email protected]
For additional commands, e-mail: [email protected]