commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1051562 - in /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2: JexlEngine.java UnifiedJEXL.java
Date Tue, 21 Dec 2010 17:11:32 GMT
Author: henrib
Date: Tue Dec 21 17:11:32 2010
New Revision: 1051562

URL: http://svn.apache.org/viewvc?rev=1051562&view=rev
Log:
Added explicit clear cache methods

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java?rev=1051562&r1=1051561&r2=1051562&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java Tue Dec
21 17:11:32 2010
@@ -729,6 +729,13 @@ public class JexlEngine {    
         }
 
         /**
+         * Clears the cache.
+         */
+        void clear() {
+            ref = null;
+        }
+
+        /**
          * Produces the cache entry set.
          * @return the cache entry set
          */
@@ -772,7 +779,7 @@ public class JexlEngine {    
     protected <K, V> Map<K, V> createCache(final int cacheSize) {
         return new java.util.LinkedHashMap<K, V>(cacheSize, LOAD_FACTOR, true) {
             /** Serial version UID. */
-            private static final long serialVersionUID = 3801124242820219131L;
+            private static final long serialVersionUID = 1L;
 
             @Override
             protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
@@ -782,6 +789,15 @@ public class JexlEngine {    
     }
 
     /**
+     * Clears the expression cache.
+     */
+    public void clearCache() {
+        synchronized(parser) {
+            cache.clear();
+        }
+    }
+
+    /**
      * Parses an expression.
      * @param expression the expression to parse
      * @param info debug information structure
@@ -868,7 +884,7 @@ public class JexlEngine {    
      * @param str expression to clean
      * @return trimmed expression ending in a semi-colon
      */
-    public static final String cleanExpression(CharSequence str) {
+    public static String cleanExpression(CharSequence str) {
         if (str != null) {
             int start = 0;
             int end = str.length();
@@ -895,7 +911,7 @@ public class JexlEngine {    
      * @return the contents of the reader as a String.
      * @throws IOException on any error reading the reader.
      */
-    public static final String readerToString(Reader scriptReader) throws IOException {
+    public static String readerToString(Reader scriptReader) throws IOException {
         StringBuilder buffer = new StringBuilder();
         BufferedReader reader;
         if (scriptReader instanceof BufferedReader) {

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java?rev=1051562&r1=1051561&r2=1051562&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java Tue
Dec 21 17:11:32 2010
@@ -192,6 +192,15 @@ public final class UnifiedJEXL {
     }
 
     /**
+     * Clears the cache.
+     */
+    public void clearCache() {
+        synchronized(cache) {
+            cache.clear();
+        }
+    }
+
+    /**
      * The sole type of (runtime) exception the UnifiedJEXL can throw.
      */
     public static class Exception extends RuntimeException {



Mime
View raw message