[jboss-cvs] JBossAS SVN: r89500 - in projects/jboss-osgi/trunk: 3rdparty/jboss-xml-binding and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 28 15:46:11 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-28 15:46:11 -0400 (Thu, 28 May 2009)
New Revision: 89500

Added:
   projects/jboss-osgi/trunk/3rdparty/jboss-xml-binding/
Removed:
   projects/jboss-osgi/trunk/3rdparty/jbossxb/
   projects/jboss-osgi/trunk/bundles/logging/
Modified:
   projects/jboss-osgi/trunk/3rdparty/jboss-xml-binding/.classpath
   projects/jboss-osgi/trunk/3rdparty/pom.xml
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
   projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
Log:
Fix duplicate deployment from DeploymentScanner

Copied: projects/jboss-osgi/trunk/3rdparty/jboss-xml-binding (from rev 89499, projects/jboss-osgi/trunk/3rdparty/jbossxb)

Modified: projects/jboss-osgi/trunk/3rdparty/jboss-xml-binding/.classpath
===================================================================
--- projects/jboss-osgi/trunk/3rdparty/jbossxb/.classpath	2009-05-28 18:36:22 UTC (rev 89499)
+++ projects/jboss-osgi/trunk/3rdparty/jboss-xml-binding/.classpath	2009-05-28 19:46:11 UTC (rev 89500)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
-	<classpathentry kind="src" path="src/main/resources"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: projects/jboss-osgi/trunk/3rdparty/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/3rdparty/pom.xml	2009-05-28 18:36:22 UTC (rev 89499)
+++ projects/jboss-osgi/trunk/3rdparty/pom.xml	2009-05-28 19:46:11 UTC (rev 89500)
@@ -17,7 +17,7 @@
     <module>apache-xerces</module>
     <module>jaxb</module>
     <module>jboss-common-core</module>
-    <module>jbossxb</module>
+    <module>jboss-xml-binding</module>
   </modules>
   
 </project>

Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-05-28 18:36:22 UTC (rev 89499)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-05-28 19:46:11 UTC (rev 89500)
@@ -40,6 +40,7 @@
 import org.jboss.osgi.common.service.BundleInfo;
 import org.jboss.osgi.common.service.DeployerService;
 import org.jboss.osgi.common.service.DeploymentScannerService;
+import org.jboss.osgi.common.service.BundleInfo.State;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -65,6 +66,7 @@
    private ScannerThread scannerThread;
    private DeployerService deployerService;
    private List<BundleInfo> lastScan = new ArrayList<BundleInfo>();
+   private boolean traceBundles = false;
 
    public DeploymentScannerImpl(BundleContext context)
    {
@@ -89,7 +91,7 @@
          }
       };
       tracker.open();
-      
+
       initScanner(context);
    }
 
@@ -114,6 +116,9 @@
    {
       List<BundleInfo> currScan = Arrays.asList(getBundles());
 
+      if (traceBundles)
+         logBundleInfos("Current Scan", currScan);
+
       processOldDeployments(currScan);
 
       processNewDeployments(currScan);
@@ -122,6 +127,15 @@
       scanCount++;
    }
 
+   private void logBundleInfos(String message, List<BundleInfo> bundleInfos)
+   {
+      System.out.println(message);
+      for (BundleInfo info : bundleInfos)
+      {
+         System.out.println("   " + info);
+      }
+   }
+
    private void processOldDeployments(List<BundleInfo> currScan)
    {
       List<BundleInfo> diff = new ArrayList<BundleInfo>();
@@ -129,14 +143,17 @@
       // Detect OLD bundles that are not in the current scan  
       for (BundleInfo info : lastScan)
       {
-         if (currScan.contains(info) == false)
+         if ((info.getState() == State.INSTALLED || info.getState() == State.ACTIVE) && currScan.contains(info) == false)
             diff.add(info);
       }
 
+      if (traceBundles)
+         logBundleInfos("OLD diff", diff);
+      
       // Undeploy the bundles through the DeployerService
       try
       {
-         BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]); 
+         BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
          deployerService.undeploy(infoArr);
       }
       catch (Exception ex)
@@ -152,14 +169,17 @@
       // Detect NEW bundles that are not in the last scan  
       for (BundleInfo info : currScan)
       {
-         if (lastScan.contains(info) == false)
+         if (info.getState() == BundleInfo.State.NEW && lastScan.contains(info) == false)
             diff.add(info);
       }
 
+      if (traceBundles)
+         logBundleInfos("NEW diff", diff);
+
       // Deploy the bundles through the DeployerService
       try
       {
-         BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]); 
+         BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
          deployerService.deploy(infoArr);
       }
       catch (Exception ex)
@@ -238,7 +258,7 @@
          JarFile jarFile = new JarFile(file);
          Manifest manifest = jarFile.getManifest();
          Attributes attribs = manifest.getMainAttributes();
-         
+
          String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
          if (symbolicName == null)
             throw new IllegalStateException("Cannot obtain '" + Constants.BUNDLE_SYMBOLICNAME + "' from: " + file);

Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java	2009-05-28 18:36:22 UTC (rev 89499)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java	2009-05-28 19:46:11 UTC (rev 89500)
@@ -29,16 +29,13 @@
 import org.jboss.osgi.common.log.LogServiceTracker;
 import org.jboss.osgi.common.service.BundleInfo;
 import org.jboss.osgi.common.service.DeployerService;
-import org.jboss.osgi.common.service.BundleInfo.State;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.service.log.LogService;
 
 /**
- * A {@link DeployerService} that installs/uninstalls the 
- * bundles directly on the OSGi framework without going 
- * through the MC registered deployers.
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
  * 
  * @author thomas.diesler at jboss.com
  * @since 27-May-2009
@@ -60,19 +57,16 @@
       List<Bundle> bundles = new ArrayList<Bundle>();
       for (BundleInfo info : bundleInfos)
       {
-         if (info.getState() == BundleInfo.State.NEW)
+         try
          {
-            try
-            {
-               log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
-               Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
-               bundles.add(bundle);
-            }
-            catch (BundleException ex)
-            {
-               log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info.getSymbolicName(), ex);
-            }
+            log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
+            Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
+            bundles.add(bundle);
          }
+         catch (BundleException ex)
+         {
+            log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info.getSymbolicName(), ex);
+         }
       }
 
       // Start the installed bundles
@@ -97,18 +91,15 @@
          Bundle bundle = getInstalledBundle(context, info);
          if (bundle != null)
          {
-            if (info.getState() == State.INSTALLED || info.getState() == State.ACTIVE)
+            try
             {
-               try
-               {
-                  log.log(LogService.LOG_DEBUG, "Uninstall: " + info.getSymbolicName());
-                  bundle.uninstall();
-               }
-               catch (BundleException ex)
-               {
-                  log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
-               }
+               log.log(LogService.LOG_DEBUG, "Uninstall: " + info.getSymbolicName());
+               bundle.uninstall();
             }
+            catch (BundleException ex)
+            {
+               log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
+            }
          }
       }
    }




More information about the jboss-cvs-commits mailing list