[jboss-cvs] JBossAS SVN: r95394 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 22 08:13:40 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-22 08:13:40 -0400 (Thu, 22 Oct 2009)
New Revision: 95394

Modified:
   projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
   projects/jboss-osgi/trunk/reactor/deployment/pom.xml
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
   projects/jboss-osgi/trunk/reactor/testing/pom.xml
   projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
Log:
Use DeployerService from testing

Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java	2009-10-22 12:13:40 UTC (rev 95394)
@@ -23,17 +23,8 @@
 
 //$Id$
 
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.jboss.osgi.deployment.deployer.DeployerService;
 import org.jboss.osgi.spi.framework.BundleContextWrapper;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,64 +40,9 @@
 {
    // Provide logging
    final Logger log = LoggerFactory.getLogger(FelixBundleContextWrapper.class);
-   
+
    public FelixBundleContextWrapper(BundleContext context)
    {
       super(context);
    }
-
-   @Override
-   public Bundle installBundle(String location) throws BundleException
-   {
-      URL url;
-      try
-      {
-         url = new URL(location);
-      }
-      catch (MalformedURLException ex)
-      {
-         throw new IllegalArgumentException("Invalid bundle location: " + location);
-      }
-      
-      BundleInfo info = BundleInfo.createBundleInfo(url);
-      String symbolicName = info.getSymbolicName();
-      Version version = Version.parseVersion(info.getVersion());
-      
-      Bundle bundle;
-      
-      ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
-      if (sref != null)
-      {
-         DeployerService service = (DeployerService)context.getService(sref);
-         service.deploy(url);
-         bundle = getBundle(symbolicName, version, true);
-      }
-      else
-      {
-         bundle = context.installBundle(location);
-      }
-      
-      return bundle;
-   }
-
-   private Bundle getBundle(String symbolicName, Version version, boolean mustExist)
-   {
-      Bundle bundle = null;
-      for (Bundle aux : getBundles())
-      {
-         if (aux.getSymbolicName().equals(symbolicName))
-         {
-            if (version == null || version.equals(aux.getVersion()))
-            {
-               bundle = aux;
-               break;
-            }
-         }
-      }
-      
-      if (bundle == null && mustExist == true)
-         throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version);
-      
-      return bundle;
-   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2009-10-22 12:13:40 UTC (rev 95394)
@@ -34,6 +34,7 @@
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
 
 /**
  * An abstraction of a bundle
@@ -47,7 +48,7 @@
    private String location;
    private Manifest manifest;
    private String symbolicName;
-   private String version;
+   private Version version;
 
    public static BundleInfo createBundleInfo(String location)
    {
@@ -154,9 +155,8 @@
       if (symbolicName == null)
          throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + root);
 
-      version = getManifestHeader(Constants.BUNDLE_VERSION);
-      if (version == null)
-         version = "0.0.0";
+      String versionStr = getManifestHeader(Constants.BUNDLE_VERSION);
+      version = Version.parseVersion(versionStr);
    }
    
    /**
@@ -196,7 +196,7 @@
    /**
     * Get the bundle version
     */
-   public String getVersion()
+   public Version getVersion()
    {
       return version;
    }

Modified: projects/jboss-osgi/trunk/reactor/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/pom.xml	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/trunk/reactor/deployment/pom.xml	2009-10-22 12:13:40 UTC (rev 95394)
@@ -59,8 +59,8 @@
     
     <!-- Test Dependecies -->
     <dependency>
-      <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-testing</artifactId>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java	2009-10-22 12:13:40 UTC (rev 95394)
@@ -92,7 +92,7 @@
     */
    public String getVersion()
    {
-      return info.getVersion();
+      return info.getVersion().toString();
    }
 
    /**

Modified: projects/jboss-osgi/trunk/reactor/testing/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/pom.xml	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/trunk/reactor/testing/pom.xml	2009-10-22 12:13:40 UTC (rev 95394)
@@ -40,6 +40,10 @@
       <artifactId>jboss-osgi-spi</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.jboss.osgi.runtime</groupId>
+      <artifactId>jboss-osgi-deployment</artifactId>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>

Modified: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-10-22 12:07:39 UTC (rev 95393)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-10-22 12:13:40 UTC (rev 95394)
@@ -33,6 +33,7 @@
 import javax.management.MBeanServerConnection;
 import javax.management.MBeanServerFactory;
 
+import org.jboss.osgi.deployment.deployer.DeployerService;
 import org.jboss.osgi.spi.capability.Capability;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.testing.OSGiBundle;
@@ -40,11 +41,13 @@
 import org.jboss.osgi.spi.testing.OSGiRuntime;
 import org.jboss.osgi.spi.testing.OSGiServiceReference;
 import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.osgi.spi.util.BundleInfo;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.framework.launch.Framework;
 import org.osgi.service.packageadmin.PackageAdmin;
 
@@ -64,11 +67,25 @@
    public OSGiBundle installBundle(String location) throws BundleException
    {
       URL url = getTestHelper().getTestArchiveURL(location);
+      BundleInfo info = BundleInfo.createBundleInfo(url);
+      String symbolicName = info.getSymbolicName();
+      Version version = info.getVersion();
       
+      OSGiBundle bundle;
+      
       BundleContext context = getBundleContext();
-      Bundle auxBundle = context.installBundle(url.toExternalForm());
-      OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
-      
+      ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+      if (sref != null)
+      {
+         DeployerService service = (DeployerService)context.getService(sref);
+         service.deploy(url);
+         bundle = getBundle(symbolicName, version, true);
+      }
+      else
+      {
+         Bundle auxBundle = context.installBundle(url.toExternalForm());
+         bundle = new EmbeddedBundle(this, auxBundle);
+      }
       return registerBundle(location, bundle);
    }
 




More information about the jboss-cvs-commits mailing list