[pkg-java] r2694 - branches/dom4j/feature/debian/src/java/org/dom4j/tree

Marcus Better marcusb-guest at alioth.debian.org
Tue Oct 31 11:26:52 UTC 2006


Author: marcusb-guest
Date: 2006-10-31 12:26:52 +0100 (Tue, 31 Oct 2006)
New Revision: 2694

Modified:
   branches/dom4j/feature/debian/src/java/org/dom4j/tree/NamespaceCache.java
Log:
Restore file to upstream version - changes are done on remove-nonfree-concurrent-class branch.


Modified: branches/dom4j/feature/debian/src/java/org/dom4j/tree/NamespaceCache.java
===================================================================
--- branches/dom4j/feature/debian/src/java/org/dom4j/tree/NamespaceCache.java	2006-10-31 11:24:13 UTC (rev 2693)
+++ branches/dom4j/feature/debian/src/java/org/dom4j/tree/NamespaceCache.java	2006-10-31 11:26:52 UTC (rev 2694)
@@ -26,46 +26,42 @@
  * @version $Revision: 1.15 $
  */
 public class NamespaceCache {
-    private static final String BACKPORT_CONCURRENTHASHMAP_CLASS
-        = "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap";
-    private static final String OSWEGO_CONCURRENTHASHMAP_CLASS
-        = "EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap";
+    private static final String CONCURRENTREADERHASHMAP_CLASS
+            = "EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap";
 
     /**
      * Cache of {@link Map}instances indexed by URI which contain caches of
      * {@link Namespace}for each prefix
      */
-    protected static Map cache = newConcurrentHashMap();
+    protected static Map cache;
 
     /**
      * Cache of {@link Namespace}instances indexed by URI for default
      * namespaces with no prefixes
      */
-    protected static Map noPrefixCache = newConcurrentHashMap();
+    protected static Map noPrefixCache;
 
-    protected static Map newConcurrentHashMap()
-    {
+    static {
         /* Try the java.util.concurrent.ConcurrentHashMap first. */
         try {
             Class clazz = Class
                     .forName("java.util.concurrent.ConcurrentHashMap");
             Constructor construct = clazz.getConstructor(new Class[] {
                     Integer.TYPE, Float.TYPE, Integer.TYPE });
-            return (Map) construct.newInstance(new Object[] {new Integer(11),
+            cache = (Map) construct.newInstance(new Object[] {new Integer(11),
                     new Float(0.75f), new Integer(1) });
+            noPrefixCache = (Map) construct.newInstance(new Object[] {
+                    new Integer(11), new Float(0.75f), new Integer(1) });
         } catch (Throwable t1) {
+            /* Try to use the util.concurrent library (if in classpath) */
             try {
-                /* Try to use the backport-util-concurrent library */
-                Class clazz = Class.forName(BACKPORT_CONCURRENTHASHMAP_CLASS);
-                return (Map) clazz.newInstance();
+                Class clazz = Class.forName(CONCURRENTREADERHASHMAP_CLASS);
+                cache = (Map) clazz.newInstance();
+                noPrefixCache = (Map) clazz.newInstance();
             } catch (Throwable t2) {
-                try {
-                    /* Try to use the oswego concurrent library */
-                    Class clazz = Class.forName(OSWEGO_CONCURRENTHASHMAP_CLASS);
-                    return (Map) clazz.newInstance();
-                } catch (Throwable t3) {
-                    return null;
-                }
+                /* If previous implementations fail, use internal one */
+                cache = new ConcurrentReaderHashMap();
+                noPrefixCache = new ConcurrentReaderHashMap();
             }
         }
     }
@@ -158,7 +154,7 @@
                 answer = (Map) cache.get(uri);
 
                 if (answer == null) {
-                    answer = newConcurrentHashMap();
+                    answer = new ConcurrentReaderHashMap();
                     cache.put(uri, answer);
                 }
             }




More information about the pkg-java-commits mailing list