You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2010/10/27 08:52:59 UTC
svn commit: r1027832 - in /felix/trunk/coordinator: pom.xml
src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java
Author: fmeschbe
Date: Wed Oct 27 06:52:59 2010
New Revision: 1027832
URL: http://svn.apache.org/viewvc?rev=1027832&view=rev
Log:
Use target of "jsr14" for compilation with the following effects:
- Source level 5 indicates support for generics
- Target jsr14 compiles JDK 14 (Class version 48) classes
- Take care to not use other Java 5 features like Annotations and Enum
(Thus replace enum State with plain old int constants)
Modified:
felix/trunk/coordinator/pom.xml
felix/trunk/coordinator/src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java
Modified: felix/trunk/coordinator/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/pom.xml?rev=1027832&r1=1027831&r2=1027832&view=diff
==============================================================================
--- felix/trunk/coordinator/pom.xml (original)
+++ felix/trunk/coordinator/pom.xml Wed Oct 27 06:52:59 2010
@@ -42,7 +42,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>5</source>
- <target>5</target>
+ <target>jsr14</target>
</configuration>
</plugin>
<plugin>
Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java?rev=1027832&r1=1027831&r2=1027832&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java (original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordination/impl/CoordinationImpl.java Wed Oct 27 06:52:59 2010
@@ -31,19 +31,17 @@ import org.apache.felix.service.coordina
@SuppressWarnings("deprecation")
public class CoordinationImpl implements Coordination {
- private enum State {
- /** Active */
- ACTIVE,
+ /** Active */
+ private static final int ACTIVE = 1;
- /** Coordination termination started */
- TERMINATING,
+ /** Coordination termination started */
+ private static final int TERMINATING = 2;
- /** Coordination completed */
- TERMINATED,
+ /** Coordination completed */
+ private static final int TERMINATED = 3;
- /** Coordination failed */
- FAILED;
- }
+ /** Coordination failed */
+ private static final int FAILED = 4;
private final CoordinationMgr mgr;
@@ -56,12 +54,11 @@ public class CoordinationImpl implements
/**
* Access to this field must be synchronized as long as the expected state
- * is {@link State#ACTIVE}. Once the state has changed, further updates to
- * this instance will not take place any more and the state will only be
- * modified by the thread successfully setting the state to
- * {@link State#TERMINATING}.
+ * is {@link #ACTIVE}. Once the state has changed, further updates to this
+ * instance will not take place any more and the state will only be modified
+ * by the thread successfully setting the state to {@link #TERMINATING}.
*/
- private volatile State state;
+ private volatile int state;
private int mustFail;
@@ -81,7 +78,7 @@ public class CoordinationImpl implements
this.id = id;
this.name = name;
this.mustFail = 0;
- this.state = State.ACTIVE;
+ this.state = ACTIVE;
this.participants = new ArrayList<Participant>();
this.variables = new HashMap<Class<?>, Object>();
this.timeOutInMs = -defaultTimeOutInMs;
@@ -144,7 +141,7 @@ public class CoordinationImpl implements
}
public boolean terminate() {
- if (state == State.ACTIVE) {
+ if (state == ACTIVE) {
try {
end();
return true;
@@ -165,7 +162,7 @@ public class CoordinationImpl implements
* the coordination is in the process of terminating due to a failure.
*/
public boolean isFailed() {
- return state == State.FAILED;
+ return state == FAILED;
}
/**
@@ -175,7 +172,7 @@ public class CoordinationImpl implements
* the coordination is in the process of terminating.
*/
public boolean isTerminated() {
- return state == State.TERMINATED;
+ return state == TERMINATED;
}
public void addTimeout(long timeOutInMs) {
@@ -210,7 +207,7 @@ public class CoordinationImpl implements
// synchronize access to the state to prevent it from being changed
// while adding the participant
synchronized (this) {
- if (state == State.ACTIVE) {
+ if (state == ACTIVE) {
if (!participants.contains(p)) {
participants.add(p);
}
@@ -224,7 +221,7 @@ public class CoordinationImpl implements
// synchronize access to the state to prevent it from being changed
// while we create a copy of the participant list
synchronized (this) {
- if (state == State.ACTIVE) {
+ if (state == ACTIVE) {
return new ArrayList<Participant>(participants);
}
}
@@ -249,8 +246,8 @@ public class CoordinationImpl implements
* thread and no further termination processing must take place.
*/
private synchronized boolean startTermination() {
- if (state == State.ACTIVE) {
- state = State.TERMINATING;
+ if (state == ACTIVE) {
+ state = TERMINATING;
mgr.unregister(this);
scheduleTimeout(-1);
return true;
@@ -283,7 +280,7 @@ public class CoordinationImpl implements
// release the participant for other coordinations
mgr.releaseParticipant(part);
}
- state = State.TERMINATED;
+ state = TERMINATED;
return reason;
}
@@ -306,7 +303,7 @@ public class CoordinationImpl implements
// release the participant for other coordinations
mgr.releaseParticipant(part);
}
- state = State.FAILED;
+ state = FAILED;
}
/**