[jboss-cvs] JBossAS SVN: r90237 - projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 16 04:03:11 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-06-16 04:03:11 -0400 (Tue, 16 Jun 2009)
New Revision: 90237
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
Log:
optimize uninstall code
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:55:57 UTC (rev 90236)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 08:03:11 UTC (rev 90237)
@@ -44,7 +44,6 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.service.log.LogReaderService;
@@ -112,7 +111,6 @@
{
OSGiBundle bundle = installBundle(location);
bundle.start();
- bundles.put(location, bundle);
}
else
{
@@ -137,20 +135,7 @@
Collections.reverse(bundleLocations);
for (String location : bundleLocations)
- {
- OSGiBundle bundle = bundles.remove(location);
- if (bundle != null)
- {
- try
- {
- bundle.uninstall();
- }
- catch (BundleException ex)
- {
- log.error("Cannot uninstall bundle: " + bundle);
- }
- }
- }
+ failsafeUninstall(bundles.remove(location));
}
List<Capability> dependencies = capability.getDependencies();
@@ -183,25 +168,13 @@
stopLogEntryTracking();
// Uninstall the registered bundles
- ArrayList<String> bundleLocations = new ArrayList<String>(bundles.keySet());
- Collections.reverse(bundleLocations);
+ ArrayList<String> locations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(locations);
- while (bundleLocations.size() > 0)
+ while (locations.size() > 0)
{
- String location = bundleLocations.remove(0);
- OSGiBundle bundle = bundles.remove(location);
- if (bundle != null)
- {
- try
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
- }
- catch (BundleException ex)
- {
- log.warn("Cannot uninstall: " + bundle, ex);
- }
- }
+ String location = locations.remove(0);
+ failsafeUninstall(bundles.remove(location));
}
// Uninstall the capabilities
@@ -284,4 +257,18 @@
return symbolicName;
}
+ private void failsafeUninstall(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.warn("Cannot uninstall bundle: " + bundle, ex);
+ }
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list