aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2011-11-07 19:43:51 (EST)
committerJohn Ross2011-11-07 19:43:51 (EST)
commitef3fa6e650dbe7273d2721dd85d92296072a374d (patch)
tree30734999c976a5327aa0f26f5ead15e8e9bc108b
parent42a48979538c0fb268cd569ed24d9736db201fc1 (diff)
downloadrt.equinox.bundles-ef3fa6e650dbe7273d2721dd85d92296072a374d.zip
rt.equinox.bundles-ef3fa6e650dbe7273d2721dd85d92296072a374d.tar.gz
rt.equinox.bundles-ef3fa6e650dbe7273d2721dd85d92296072a374d.tar.bz2
Bug 362232 - [coordinator] Add support for the new, mandatory orphaned coordination requirement.
Changed error constants to more meaningful names.
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java29
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java5
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationWeakReference.java6
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java12
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/Messages.java42
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties42
6 files changed, 67 insertions, 69 deletions
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java
index 9805cd1..5e22f5a 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.TimerTask;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.service.coordinator.Coordination;
import org.osgi.service.coordinator.CoordinationException;
@@ -55,7 +56,7 @@ public class CoordinationImpl implements Coordination {
// This method requires the PARTICIPATE permission.
coordinator.checkPermission(CoordinationPermission.PARTICIPATE, name);
if (participant == null)
- throw new NullPointerException(Messages.CoordinationImpl_15);
+ throw new NullPointerException(NLS.bind(Messages.NullParameter, "participant")); //$NON-NLS-1$
/* The caller has permission. Check to see if the participant is already
* participating in another coordination. Do this in a loop in case the
* participant must wait for the other coordination to finish. The loop
@@ -92,7 +93,7 @@ public class CoordinationImpl implements Coordination {
// any thread, and there's nothing to compare. If the coordination
// is using this thread, then we can't block due to risk of deadlock.
if (t == Thread.currentThread()) {
- throw new CoordinationException(Messages.CoordinationImpl_1, CoordinationImpl.this, CoordinationException.DEADLOCK_DETECTED);
+ throw new CoordinationException(Messages.Deadlock, CoordinationImpl.this, CoordinationException.DEADLOCK_DETECTED);
}
}
}
@@ -104,10 +105,10 @@ public class CoordinationImpl implements Coordination {
try {
coordination.join(1000);
} catch (InterruptedException e) {
- coordinator.getLogService().log(LogService.LOG_DEBUG, Messages.CoordinationImpl_2, e);
+ coordinator.getLogService().log(LogService.LOG_DEBUG, Messages.LockInterrupted, e);
// This thread was interrupted while waiting for the coordination
// to terminate.
- throw new CoordinationException(Messages.CoordinationImpl_3, CoordinationImpl.this, CoordinationException.LOCK_INTERRUPTED, e);
+ throw new CoordinationException(Messages.LockInterrupted, CoordinationImpl.this, CoordinationException.LOCK_INTERRUPTED, e);
}
}
}
@@ -122,7 +123,7 @@ public class CoordinationImpl implements Coordination {
// Coordinations may only be ended by the same thread that
// pushed them onto the stack, if any.
if (thread != Thread.currentThread()) {
- throw new CoordinationException(Messages.CoordinationImpl_14, this, CoordinationException.WRONG_THREAD);
+ throw new CoordinationException(Messages.EndingThreadNotSame, this, CoordinationException.WRONG_THREAD);
}
// Unwind the stack in case there are other coordinations higher
// up than this one.
@@ -151,7 +152,7 @@ public class CoordinationImpl implements Coordination {
try {
participant.ended(referent);
} catch (Exception e) {
- coordinator.getLogService().log(LogService.LOG_WARNING, Messages.CoordinationImpl_4, e);
+ coordinator.getLogService().log(LogService.LOG_WARNING, Messages.ParticipantEndedError, e);
// Only the first exception will be propagated.
if (exception == null)
exception = e;
@@ -163,7 +164,7 @@ public class CoordinationImpl implements Coordination {
}
// If a partial ending has occurred, throw the required exception.
if (exception != null) {
- throw new CoordinationException(Messages.CoordinationImpl_5, this, CoordinationException.PARTIALLY_ENDED, exception);
+ throw new CoordinationException(Messages.CoordinationPartiallyEnded, this, CoordinationException.PARTIALLY_ENDED, exception);
}
}
@@ -200,7 +201,7 @@ public class CoordinationImpl implements Coordination {
checkTerminated();
}
catch (InterruptedException e) {
- throw new CoordinationException(Messages.CoordinationImpl_13, this, CoordinationException.UNKNOWN, e);
+ throw new CoordinationException(Messages.InterruptedTimeoutExtension, this, CoordinationException.UNKNOWN, e);
}
}
// Create the new timeout.
@@ -218,7 +219,7 @@ public class CoordinationImpl implements Coordination {
coordinator.checkPermission(CoordinationPermission.PARTICIPATE, name);
// The reason must not be null.
if (reason == null)
- throw new NullPointerException(Messages.CoordinationImpl_11);
+ throw new NullPointerException(Messages.MissingFailureCause);
// Terminating the coordination must be atomic.
synchronized (this) {
// If this coordination is terminated, return false. Do not throw a
@@ -238,7 +239,7 @@ public class CoordinationImpl implements Coordination {
try {
participant.failed(referent);
} catch (Exception e) {
- coordinator.getLogService().log(LogService.LOG_WARNING, Messages.CoordinationImpl_6, e);
+ coordinator.getLogService().log(LogService.LOG_WARNING, Messages.ParticipantFailedError, e);
}
}
synchronized (this) {
@@ -346,11 +347,11 @@ public class CoordinationImpl implements Coordination {
// must be thrown.
if (failure != null) {
// The fail() method was called indicating the coordination failed.
- throw new CoordinationException(Messages.CoordinationImpl_7, this, CoordinationException.FAILED, failure);
+ throw new CoordinationException(Messages.CoordinationFailed, this, CoordinationException.FAILED, failure);
}
// The coordination did not fail, so it either partially ended or
// ended successfully.
- throw new CoordinationException(Messages.CoordinationImpl_8, CoordinationImpl.this, CoordinationException.ALREADY_ENDED);
+ throw new CoordinationException(Messages.CoordinationEnded, CoordinationImpl.this, CoordinationException.ALREADY_ENDED);
}
private void terminate() throws CoordinationException {
@@ -381,11 +382,11 @@ public class CoordinationImpl implements Coordination {
}
}
if (!valid)
- throw new IllegalArgumentException(Messages.CoordinationImpl_10);
+ throw new IllegalArgumentException(Messages.InvalidCoordinationName);
}
private static void validateTimeout(long timeout) {
if (timeout < 0)
- throw new IllegalArgumentException(Messages.CoordinationImpl_12);
+ throw new IllegalArgumentException(Messages.InvalidTimeout);
}
}
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java
index 8c243d3..b65321e 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationTimerTask.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.coordinator;
import java.util.TimerTask;
+import org.eclipse.osgi.util.NLS;
import org.osgi.service.coordinator.Coordination;
import org.osgi.service.log.LogService;
@@ -20,7 +21,7 @@ public class CoordinationTimerTask extends TimerTask {
public CoordinationTimerTask(CoordinationImpl coordination) {
if (coordination == null)
- throw new IllegalArgumentException(Messages.CoordinationImpl_0);
+ throw new NullPointerException(NLS.bind(Messages.NullParameter, "coordination")); //$NON-NLS-1$
this.coordination = coordination;
}
@@ -31,7 +32,7 @@ public class CoordinationTimerTask extends TimerTask {
try {
coordination.fail(Coordination.TIMEOUT);
} catch (Throwable t) {
- coordination.getLogService().log(LogService.LOG_ERROR, Messages.CoordinationImpl_9, t);
+ coordination.getLogService().log(LogService.LOG_ERROR, Messages.CoordinationTimedOutError, t);
}
}
}
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationWeakReference.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationWeakReference.java
index 27dcbc0..d2d25de 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationWeakReference.java
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationWeakReference.java
@@ -40,7 +40,7 @@ public class CoordinationWeakReference extends WeakReference<CoordinationReferen
c.fail(Coordination.ORPHANED);
}
catch (Throwable t) {
- c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.CoordinatorImpl_5, c.getName(), c.getId()), t);
+ c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.OrphanedCoordinationError, c.getName(), c.getId()), t);
}
finally {
try {
@@ -50,10 +50,10 @@ public class CoordinationWeakReference extends WeakReference<CoordinationReferen
// This is expected since we already failed the coordination...
if (!Coordination.ORPHANED.equals(e.getCause()))
// ...but only if the cause is ORPHANED.
- c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.CoordinatorImpl_5, c.getName(), c.getId()), e);
+ c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.OrphanedCoordinationError, c.getName(), c.getId()), e);
}
catch (Throwable t) {
- c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.CoordinatorImpl_5, c.getName(), c.getId()), t);
+ c.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.OrphanedCoordinationError, c.getName(), c.getId()), t);
}
}
}
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java
index e143240..df748c3 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinatorImpl.java
@@ -36,7 +36,7 @@ public class CoordinatorImpl implements Coordinator {
private synchronized static long getNextId() {
if (Long.MAX_VALUE == lastId)
- throw new IllegalStateException(Messages.CoordinatorImpl_0);
+ throw new IllegalStateException(Messages.MaxCoordinationIdExceeded);
// First ID will be 1.
return ++lastId;
}
@@ -80,7 +80,7 @@ public class CoordinatorImpl implements Coordinator {
public void push(CoordinationImpl c) {
if (contains(c))
- throw new CoordinationException(Messages.CoordinatorImpl_3, c, CoordinationException.ALREADY_PUSHED);
+ throw new CoordinationException(Messages.CoordinationAlreadyExists, c, CoordinationException.ALREADY_PUSHED);
c.setThreadAndEnclosingCoordination(Thread.currentThread(), coordinations.isEmpty() ? null : coordinations.getFirst());
coordinations.addFirst(c);
}
@@ -123,7 +123,7 @@ public class CoordinatorImpl implements Coordinator {
CoordinationReferent referent = new CoordinationReferent(coordination);
synchronized (this) {
if (shutdown)
- throw new IllegalStateException(Messages.CoordinatorImpl_2);
+ throw new IllegalStateException(Messages.CoordinatorShutdown);
synchronized (CoordinatorImpl.class) {
CoordinationWeakReference.newInstance(referent);
coordinations.add(coordination);
@@ -158,7 +158,7 @@ public class CoordinatorImpl implements Coordinator {
try {
checkPermission(CoordinationPermission.ADMIN, result.getName());
} catch (SecurityException e) {
- logService.log(LogService.LOG_DEBUG, Messages.CoordinatorImpl_1, e);
+ logService.log(LogService.LOG_DEBUG, Messages.GetCoordinationNotPermitted, e);
result = null;
}
}
@@ -179,7 +179,7 @@ public class CoordinatorImpl implements Coordinator {
checkPermission(CoordinationPermission.ADMIN, coordination.getName());
result.add(new CoordinationReferent(coordination));
} catch (SecurityException e) {
- logService.log(LogService.LOG_DEBUG, Messages.CoordinatorImpl_1, e);
+ logService.log(LogService.LOG_DEBUG, Messages.GetCoordinationNotPermitted, e);
}
}
}
@@ -238,7 +238,7 @@ public class CoordinatorImpl implements Coordinator {
try {
Timer.class.getMethod("purge", (Class<?>[]) null).invoke(timer, (Object[]) null); //$NON-NLS-1$
} catch (Exception e) {
- logService.log(LogService.LOG_DEBUG, Messages.CoordinatorImpl_4, e);
+ logService.log(LogService.LOG_DEBUG, Messages.CanceledTaskNotPurged, e);
}
}
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/Messages.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/Messages.java
index 6603c51..57b96c6 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/Messages.java
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/Messages.java
@@ -14,28 +14,26 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.equinox.coordinator.messages"; //$NON-NLS-1$
- public static String CoordinationImpl_0;
- public static String CoordinationImpl_1;
- public static String CoordinationImpl_10;
- public static String CoordinationImpl_11;
- public static String CoordinationImpl_12;
- public static String CoordinationImpl_13;
- public static String CoordinationImpl_14;
- public static String CoordinationImpl_15;
- public static String CoordinationImpl_2;
- public static String CoordinationImpl_3;
- public static String CoordinationImpl_4;
- public static String CoordinationImpl_5;
- public static String CoordinationImpl_6;
- public static String CoordinationImpl_7;
- public static String CoordinationImpl_8;
- public static String CoordinationImpl_9;
- public static String CoordinatorImpl_0;
- public static String CoordinatorImpl_1;
- public static String CoordinatorImpl_2;
- public static String CoordinatorImpl_3;
- public static String CoordinatorImpl_4;
- public static String CoordinatorImpl_5;
+ public static String NullParameter;
+ public static String Deadlock;
+ public static String InvalidCoordinationName;
+ public static String MissingFailureCause;
+ public static String InvalidTimeout;
+ public static String InterruptedTimeoutExtension;
+ public static String EndingThreadNotSame;
+ public static String LockInterrupted;
+ public static String ParticipantEndedError;
+ public static String CoordinationPartiallyEnded;
+ public static String ParticipantFailedError;
+ public static String CoordinationFailed;
+ public static String CoordinationEnded;
+ public static String CoordinationTimedOutError;
+ public static String MaxCoordinationIdExceeded;
+ public static String GetCoordinationNotPermitted;
+ public static String CoordinatorShutdown;
+ public static String CoordinationAlreadyExists;
+ public static String CanceledTaskNotPurged;
+ public static String OrphanedCoordinationError;
static {
// initialize resource bundle
diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties
index fc33abc..a4ca732 100644
--- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties
+++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/messages.properties
@@ -8,25 +8,23 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-CoordinationImpl_0=Parameter must not be null: coordination
-CoordinationImpl_1=Deadlock detected
-CoordinationImpl_10=The coordination name does not match the Bundle Symbolic Name pattern
-CoordinationImpl_11=A reason must be specified when failing a coordination
-CoordinationImpl_12=A timeout must be a non-negative integer
-CoordinationImpl_13=The timeout could not be extended because the previous one had already expired. The current thread was interrupted before it was possible to determine how this coordination terminated.
-CoordinationImpl_14=Coordinations may only be ended by the same thread that pushed them onto the thread local stack
-CoordinationImpl_15=The participant to add was null
-CoordinationImpl_2=The lock was interrupted
-CoordinationImpl_3=The lock was interrupted
-CoordinationImpl_4=A participant indicated an error occurred while the coordination was ending
-CoordinationImpl_5=Partially ended
-CoordinationImpl_6=A participant indicated an error occurred while the coordination was failing
-CoordinationImpl_7=Coordination has failed
-CoordinationImpl_8=Coordination has already ended
-CoordinationImpl_9=An unexpected exception occurred while failing a coordination. This will not stop the timer thread.
-CoordinatorImpl_0=The next Coordinator ID would exceed the maximum possible value
-CoordinatorImpl_1=A requester did not have permission to view a coordination
-CoordinatorImpl_2=This coordinator has been shutdown
-CoordinatorImpl_3=Coordination already exists
-CoordinatorImpl_4=Unable to purge the canceled task
-CoordinatorImpl_5=An error occurred while processing orphaned coordination {0} with ID {1}.
+NullParameter=Parameter must not be null: {0}
+Deadlock=Deadlock detected
+InvalidCoordinationName=The coordination name does not match the Bundle Symbolic Name pattern
+MissingFailureCause=A reason must be specified when failing a coordination
+InvalidTimeout=A timeout must be a non-negative integer
+InterruptedTimeoutExtension=The timeout could not be extended because the previous one had already expired. The current thread was interrupted before it was possible to determine how this coordination terminated.
+EndingThreadNotSame=Coordinations may only be ended by the same thread that pushed them onto the thread local stack
+LockInterrupted=The lock was interrupted
+ParticipantEndedError=A participant indicated an error occurred while the coordination was ending
+CoordinationPartiallyEnded=Partially ended
+ParticipantFailedError=A participant indicated an error occurred while the coordination was failing
+CoordinationFailed=Coordination has failed
+CoordinationEnded=Coordination has already ended
+CoordinationTimedOutError=An unexpected exception occurred while failing a coordination. This will not stop the timer thread.
+MaxCoordinationIdExceeded=The next coordination ID would exceed the maximum possible value
+GetCoordinationNotPermitted=A requester did not have permission to view a coordination
+CoordinatorShutdown=This coordinator has been shutdown
+CoordinationAlreadyExists=Coordination already exists
+CanceledTaskNotPurged=Unable to purge the canceled task
+OrphanedCoordinationError=An error occurred while processing orphaned coordination {0} with ID {1}.