diff --git a/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/Activator.java b/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/Activator.java index 759e107de3..8002b9f458 100644 --- a/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/Activator.java +++ b/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/Activator.java @@ -28,7 +28,7 @@ public class Activator implements BundleActivator { public void start(BundleContext bundleContext) throws Exception { QuiesceManager manager = new QuiesceManagerImpl(bundleContext); - serviceReg = bundleContext.registerService(QuiesceManager.class.getName(), manager, null); + serviceReg = bundleContext.registerService(QuiesceManager.class, manager, null); } public void stop(BundleContext bundleContext) throws Exception { diff --git a/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/QuiesceManagerImpl.java b/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/QuiesceManagerImpl.java index 64be212c43..ae83e74446 100644 --- a/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/QuiesceManagerImpl.java +++ b/quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/QuiesceManagerImpl.java @@ -14,6 +14,7 @@ package org.apache.aries.quiesce.manager.impl; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -97,7 +98,7 @@ public Future quiesceWithFuture(List bundlesToQuiesce) { public Future quiesceWithFuture(long timeout, List bundles) { QuiesceFuture result = new QuiesceFuture(); - if (bundles != null && !!!bundles.isEmpty()) { + if (bundles != null && !bundles.isEmpty()) { //check that bundle b is not already quiescing Iterator it = bundles.iterator(); Set bundlesToQuiesce = new HashSet(); @@ -134,7 +135,7 @@ public Object get() throws InterruptedException, ExecutionException { } public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - if (!!!latch.await(timeout, unit)) + if (!latch.await(timeout, unit)) throw new TimeoutException(); return null; @@ -149,7 +150,7 @@ public boolean isDone() { } public void registerDone() { - if (!!!isDone()) { + if (!isDone()) { latch.countDown(); } } @@ -217,8 +218,9 @@ public BundleQuiescer(Set bundlesToQuiesce, long timeout, QuiesceFuture public void run() { try { if (bundleContext != null) { - ServiceReference[] serviceRefs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null); - if (serviceRefs != null) { + Collection> serviceRefs = + bundleContext.getServiceReferences(QuiesceParticipant.class, null); + if (serviceRefs != null && !serviceRefs.isEmpty()) { List participants = new ArrayList(); final List callbacks = new ArrayList(); List copyOfBundles = new ArrayList(bundlesToQuiesce); @@ -241,8 +243,8 @@ public void run() { //Create callback objects for all participants - for( ServiceReference sr : serviceRefs ) { - QuiesceParticipant participant = (QuiesceParticipant) bundleContext.getService(sr); + for( ServiceReference sr : serviceRefs ) { + QuiesceParticipant participant = bundleContext.getService(sr); participants.add(participant); callbacks.add(new QuiesceCallbackImpl(bundlesToQuiesce, callbacks, future, timeoutFuture)); } @@ -311,10 +313,10 @@ public void bundleQuiesced(Bundle... bundlesQuiesced) { synchronized (allCallbacks) { for(Bundle b : bundlesQuiesced) { - if(QuiesceManagerImpl.stillQuiescing(b)) { + if(stillQuiescing(b)) { if(toQuiesce.remove(b)) { if(checkOthers(b)){ - QuiesceManagerImpl.stopBundle(b, toQuiesceShared); + stopBundle(b, toQuiesceShared); if(allCallbacksComplete()){ future.registerDone(); timeoutFuture.cancel(false); @@ -340,7 +342,7 @@ private boolean checkOthers(Bundle b) { boolean allDone = true; Iterator it = allCallbacks.iterator(); while (allDone && it.hasNext()) { - allDone = !!!it.next().toQuiesce.contains(b); + allDone = !it.next().toQuiesce.contains(b); } return allDone; } @@ -350,9 +352,9 @@ private boolean allCallbacksComplete() { Iterator it = allCallbacks.iterator(); while (allDone && it.hasNext()) { QuiesceCallbackImpl next = it.next(); - if (!!!next.toQuiesce.isEmpty()) allDone = false; + if (!next.toQuiesce.isEmpty()) allDone = false; } return allDone; } } -} \ No newline at end of file +}