FELIX-3662 switch to backport-util-concurrent for pre java 5 concurrent emulation

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1383647 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/pom.xml b/scr/pom.xml
index deab4ff..4fc4edc 100644
--- a/scr/pom.xml
+++ b/scr/pom.xml
@@ -111,12 +111,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>concurrent</groupId>
-            <artifactId>concurrent</artifactId>
-            <version>1.3.4</version>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>3.1</version>
             <scope>provided</scope>
         </dependency>
-        
+
         <!-- Integration Testing with Pax Exam -->
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
@@ -305,7 +305,21 @@
                         </DynamicImport-Package>
                         <Embed-Dependency>
                             kxml2;inline=org/kxml2/io/KXmlParser.class|org/xmlpull/v1/XmlPull**,
-                            concurrent;inline=EDU/oswego/cs/dl/util/concurrent/ReentrantWriterPreferenceReadWriteLock.class|EDU/oswego/cs/dl/util/concurrent/WriterPreferenceReadWriteLock*|EDU/oswego/cs/dl/util/concurrent/ReadWriteLock.class|EDU/oswego/cs/dl/util/concurrent/SynchronizedRef.class|EDU/oswego/cs/dl/util/concurrent/SynchronizedVariable.class|EDU/oswego/cs/dl/util/concurrent/Sync.class|EDU/oswego/cs/dl/util/concurrent/Executor.class
+                            backport-util-concurrent;inline=edu/emory/mathcs/backport/java/util/concurrent/TimeUnit.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/TimeUnit*.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/ReentrantReadWriteLock.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/ReentrantReadWriteLock*.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/ReadWriteLock.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/Lock.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/Condition.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/CondVar.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/locks/CondVar*.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/helpers/NanoTimer.class
+                            |edu/emory/mathcs/backport/java/util/Arrays.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/helpers/Utils.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/helpers/Utils*1.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/helpers/Utils*MillisProvider.class
+                            |edu/emory/mathcs/backport/java/util/concurrent/atomic/AtomicReference.class
                         </Embed-Dependency>
                     </instructions>
                 </configuration>
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
index 4c85027..80cd8f0 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
@@ -1917,50 +1917,44 @@
         }
     }
 
-    private static class EDULock extends EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock implements LockWrapper
+    private static class EDULock  implements LockWrapper
     {
+        private final edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantReadWriteLock lock = new edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantReadWriteLock( );
+
         public boolean tryReadLock( long milliseconds ) throws InterruptedException
         {
-            return readLock().attempt( milliseconds );
+             return lock.readLock().tryLock( milliseconds, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit.MILLISECONDS );
         }
 
         public long getReadHoldCount()
         {
-            return readers_.size();
+            return lock.getReadHoldCount();
         }
 
         public void unlockReadLock()
         {
-            readLock().release();
+            lock.readLock().unlock();
         }
 
         public boolean tryWriteLock( long milliseconds ) throws InterruptedException
         {
-            return writeLock().attempt( milliseconds );
+            return lock.writeLock().tryLock( milliseconds, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit.MILLISECONDS );
         }
 
         public long getWriteHoldCount()
         {
-            return writeHolds_;
+            return lock.getWriteHoldCount();
         }
 
         public void unlockWriteLock()
         {
-            writeLock().release();
+            lock.writeLock().unlock();
         }
 
         public void deescalate()
         {
-            try
-            {
-                readLock().acquire();
-            }
-            catch ( InterruptedException e )
-            {
-                //should not happen, we have the write lock
-                throw ( IllegalStateException ) new IllegalStateException( "Unexpected InterruptedException while acquiring read lock and holding write lock" ).initCause( e );
-            }
-            writeLock().release();
+            lock.readLock().lock();
+            lock.writeLock().unlock();
         }
     }
 
@@ -1996,7 +1990,7 @@
 
     private static class EDUAtomicReferenceWrapper implements AtomicReferenceWrapper
     {
-        private final EDU.oswego.cs.dl.util.concurrent.SynchronizedRef ref = new EDU.oswego.cs.dl.util.concurrent.SynchronizedRef( null );
+        private final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicReference ref = new edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicReference(  );
 
         public Object get()
         {
@@ -2004,13 +1998,13 @@
         }
 
         public void set(Object o)
-         {
-             ref.set( o );
-         }
+        {
+            ref.set( o );
+        }
 
         public boolean compareAndSet(Object expected, Object replacement)
         {
-            return ref.commit( expected, replacement );
+            return ref.compareAndSet( expected, replacement );
         }
     }