geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r898637 - /geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/
Date Wed, 13 Jan 2010 03:30:30 GMT
Author: xuhaihong
Date: Wed Jan 13 03:30:30 2010
New Revision: 898637

URL: http://svn.apache.org/viewvc?rev=898637&view=rev
Log:
1.Implement newInstance in ExpressionFactory
2. Add some empty invoke methods to make the compile pass

Modified:
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ArrayELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/BeanELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/CompositeELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ListELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/MapELResolver.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ResourceBundleELResolver.java

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ArrayELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ArrayELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ArrayELResolver.java
(original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ArrayELResolver.java
Wed Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -156,4 +156,8 @@
 				.toString() : "null");
 	}
 
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/BeanELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/BeanELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/BeanELResolver.java (original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/BeanELResolver.java Wed
Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -200,7 +200,7 @@
         public BeanProperty getBeanProperty(String name) {
             return get(null, name);
         }
-        
+
         private Class<?> getType() {
             return type;
         }
@@ -287,7 +287,7 @@
 		Method mp;
         for (Class anInf : inf) {
             try {
-                mp = anInf.getMethod(m.getName(), (Class[]) m.getParameterTypes());
+                mp = anInf.getMethod(m.getName(), m.getParameterTypes());
                 mp = getMethod(mp.getDeclaringClass(), mp);
                 if (mp != null) {
                     return mp;
@@ -299,7 +299,7 @@
         Class sup = type.getSuperclass();
 		if (sup != null) {
 			try {
-				mp = sup.getMethod(m.getName(), (Class[]) m.getParameterTypes());
+				mp = sup.getMethod(m.getName(), m.getParameterTypes());
 				mp = getMethod(mp.getDeclaringClass(), mp);
 				if (mp != null) {
 					return mp;
@@ -310,19 +310,19 @@
 		}
 		return null;
 	}
-	
+
 	private final static class ConcurrentCache<K,V> {
 
 		private final int size;
 		private final Map<K,V> eden;
 		private final Map<K,V> longterm;
-		
+
 		public ConcurrentCache(int size) {
 			this.size = size;
 			this.eden = new ConcurrentHashMap<K,V>(size);
 			this.longterm = new WeakHashMap<K,V>(size);
 		}
-		
+
 		public V get(K key) {
 			V value = this.eden.get(key);
 			if (value == null) {
@@ -333,7 +333,7 @@
 			}
 			return value;
 		}
-		
+
 		public void put(K key, V value) {
 			if (this.eden.size() >= this.size) {
 				this.longterm.putAll(this.eden);
@@ -343,4 +343,9 @@
 		}
 
 	}
+
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/CompositeELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/CompositeELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/CompositeELResolver.java
(original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/CompositeELResolver.java
Wed Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -166,7 +166,7 @@
 			this.idx = 0;
 			this.guaranteeIterator();
 		}
-		
+
 		private void guaranteeIterator() {
 			while (this.itr == null && this.idx < this.size) {
 				this.itr = this.resolvers[this.idx].getFeatureDescriptors(
@@ -198,4 +198,8 @@
 		}
 	}
 
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELResolver.java (original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELResolver.java Wed Jan
13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@
  *
  */
 public abstract class ELResolver {
-	
+
 	static String message(ELContext context, String name, Object[] props) {
 		Locale locale = context == null? null: context.getLocale();
 		if (locale == null) {
@@ -52,18 +52,20 @@
 	}
 
     public final static String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime";
-    
+
     public final static String TYPE = "type";
-    
+
     public abstract Object getValue(ELContext context, Object base, Object property) throws
NullPointerException, PropertyNotFoundException, ELException;
-    
+
     public abstract Class<?> getType(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException;
-    
+
     public abstract void setValue(ELContext context, Object base, Object property, Object
value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException,
ELException;
 
     public abstract boolean isReadOnly(ELContext context, Object base, Object property) throws
NullPointerException, PropertyNotFoundException, ELException;
-    
+
     public abstract Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext
context, Object base);
-    
+
     public abstract Class<?> getCommonPropertyType(ELContext context, Object base);
+
+    public abstract Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params);
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java
(original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java
Wed Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,24 +17,158 @@
 
 package javax.el;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Properties;
+
 /**
- * 
+ *
  * @since 2.1
  */
 public abstract class ExpressionFactory {
 
-    public abstract Object coerceToType(Object obj, Class<?> expectedType)
-            throws ELException;
+    private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "org.apache.el.ExpressionFactoryImpl";
+
+    private static final String EXPRESSION_FACTORY_SERVICE_ENTRY_URL = "META-INF/services/javax.el.ExpressionFactory";
+
+    private static final String SYSTEM_PROPERTY_NAME = "javax.el.ExpressionFactory";
+
+    private static final String JAVA_RUNTIME_PROPERTY_FILE_LOCATION = "lib" + File.separator
+ "el.properties";
 
-    public abstract ValueExpression createValueExpression(ELContext context,
-            String expression, Class<?> expectedType)
-            throws NullPointerException, ELException;
-
-    public abstract ValueExpression createValueExpression(Object instance,
-            Class<?> expectedType);
-
-    public abstract MethodExpression createMethodExpression(ELContext context,
-            String expression, Class<?> expectedReturnType,
-            Class<?>[] expectedParamTypes) throws ELException,
-            NullPointerException;
+    public abstract Object coerceToType(Object obj, Class<?> expectedType) throws ELException;
+
+    public abstract ValueExpression createValueExpression(ELContext context, String expression,
Class<?> expectedType) throws NullPointerException, ELException;
+
+    public abstract ValueExpression createValueExpression(Object instance, Class<?>
expectedType);
+
+    public abstract MethodExpression createMethodExpression(ELContext context, String expression,
Class<?> expectedReturnType, Class<?>[] expectedParamTypes) throws ELException,
NullPointerException;
+
+    public static ExpressionFactory newInstance() {
+        return newInstance(null);
+    }
+
+    public static ExpressionFactory newInstance(Properties properties) {
+        Class<?> implClass = loadExpressionFactoryImplClass();
+        if (properties == null) {
+            return newInstance0(implClass);
+        }
+        try {
+            Constructor<?> constructor = implClass.getConstructor(Properties.class);
+            try {
+                return (ExpressionFactory) constructor.newInstance(properties);
+            } catch (IllegalArgumentException e) {
+                throw new ELException("Fail to create ExpressionFactory instance", e);
+            } catch (InstantiationException e) {
+                throw new ELException("Fail to create ExpressionFactory instance", e);
+            } catch (IllegalAccessException e) {
+                throw new ELException("Fail to create ExpressionFactory instance", e);
+            } catch (InvocationTargetException e) {
+                throw new ELException("Fail to create ExpressionFactory instance", e);
+            }
+        } catch (SecurityException e) {
+            throw new ELException("Fail to get constuctor from ExpressionFactory implementation
class", e);
+        } catch (NoSuchMethodException e) {
+            return newInstance0(implClass);
+        }
+    }
+
+    private static ExpressionFactory newInstance0(Class<?> implClass) {
+        try {
+            return (ExpressionFactory) implClass.newInstance();
+        } catch (IllegalAccessException e) {
+            throw new ELException("Fail to create ExpressionFactory instance", e);
+        } catch (InstantiationException e) {
+            throw new ELException("Fail to create ExpressionFactory instance", e);
+        }
+    }
+
+    private static String lookupExpressionFactoryImplClass() {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if (cl == null) {
+            cl = ClassLoader.getSystemClassLoader();
+        }
+        String implClassName = null;
+        implClassName = lookupByServiceEntryURL(cl);
+        if (implClassName == null) {
+            implClassName = lookupByJREPropertyFile();
+            if (implClassName == null) {
+                implClassName = System.getProperty(SYSTEM_PROPERTY_NAME);
+                if (implClassName == null) {
+                    implClassName = PLATFORM_DEFAULT_FACTORY_CLASS;
+                }
+            }
+        }
+        return implClassName;
+    }
+
+    private static String lookupByServiceEntryURL(ClassLoader cl) {
+        InputStream in = null;
+        try {
+            in = cl.getResourceAsStream(EXPRESSION_FACTORY_SERVICE_ENTRY_URL);
+            if (in != null) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,
"UTF-8"));
+                return bufferedReader.readLine().trim();
+            } else {
+                return null;
+            }
+        } catch (UnsupportedEncodingException e) {
+            throw new ELException("Fail to read " + EXPRESSION_FACTORY_SERVICE_ENTRY_URL,
e);
+        } catch (IOException e) {
+            throw new ELException("Fail to read " + EXPRESSION_FACTORY_SERVICE_ENTRY_URL,
e);
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+
+    private static String lookupByJREPropertyFile() {
+        String jreDirectory = System.getProperty("java.home");
+        File configurationFile = new File(jreDirectory + File.separator + JAVA_RUNTIME_PROPERTY_FILE_LOCATION);
+        if (configurationFile.exists() && configurationFile.canRead()) {
+            Properties properties = new Properties();
+            InputStream in = null;
+            try {
+                in = new FileInputStream(configurationFile);
+                properties.load(in);
+                return properties.getProperty(SYSTEM_PROPERTY_NAME);
+            } catch (IOException e) {
+                throw new ELException("Fail to read " + configurationFile.getAbsolutePath(),
e);
+            } finally {
+                if (in != null) {
+                    try {
+                        in.close();
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        } else {
+            return null;
+        }
+    }
+
+    private static Class<?> loadExpressionFactoryImplClass() {
+        String implClassName = null;
+        try {
+            implClassName = lookupExpressionFactoryImplClass();
+            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+            if (contextClassLoader != null) {
+                return contextClassLoader.loadClass(implClassName);
+            } else {
+                return Class.forName(implClassName);
+            }
+        } catch (ClassNotFoundException e) {
+            throw new ELException("Fail to load implementation class " + implClassName, e);
+        }
+    }
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ListELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ListELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ListELResolver.java (original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ListELResolver.java Wed
Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -168,4 +168,9 @@
 		throw new IllegalArgumentException(property != null ? property
 				.toString() : "null");
 	}
+
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/MapELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/MapELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/MapELResolver.java (original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/MapELResolver.java Wed
Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,7 +50,7 @@
 			context.setPropertyResolved(true);
 			return ((Map) base).get(property);
 		}
-		
+
 		return null;
 	}
 
@@ -65,7 +65,7 @@
 			Object obj = ((Map) base).get(property);
 			return (obj != null) ? obj.getClass() : null;
 		}
-		
+
 		return null;
 	}
 
@@ -104,7 +104,7 @@
 			context.setPropertyResolved(true);
 			return this.readOnly || UNMODIFIABLE.equals(base.getClass());
 		}
-		
+
 		return this.readOnly;
 	}
 
@@ -138,4 +138,9 @@
 		return null;
 	}
 
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ResourceBundleELResolver.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ResourceBundleELResolver.java?rev=898637&r1=898636&r2=898637&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ResourceBundleELResolver.java
(original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ResourceBundleELResolver.java
Wed Jan 13 03:30:30 2010
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@
 		if (context == null) {
 			throw new NullPointerException();
 		}
-		
+
 		if (base instanceof ResourceBundle) {
 			context.setPropertyResolved(true);
 
@@ -58,11 +58,11 @@
 		if (context == null) {
 			throw new NullPointerException();
 		}
-		
+
 		if (base instanceof ResourceBundle) {
 			context.setPropertyResolved(true);
 		}
-		
+
 		return null;
 	}
 
@@ -73,7 +73,7 @@
 		if (context == null) {
 			throw new NullPointerException();
 		}
-		
+
 		if (base instanceof ResourceBundle) {
 			context.setPropertyResolved(true);
 			throw new PropertyNotWritableException(message(context,
@@ -87,11 +87,11 @@
 		if (context == null) {
 			throw new NullPointerException();
 		}
-		
+
 		if (base instanceof ResourceBundle) {
 			context.setPropertyResolved(true);
 		}
-		
+
 		return true;
 	}
 
@@ -125,4 +125,8 @@
 		return null;
 	}
 
+    public Object invoke(ELContext context, Object base, Object method, Class<?>[]
paramTypes, Object[] params) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }



Mime
View raw message