geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r902530 - in /geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el: BeanELResolver.java CompositeELResolver.java ELContext.java ELUtils.java ExpressionFactory.java
Date Sun, 24 Jan 2010 07:17:55 GMT
Author: xuhaihong
Date: Sun Jan 24 07:17:54 2010
New Revision: 902530

URL: http://svn.apache.org/viewvc?rev=902530&view=rev
Log:
Still think that a cached ExpressionFactory is need to improve efficiency, now use ELUtils
to hold the cached expressionFactory

Added:
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java   (with
props)
Modified:
    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/ELContext.java
    geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ExpressionFactory.java

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=902530&r1=902529&r2=902530&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 Sun
Jan 24 07:17:54 2010
@@ -357,7 +357,10 @@
         if (params == null) {
             params = new Object[0];
         }
-        ExpressionFactory expressionFactory = (ExpressionFactory) context.getContext(ExpressionFactory.class);
+        ExpressionFactory expressionFactory = null;
+        if (ELUtils.isCachedExpressionFactoryEnabled()) {
+            expressionFactory = ELUtils.getCachedExpressionFactory();
+        }
         if (expressionFactory == null) {
             expressionFactory = ExpressionFactory.newInstance();
         }

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=902530&r1=902529&r2=902530&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
Sun Jan 24 07:17:54 2010
@@ -205,7 +205,10 @@
         if (method == null || base == null) {
             return null;
         }
-        ExpressionFactory expressionFactory = (ExpressionFactory) context.getContext(ExpressionFactory.class);
+        ExpressionFactory expressionFactory = null;
+        if (ELUtils.isCachedExpressionFactoryEnabled()) {
+            expressionFactory = ELUtils.getCachedExpressionFactory();
+        }
         if (expressionFactory == null) {
             expressionFactory = ExpressionFactory.newInstance();
         }

Modified: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELContext.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELContext.java?rev=902530&r1=902529&r2=902530&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELContext.java (original)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELContext.java Sun Jan
24 07:17:54 2010
@@ -32,28 +32,11 @@
 
     private boolean resolved;
 
-    private static ExpressionFactory expressionFactory;
-
-    private static boolean useCachedExpressionFactory;
-
-    static{
-        useCachedExpressionFactory = Boolean.valueOf(System.getProperty("org.apache.geronimo.spec.el.useCachedExpressionFactory","true"));
-        if (useCachedExpressionFactory) {
-            try {
-                expressionFactory = ExpressionFactory.newInstance();
-            } catch (Exception e) {
-            }
-        }
-    }
-
     /**
      *
      */
     public ELContext() {
         this.resolved = false;
-        if (useCachedExpressionFactory) {
-            putContext(ExpressionFactory.class, expressionFactory);
-        }
     }
 
     public Object getContext(Class key) {

Added: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java?rev=902530&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java (added)
+++ geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java Sun Jan
24 07:17:54 2010
@@ -0,0 +1,38 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  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.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.el;
+
+public class ELUtils {
+
+    private static volatile ExpressionFactory cachedExpressionFactory;
+
+    private static volatile boolean cachedExpressionFactoryEnabled = Boolean.valueOf(System.getProperty("org.apache.geronimo.spec.el.useCachedExpressionFactory",
"true"));
+
+    public static ExpressionFactory getCachedExpressionFactory() {
+        return cachedExpressionFactory;
+    }
+
+    public static boolean isCachedExpressionFactoryEnabled() {
+        return cachedExpressionFactoryEnabled;
+    }
+
+    public static void setCachedExpressionFactory(ExpressionFactory expressionFactory) {
+        cachedExpressionFactory = expressionFactory;
+    }
+
+}

Propchange: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-el_2.2_spec/src/main/java/javax/el/ELUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=902530&r1=902529&r2=902530&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
Sun Jan 24 07:17:54 2010
@@ -42,6 +42,13 @@
 
     private static final String JAVA_RUNTIME_PROPERTY_FILE_LOCATION = "lib" + File.separator
+ "el.properties";
 
+    static {
+        try {
+            ELUtils.setCachedExpressionFactory(newInstance());
+        } catch (Exception e) {
+        }
+    }
+
     public abstract Object coerceToType(Object obj, Class<?> expectedType) throws ELException;
 
     public abstract ValueExpression createValueExpression(ELContext context, String expression,
Class<?> expectedType) throws NullPointerException, ELException;



Mime
View raw message