You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2007/10/05 20:13:18 UTC

svn commit: r582368 - in /xmlbeans/trunk/src: store/org/apache/xmlbeans/impl/store/Path.java xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java xmlpublic/org/apache/xmlbeans/message.properties

Author: cezar
Date: Fri Oct  5 11:13:17 2007
New Revision: 582368

URL: http://svn.apache.org/viewvc?rev=582368&view=rev
Log:
Adding XmlError codes and replace static HashMaps with WeakHashMaps.

checkintest passes


Modified:
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java?rev=582368&r1=582367&r2=582368&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java Fri Oct  5 11:13:17 2007
@@ -19,6 +19,7 @@
 
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.ref.WeakReference;
 import java.math.BigDecimal;
 
 import org.apache.xmlbeans.impl.common.XPath;
@@ -95,15 +96,18 @@
         String currentVar)
     {
         Path path = null;
+        WeakReference pathWeakRef = null;
         Map namespaces = (force & USE_SAXON) != 0 ? new HashMap() : null;
 
         if ((force & USE_XBEAN) != 0)
-            path = (Path) _xbeanPathCache.get(pathExpr);
+            pathWeakRef = (WeakReference)_xbeanPathCache.get(pathExpr);
         if (path == null && (force & USE_XQRL) != 0)
-            path = (Path) _xqrlPathCache.get(pathExpr);
+            pathWeakRef = (WeakReference)_xqrlPathCache.get(pathExpr);
         if (path == null && (force & USE_XQRL2002) != 0)
-            path = (Path) _xqrl2002PathCache.get(pathExpr);
+            pathWeakRef = (WeakReference)_xqrl2002PathCache.get(pathExpr);
 
+        if (pathWeakRef!=null)
+            path = (Path)pathWeakRef.get();
         if (path != null)
             return path;
 
@@ -138,7 +142,7 @@
     {
         Path path = createXqrlCompiledPath(pathExpr, currentVar);
         if (path != null)
-            _xqrlPathCache.put(path._pathKey, path);
+            _xqrlPathCache.put(path._pathKey, new WeakReference(path));
 
         return path;
     }
@@ -147,7 +151,7 @@
     {
         Path path = createXqrl2002CompiledPath(pathExpr, currentVar);
         if (path != null)
-            _xqrl2002PathCache.put(path._pathKey, path);
+            _xqrl2002PathCache.put(path._pathKey, new WeakReference(path));
 
         return path;
     }
@@ -157,7 +161,7 @@
     {
         Path path = XbeanPath.create(pathExpr, currentVar, namespaces);
         if (path != null)
-            _xbeanPathCache.put(path._pathKey, path);
+            _xbeanPathCache.put(path._pathKey, new WeakReference(path));
 
         return path;
     }
@@ -578,9 +582,9 @@
 
     protected final String _pathKey;
 
-    private static Map _xbeanPathCache = new HashMap();
-    private static Map _xqrlPathCache = new HashMap();
-    private static Map _xqrl2002PathCache = new HashMap();
+    private static Map _xbeanPathCache = new WeakHashMap();
+    private static Map _xqrlPathCache = new WeakHashMap();
+    private static Map _xqrl2002PathCache = new WeakHashMap();
 
     private static Method _xqrlCompilePath;
     private static Method _xqrl2002CompilePath;

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java?rev=582368&r1=582367&r2=582368&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java Fri Oct  5 11:13:17 2007
@@ -69,6 +69,9 @@
     public static final String EXCEPTION_VALUE_NOT_SUPPORTED_J2S = "exception.value.not.supported.j2s";
     public static final String EXCEPTION_VALUE_NOT_SUPPORTED_S2J = "exception.value.not.supported.s2j";
 
+    public static final String EXCEPTION_XQRL_XPATH_NOT_VALID = "exception.xqrl.xpath.not.valid";
+    public static final String EXCEPTION_XQRL_EXCEPTION = "exception.xqrl.exception";
+
     //
     // xml errors
     //
@@ -1859,6 +1862,4 @@
      *
      */
     public static final String INVALID_XPATH = "invalid-xpath";
-
-
 }

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties?rev=582368&r1=582367&r2=582368&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties Fri Oct  5 11:13:17 2007
@@ -41,6 +41,12 @@
 exception.value.not.supported.s2j = \
 Could not get a Java {1} type from a Schema {0} type
 
+exception.xqrl.xpath.not.valid = \
+Path expression is not selective, it creates new nodes: {0}
+
+exception.xqrl.exception = \
+XQuery engine exception: {0} for expresion: {1}
+
 #
 # xml messages
 #



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org