[jboss-cvs] JBossAS SVN: r93198 - in projects/jboss-osgi/projects: bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 4 05:32:13 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-04 05:32:11 -0400 (Fri, 04 Sep 2009)
New Revision: 93198

Modified:
   projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
   projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
   projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java
Log:
Use 4.2 Version instead of String

Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -31,6 +31,7 @@
 import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.util.BundleDeployment;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
 
 /**
  * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
@@ -56,7 +57,7 @@
       deployments.remove(dep);
    }
    
-   public BundleDeployment getBundleDeployment(String symbolicName, String version)
+   public BundleDeployment getBundleDeployment(String symbolicName, Version version)
    {
       if (symbolicName == null)
          throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
@@ -65,8 +66,8 @@
       for (BundleDeployment auxDep : deployments)
       {
          String auxName = auxDep.getSymbolicName();
-         String auxVersion = auxDep.getVersion();
-         if (symbolicName.equals(auxName) && (version == null || version.equals(auxVersion)))
+         Version auxVersion = auxDep.getVersion();
+         if (symbolicName.equals(auxName) && version.equals(auxVersion))
          {
             dep = auxDep;
             break;

Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -37,8 +37,8 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.startlevel.StartLevel;
@@ -187,15 +187,15 @@
    private Bundle getBundle(BundleDeployment dep)
    {
       String symbolicName = dep.getSymbolicName();
-      String version = dep.getVersion();
+      Version version = dep.getVersion();
 
       Bundle bundle = null;
       for (Bundle aux : context.getBundles())
       {
          if (aux.getSymbolicName().equals(symbolicName))
          {
-            String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
-            if (version == null || version.equals(auxVersion))
+            Version auxVersion = aux.getVersion();
+            if (version.equals(auxVersion))
             {
                bundle = aux;
                break;

Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -44,8 +44,8 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.service.log.LogService;
 
 /**
@@ -180,12 +180,19 @@
          if (currScan.contains(dep) == false)
          {
             Bundle bundle = getBundle(dep);
-            int state = bundle.getState();
-            if (state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.ACTIVE)
+            if (bundle == null)
             {
                deploymentCache.remove(dep.getLocation().toExternalForm());
-               diff.add(dep);
             }
+            else
+            {
+               int state = bundle.getState();
+               if (state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.ACTIVE)
+               {
+                  deploymentCache.remove(dep.getLocation().toExternalForm());
+                  diff.add(dep);
+               }
+            }
          }
       }
 
@@ -311,15 +318,15 @@
    private Bundle getBundle(BundleDeployment dep)
    {
       String symbolicName = dep.getSymbolicName();
-      String version = dep.getVersion();
+      Version version = dep.getVersion();
 
       Bundle bundle = null;
       for (Bundle aux : context.getBundles())
       {
          if (aux.getSymbolicName().equals(symbolicName))
          {
-            String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
-            if (version == null || version.equals(auxVersion))
+            Version auxVersion = aux.getVersion();
+            if (version.equals(auxVersion))
             {
                bundle = aux;
                break;

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -26,6 +26,7 @@
 import java.net.URL;
 
 import org.jboss.osgi.spi.util.BundleDeployment;
+import org.osgi.framework.Version;
 
 /**
  * A Service to register/unregister bundle deployments.
@@ -45,7 +46,7 @@
     * Get the bundle deployment for the given bundle symbolicName and version
     * @return null, if this service does not maintain the bundle deployment
     */
-   BundleDeployment getBundleDeployment(String symbolicName, String version);
+   BundleDeployment getBundleDeployment(String symbolicName, Version version);
 
    /**
     * Register a bundle deployment

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -24,6 +24,8 @@
 import java.io.Serializable;
 import java.net.URL;
 
+import org.osgi.framework.Version;
+
 //$Id$
 
 /**
@@ -38,12 +40,12 @@
    
    private URL location;
    private String symbolicName;
-   private String version;
+   private Version version;
    private int startLevel;
    private boolean autoStart;
    private Object metadata;
 
-   public BundleDeployment(URL location, String symbolicName, String version)
+   public BundleDeployment(URL location, String symbolicName, Version version)
    {
       if (location == null)
          throw new IllegalArgumentException("Location cannot be null");
@@ -52,8 +54,7 @@
       
       this.symbolicName = symbolicName;
       this.location = location;
-      
-      this.version = (version != null ? version : "0.0.0");
+      this.version = version;
    }
 
    /**
@@ -75,7 +76,7 @@
    /**
     * Get the bundle version
     */
-   public String getVersion()
+   public Version getVersion()
    {
       return version;
    }

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java	2009-09-04 08:51:14 UTC (rev 93197)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java	2009-09-04 09:32:11 UTC (rev 93198)
@@ -31,6 +31,7 @@
 
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
 
 /**
  * A factory for bundle deployments.
@@ -60,7 +61,8 @@
       if (symbolicName == null)
          throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
 
-      String version = attribs.getValue(Constants.BUNDLE_VERSION);
+      String versionStr = attribs.getValue(Constants.BUNDLE_VERSION);
+      Version version = Version.parseVersion(versionStr);
       return new BundleDeployment(url, symbolicName, version);
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list