[jboss-osgi-commits] JBoss-OSGI SVN: r89473 - projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed May 27 11:40:19 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-27 11:40:19 -0400 (Wed, 27 May 2009)
New Revision: 89473

Modified:
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java
Log:
Only uninstall when in state INSTALLED || ACTIVE

Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java	2009-05-27 15:33:29 UTC (rev 89472)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerHelper.java	2009-05-27 15:40:19 UTC (rev 89473)
@@ -30,6 +30,7 @@
 import org.jboss.osgi.common.log.LogServiceTracker;
 import org.jboss.osgi.service.hotdeploy.BundleInfo;
 import org.jboss.osgi.service.hotdeploy.DeploymentScanner;
+import org.jboss.osgi.service.hotdeploy.BundleInfo.State;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -68,6 +69,38 @@
       lastScan = currScan;
    }
 
+   private void processOldDeployments(List<BundleInfo> currScan)
+   {
+      List<BundleInfo> diff = new ArrayList<BundleInfo>();
+
+      // Detect OLD bundles that are not in the current scan  
+      for (BundleInfo info : lastScan)
+      {
+         if (currScan.contains(info) == false)
+            diff.add(info);
+      }
+
+      for (BundleInfo info : diff)
+      {
+         Bundle bundle = getInstalledBundle(context, info.getSymbolicName());
+         if (bundle != null)
+         {
+            if (info.getState() == State.INSTALLED || info.getState() == State.ACTIVE)
+            {
+               try
+               {
+                  log.log(LogService.LOG_INFO, "Uninstall: " + info.getSymbolicName());
+                  bundle.uninstall();
+               }
+               catch (BundleException ex)
+               {
+                  log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
+               }
+            }
+         }
+      }
+   }
+
    private void processNewDeployments(List<BundleInfo> currScan)
    {
       List<BundleInfo> diff = new ArrayList<BundleInfo>();
@@ -110,32 +143,6 @@
       }
    }
 
-   private void processOldDeployments(List<BundleInfo> currScan)
-   {
-      List<BundleInfo> diff = new ArrayList<BundleInfo>();
-
-      // Detect OLD bundles that are not in the current scan  
-      for (BundleInfo info : lastScan)
-      {
-         if (currScan.contains(info) == false)
-            diff.add(info);
-      }
-
-      for (BundleInfo info : diff)
-      {
-         Bundle bundle = getInstalledBundle(context, info.getSymbolicName());
-         try
-         {
-            log.log(LogService.LOG_INFO, "Uninstall: " + info.getSymbolicName());
-            bundle.uninstall();
-         }
-         catch (BundleException ex)
-         {
-            log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
-         }
-      }
-   }
-
    static Bundle getInstalledBundle(BundleContext context, String symbolicName)
    {
       Bundle bundle = null;




More information about the jboss-osgi-commits mailing list