FELIX-3747 Cleanup project for Java 5 release
- Remove commented sections in pom.xml
- Configure Animal Sniffer for Java 5
- Configure compiler for Java 5 source and target
- Remove backport util 3.1 dependency
- Use Java Util classes directly (wihtout wrappers)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1406546 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/pom.xml b/scr/pom.xml
index 499cf3c..2c9ec0a 100644
--- a/scr/pom.xml
+++ b/scr/pom.xml
@@ -110,12 +110,6 @@
<version>2.2.2</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>backport-util-concurrent</groupId>
- <artifactId>backport-util-concurrent</artifactId>
- <version>3.1</version>
- <scope>provided</scope>
- </dependency>
<!-- Integration Testing with Pax Exam -->
<dependency>
@@ -305,21 +299,6 @@
</DynamicImport-Package>
<Embed-Dependency>
kxml2;inline=org/kxml2/io/KXmlParser.class|org/xmlpull/v1/XmlPull**,
- 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/ReentrantLock.class
- |edu/emory/mathcs/backport/java/util/concurrent/locks/ReentrantLock*.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>
@@ -327,10 +306,8 @@
<!--
Ensure not using too recent Java API
- - for now touch base on Java 1.4
- - Ignore some known Java 5 classes (used in JLock)
+ - Ensure Java 5 API
-->
-<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
@@ -338,17 +315,9 @@
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
- <artifactId>java14</artifactId>
+ <artifactId>java15</artifactId>
<version>1.0</version>
</signature>
- <ignores>
- <ignore>java.util.concurrent.atomic.AtomicReference</ignore>
- <ignore>java.util.concurrent.locks.ReentrantLock</ignore>
- <ignore>java.util.concurrent.TimeUnit</ignore>
- <ignore>java.lang.management.ManagementFactory</ignore>
- <ignore>java.lang.management.ThreadInfo</ignore>
- <ignore>java.lang.management.ThreadMXBean</ignore>
- </ignores>
</configuration>
<executions>
<execution>
@@ -359,60 +328,15 @@
</execution>
</executions>
</plugin>
--->
<!--
- Configure default compilation for Java 1.3 and integration
- test compilation for Java 5 (since integration tests use
- Java Annotations for Pax Exam).
- Also configure the compilation of the Gogo Command class
- (using Java 5 annotations) with Java 5 target.
+ Configure default compilation for Java 5
-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>compile-java5</id>-->
- <!--<goals>-->
- <!--<goal>compile</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<source>1.5</source>-->
- <!--<target>1.5</target>-->
- <!--<excludes>-->
- <!--<exclude>dummy-to-overwrite-global-config</exclude>-->
- <!--</excludes>-->
- <!--<includes>-->
- <!--<include>**/ScrGogoCommand.java</include>-->
- <!--</includes>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--<execution>-->
- <!--<id>test-compile-java5</id>-->
- <!--<goals>-->
- <!--<goal>testCompile</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<source>1.5</source>-->
- <!--<target>1.5</target>-->
- <!--<testIncludes>-->
- <!--<testInclude>**/integration/**</testInclude>-->
- <!--</testIncludes>-->
- <!--<testExcludes>-->
- <!--<testExclude>**/impl/**</testExclude>-->
- <!--</testExcludes>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--</executions>-->
<configuration>
<source>1.5</source>
<target>1.5</target>
- <!--<testExcludes>-->
- <!--<testExclude>**/integration/**</testExclude>-->
- <!--</testExcludes>-->
- <!--<excludes>-->
- <!--<exclude>**/ScrGogoCommand.java</exclude>-->
- <!--</excludes>-->
</configuration>
</plugin>
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 190b1d5..dac31af 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
@@ -62,22 +62,6 @@
public abstract class AbstractComponentManager implements Component, SimpleLogger
{
- private static final boolean JUC_AVAILABLE;
-
- static {
- boolean juc_available;
- try
- {
- new JLock();
- juc_available = true;
- }
- catch (Throwable t)
- {
- juc_available = false;
- }
- JUC_AVAILABLE = juc_available;
- }
-
// the ID of this component
private long m_componentId;
@@ -97,15 +81,15 @@
private boolean m_dependencyManagersInitialized;
//<Map<DependencyManager, Map<ServiceReference, RefPair>>>
- private final AtomicReferenceWrapper m_dependencies_map;
+ private final AtomicReference m_dependencies_map;
// A reference to the BundleComponentActivator
private BundleComponentActivator m_activator;
// The ServiceRegistration
- private final AtomicReferenceWrapper m_serviceRegistration;
+ private final AtomicReference m_serviceRegistration;
- private final LockWrapper m_stateLock;
+ private final ReentrantLock m_stateLock;
private long m_timeout = 5000;
@@ -140,18 +124,9 @@
m_state = Disabled.getInstance();
m_dependencyManagers = loadDependencyManagers( metadata );
- if (JUC_AVAILABLE)
- {
- m_stateLock = new JLock();
- m_dependencies_map = new JAtomicReferenceWrapper();
- m_serviceRegistration = new JAtomicReferenceWrapper();
- }
- else
- {
- m_stateLock = new EDULock();
- m_dependencies_map = new EDUAtomicReferenceWrapper();
- m_serviceRegistration = new EDUAtomicReferenceWrapper();
- }
+ m_stateLock = new ReentrantLock( true );
+ m_dependencies_map = new AtomicReference();
+ m_serviceRegistration = new AtomicReference();
// dump component details
if ( isLogEnabled( LogService.LOG_DEBUG ) )
@@ -189,7 +164,7 @@
// }
try
{
- if (!m_stateLock.tryLock( m_timeout ) )
+ if (!m_stateLock.tryLock( m_timeout, TimeUnit.MILLISECONDS ) )
{
// lockingActivity.add( "obtainWriteLock failure from: " + source + " readLocks: " + m_stateLock.getReadHoldCount() + " writeLocks: " + m_stateLock.getWriteHoldCount() + " thread: " + Thread.currentThread() + " time: " + System.currentTimeMillis() + " Could not obtain write lock.");
throw new IllegalStateException( "Could not obtain lock" );
@@ -1858,104 +1833,4 @@
throw new IllegalStateException( "enable: " + this );
}
}
-
- private static interface LockWrapper
- {
- boolean tryLock( long milliseconds ) throws InterruptedException;
- long getHoldCount();
- void unlock();
-
-
- }
-
- private static class JLock implements LockWrapper
- {
- private final ReentrantLock lock = new ReentrantLock( true );
-
- public boolean tryLock( long milliseconds ) throws InterruptedException
- {
- return lock.tryLock( milliseconds, TimeUnit.MILLISECONDS );
- }
-
- public long getHoldCount()
- {
- return lock.getHoldCount();
- }
-
- public void unlock()
- {
- lock.unlock();
- }
- }
-
- private static class EDULock implements LockWrapper
- {
- private final edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock lock = new edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock( );
-
- public boolean tryLock( long milliseconds ) throws InterruptedException
- {
- return lock.tryLock( milliseconds, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit.MILLISECONDS );
- }
-
- public long getHoldCount()
- {
- return lock.getHoldCount();
- }
-
- public void unlock()
- {
- lock.unlock();
- }
- }
-
- private interface AtomicReferenceWrapper
- {
- Object get();
-
- void set(Object o);
-
- boolean compareAndSet(Object expected, Object replacement);
-
- }
-
- private static class JAtomicReferenceWrapper implements AtomicReferenceWrapper
- {
- private final AtomicReference ref = new AtomicReference( );
-
- public Object get()
- {
- return ref.get();
- }
-
- public void set(Object o)
- {
- ref.set( o );
- }
-
- public boolean compareAndSet(Object expected, Object replacement)
- {
- return ref.compareAndSet( expected, replacement );
- }
- }
-
- private static class EDUAtomicReferenceWrapper implements AtomicReferenceWrapper
- {
- 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()
- {
- return ref.get();
- }
-
- public void set(Object o)
- {
- ref.set( o );
- }
-
- public boolean compareAndSet(Object expected, Object replacement)
- {
- return ref.compareAndSet( expected, replacement );
- }
- }
-
}