jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r822311 - in /jackrabbit/trunk/jackrabbit-jcr2spi: ./ src/main/java/org/apache/jackrabbit/jcr2spi/ src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/
Date Tue, 06 Oct 2009 15:18:10 GMT
Author: mduerig
Date: Tue Oct  6 15:18:09 2009
New Revision: 822311

URL: http://svn.apache.org/viewvc?rev=822311&view=rev
Log:
JCR-2324: Remove dependency on EDU.oswego.cs.dl.util.concurrent

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/pom.xml
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/pom.xml?rev=822311&r1=822310&r2=822311&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/pom.xml Tue Oct  6 15:18:09 2009
@@ -124,6 +124,7 @@
     <dependency>
       <groupId>concurrent</groupId>
       <artifactId>concurrent</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=822311&r1=822310&r2=822311&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Tue Oct  6 15:18:09 2009
@@ -22,6 +22,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Semaphore;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.InvalidItemStateException;
@@ -114,9 +115,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import EDU.oswego.cs.dl.util.concurrent.Mutex;
-import EDU.oswego.cs.dl.util.concurrent.Sync;
-
 /**
  * <code>WorkspaceManager</code>...
  */
@@ -140,11 +138,11 @@
     private final ItemDefinitionProvider definitionProvider;
 
     /**
-     * Mutex to synchronize the feed thread with client
+     * Semaphore to synchronize the feed thread with client
      * threads that call {@link #execute(Operation)} or {@link
      * #execute(ChangeLog)}.
      */
-    private final Sync updateSync = new Mutex();
+    private final Semaphore updateSync = new Semaphore(1);
 
     /**
      * This is the event polling for changes. If <code>null</code>
@@ -197,8 +195,7 @@
         InternalEventListener listener = createHierarchyListener(hierarchyManager);
         if (cacheBehaviour == CacheBehaviour.OBSERVATION) {
             addEventListener(listener);
-        }
-        else {
+        } else {
             listeners.add(listener);
         }
     }
@@ -607,6 +604,11 @@
     public synchronized void dispose() {
         try {
             updateSync.acquire();
+        } catch (InterruptedException e) {
+            log.warn("Exception while disposing WorkspaceManager: " + e);
+            return;
+        }
+        try {
             if (changeFeed != null) {
                 disposeChangeFeed = true;
                 changeFeed.interrupt();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java?rev=822311&r1=822310&r2=822311&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
Tue Oct  6 15:18:09 2009
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import org.apache.jackrabbit.spi.Name;
-
-import java.util.TreeSet;
-import java.util.HashMap;
-import java.util.ArrayList;
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
 
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+import org.apache.jackrabbit.spi.Name;
 
 /**
  * Implements an effective node type cache that uses a bit set for storing the
@@ -63,7 +62,7 @@
      * be stored in the node type registry since only registered node type names
      * are allowed in the keys.
      */
-    private final ConcurrentReaderHashMap nameIndex = new ConcurrentReaderHashMap();
+    private final ConcurrentHashMap<Name, Integer> nameIndex = new ConcurrentHashMap<Name,
Integer>();
 
     /**
      * The reverse lookup table for bit numbers to names
@@ -166,13 +165,13 @@
      * @return the bit number for the given name
      */
     private int getBitNumber(Name name) {
-        Integer i = (Integer) nameIndex.get(name);
+        Integer i = nameIndex.get(name);
         if (i == null) {
             synchronized (nameIndex) {
-                i = (Integer) nameIndex.get(name);
+                i = nameIndex.get(name);
                 if (i == null) {
                     int idx = nameIndex.size();
-                    i = new Integer(idx);
+                    i = idx;
                     nameIndex.put(name, i);
                     if (idx >= names.length) {
                         Name[] newNames = new Name[names.length*2];
@@ -183,7 +182,7 @@
                 }
             }
         }
-        return i.intValue();
+        return i;
     }
 
     /**
@@ -217,6 +216,7 @@
     /**
      * @see Cloneable#clone()
      */
+    @Override
     public Object clone() {
         BitsetENTCacheImpl clone = new BitsetENTCacheImpl();
         clone.sortedKeys.addAll(sortedKeys);
@@ -453,6 +453,7 @@
         /**
          * @see Object#equals(Object)
          */
+        @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
@@ -479,6 +480,7 @@
         /**
          * @see Object#hashCode()
          */
+        @Override
         public int hashCode() {
             return hashCode;
         }
@@ -486,6 +488,7 @@
         /**
          * @see Object#toString()
          */
+        @Override
         public String toString() {
             StringBuffer buf = new StringBuffer("w=");
             buf.append(names.length);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=822311&r1=822310&r2=822311&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Tue Oct  6 15:18:09 2009
@@ -16,40 +16,41 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.version.OnParentVersionAction;
+
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
-import javax.jcr.nodetype.NodeTypeExistsException;
-import javax.jcr.version.OnParentVersionAction;
-import java.io.PrintStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.TreeSet;
-import java.util.HashMap;
-
 /**
  * A <code>NodeTypeRegistry</code> ...
  */
@@ -82,6 +83,7 @@
     /**
      * Listeners (soft references)
      */
+    @SuppressWarnings("unchecked")
     private final Map<NodeTypeRegistryListener, NodeTypeRegistryListener> listeners
= Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
     /**
@@ -660,14 +662,13 @@
     private class NodeTypeDefinitionMap implements Map<Name, QNodeTypeDefinition>,
Dumpable {
 
         // map of node type names and node type definitions
-        private final ConcurrentReaderHashMap nodetypeDefinitions = new ConcurrentReaderHashMap();
+        private final ConcurrentHashMap<Name, QNodeTypeDefinition> nodetypeDefinitions
=
+            new ConcurrentHashMap<Name, QNodeTypeDefinition>();
 
-        @SuppressWarnings("unchecked")
         private Collection<QNodeTypeDefinition> getValues() {
             return nodetypeDefinitions.values();
         }
 
-        @SuppressWarnings("unchecked")
         private Set<Name> getKeySet() {
             return nodetypeDefinitions.keySet();
         }
@@ -755,14 +756,13 @@
         }
 
         public QNodeTypeDefinition put(Name key, QNodeTypeDefinition value) {
-            return (QNodeTypeDefinition) nodetypeDefinitions.put(key, value);
+            return nodetypeDefinitions.put(key, value);
         }
 
         public void putAll(Map<? extends Name, ? extends QNodeTypeDefinition> t) {
             throw new UnsupportedOperationException("Implementation missing");
         }
 
-        @SuppressWarnings("unchecked")
         public Set<Map.Entry<Name, QNodeTypeDefinition>> entrySet() {
             // make sure all node type definitions have been loaded.
             keySet();
@@ -773,7 +773,7 @@
             if (!(key instanceof Name)) {
                 throw new IllegalArgumentException();
             }
-            QNodeTypeDefinition def = (QNodeTypeDefinition) nodetypeDefinitions.get(key);
+            QNodeTypeDefinition def = nodetypeDefinitions.get(key);
             if (def == null) {
                 try {
                     // node type does either not exist or hasn't been loaded yet
@@ -783,12 +783,12 @@
                     log.debug(e.getMessage());
                 }
             }
-            def = (QNodeTypeDefinition) nodetypeDefinitions.get(key);
+            def = nodetypeDefinitions.get(key);
             return def;
         }
 
         public QNodeTypeDefinition remove(Object key) {
-            return (QNodeTypeDefinition) nodetypeDefinitions.remove(key);
+            return nodetypeDefinitions.remove(key);
         }
 
         //-------------------------------------------------------< Dumpable >---



Mime
View raw message