[jboss-cvs] JBossAS SVN: r97207 - in projects/jboss-osgi: projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 1 03:46:34 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-12-01 03:46:33 -0500 (Tue, 01 Dec 2009)
New Revision: 97207

Modified:
   projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
   projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
   projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml
   projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
   projects/jboss-osgi/trunk/pom.xml
Log:
Husky remote undeployment issue - WIP 

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml	2009-12-01 08:46:33 UTC (rev 97207)
@@ -42,7 +42,7 @@
   <properties>
     <version.jboss.osgi.runtime.felix>2.0.0</version.jboss.osgi.runtime.felix>
     <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
-    <version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
+    <version.jboss.osgi.deployment>1.0.0-SNAPSHOT</version.jboss.osgi.deployment>
     <version.osgi>4.2.0</version.osgi>
   </properties>
 

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -66,10 +66,10 @@
 
    public OSGiBundle installBundle(String location) throws BundleException
    {
-      URL url = getTestHelper().getTestArchiveURL(location);
-      BundleInfo info = BundleInfo.createBundleInfo(url);
+      BundleInfo info = BundleInfo.createBundleInfo(location);
       String symbolicName = info.getSymbolicName();
       Version version = info.getVersion();
+      URL rootURL = info.getRootURL();
       
       OSGiBundle bundle;
       
@@ -78,15 +78,15 @@
       if (sref != null)
       {
          DeployerService service = (DeployerService)context.getService(sref);
-         service.deploy(url);
+         service.deploy(rootURL);
          bundle = getBundle(symbolicName, version, true);
       }
       else
       {
-         Bundle auxBundle = context.installBundle(url.toExternalForm());
+         Bundle auxBundle = context.installBundle(rootURL.toExternalForm());
          bundle = new EmbeddedBundle(this, auxBundle);
       }
-      return registerBundle(location, bundle);
+      return registerBundle(bundle.getLocation(), bundle);
    }
 
    public OSGiBundle[] getBundles()

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -45,13 +45,13 @@
 import org.jboss.osgi.deployment.deployer.DeployerService;
 import org.jboss.osgi.deployment.deployer.Deployment;
 import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.util.BundleInfo;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
 import org.jboss.osgi.testing.OSGiServiceReference;
 import org.jboss.osgi.testing.OSGiTestHelper;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -98,9 +98,10 @@
       {
          log.debug("Add capability: " + capability);
 
-         for (String location : capability.getBundles())
+         for (BundleInfo info : capability.getBundles())
          {
-            String symName = getManifestEntry(location, Constants.BUNDLE_SYMBOLICNAME);
+            String location = info.getLocation();
+            String symName = info.getSymbolicName();
             if (bundles.get(location) == null && getBundle(symName, null) == null)
             {
                OSGiBundle bundle = installBundle(location);
@@ -125,11 +126,11 @@
       {
          log.debug("Remove capability : " + capability);
 
-         List<String> bundleLocations = new ArrayList<String>(capability.getBundles());
-         Collections.reverse(bundleLocations);
+         List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>(capability.getBundles());
+         Collections.reverse(bundleInfos);
 
-         for (String location : bundleLocations)
-            failsafeUninstall(bundles.remove(location));
+         for (BundleInfo info : bundleInfos)
+            failsafeUninstall(bundles.remove(info.getLocation()));
       }
 
       List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -23,10 +23,10 @@
 
 // $Id$
 
-import java.net.URL;
 import java.util.Dictionary;
 
 import org.jboss.osgi.spi.management.ManagedBundleMBean;
+import org.jboss.osgi.spi.util.BundleInfo;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
@@ -47,21 +47,22 @@
    private final Logger log = LoggerFactory.getLogger(RemoteBundle.class);
    
    private ManagedBundleMBean bundle;
+   private BundleInfo bundleInfo;
    private String location;
-
-   private long bundleId;
-   private String symbolicName;
    private Version version;
    
-   public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, String location)
+   public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, BundleInfo bundleInfo)
    {
+      this(runtime, bundle);
+      this.bundleInfo = bundleInfo;
+      this.location = bundleInfo.getLocation();
+   }
+   
+   public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle)
+   {
       super(runtime);
       this.bundle = bundle;
-      this.location = location;
       
-      this.bundleId = bundle.getBundleId();
-      this.symbolicName = bundle.getSymbolicName();
-      
       String versionStr = getHeaders().get(Constants.BUNDLE_VERSION);
       this.version = Version.parseVersion(versionStr);
    }
@@ -75,13 +76,13 @@
    @Override
    public long getBundleId()
    {
-      return bundleId;
+      return bundle.getBundleId();
    }
 
    @Override
    public String getSymbolicName()
    {
-      return symbolicName;
+      return bundle.getSymbolicName();
    }
 
    @Override
@@ -130,7 +131,7 @@
       assertNotUninstalled();
       try
       {
-         getRuntime().undeploy(new URL(getLocation()));
+         getRuntime().undeploy(bundleInfo.getRootURL());
          getRuntime().unregisterBundle(this);
          setUninstalled(true);
       }

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -69,8 +69,7 @@
       try
       {
          // Get the bundle info from the location
-         URL bundleURL = getTestHelper().getTestArchiveURL(location);
-         BundleInfo info = BundleInfo.createBundleInfo(bundleURL);
+         BundleInfo info = BundleInfo.createBundleInfo(location);
 
          // Create the deployment from the info
          DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
@@ -95,8 +94,8 @@
          if (bundleMBean == null)
             throw new IllegalStateException("Cannot find installed bundle: " + symbolicName + "-" + version);
 
-         RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
-         return registerBundle(location, bundle);
+         RemoteBundle bundle = new RemoteBundle(this, bundleMBean, info);
+         return registerBundle(bundle.getLocation(), bundle);
       }
       catch (RuntimeException rte)
       {
@@ -135,7 +134,7 @@
          Set<ManagedBundleMBean> remoteBundles = getRemoteFramework().getBundles();
          Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
          for (ManagedBundleMBean remoteBundle : remoteBundles)
-            bundles.add(new RemoteBundle(this, remoteBundle, null));
+            bundles.add(new RemoteBundle(this, remoteBundle));
 
          OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
          bundles.toArray(bundleArr);
@@ -150,7 +149,7 @@
    public OSGiBundle getBundle(long bundleId)
    {
       ManagedBundleMBean bundle = getRemoteFramework().getBundle(bundleId);
-      return bundle != null ? new RemoteBundle(this, bundle, null) : null;
+      return bundle != null ? new RemoteBundle(this, bundle) : null;
    }
 
    public OSGiServiceReference getServiceReference(String clazz)

Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml	2009-12-01 08:46:33 UTC (rev 97207)
@@ -20,7 +20,7 @@
   <artifactId>jboss-osgi-deployment</artifactId>
   <packaging>jar</packaging>
 
-  <version>1.0.1-SNAPSHOT</version>
+  <version>1.0.0-SNAPSHOT</version>
 
   <!-- Parent -->
   <parent>
@@ -38,8 +38,8 @@
   
   <!-- Properties -->
   <properties>
-    <version.jboss.deployers>2.0.8.GA</version.jboss.deployers>
-    <version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
+    <version.jboss.deployers>2.0.9.GA</version.jboss.deployers>
+    <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
     <version.osgi>4.2.0</version.osgi>
   </properties>
 

Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -22,7 +22,6 @@
 package org.jboss.osgi.deployment.internal;
 
 import java.io.Serializable;
-import java.net.MalformedURLException;
 import java.net.URL;
 
 import org.jboss.osgi.deployment.deployer.Deployment;
@@ -43,7 +42,6 @@
    private static final long serialVersionUID = 6216977125749367927L;
    
    private BundleInfo info;
-   private URL location;
    private int startLevel;
    private boolean autoStart;
 
@@ -53,15 +51,6 @@
          throw new IllegalArgumentException("Bundle info cannot be null");
       
       this.info = info;
-      
-      try
-      {
-         this.location = new URL(info.getLocation());
-      }
-      catch (MalformedURLException e)
-      {
-         throw new IllegalArgumentException("Malformed URL location: " + info.getLocation());
-      }
    }
    
    /**
@@ -77,7 +66,7 @@
     */
    public URL getLocation()
    {
-      return location;
+      return info.getRootURL();
    }
 
    /**
@@ -157,6 +146,7 @@
    {
       String symbolicName = getSymbolicName();
       String version = getVersion();
-      return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+      URL url = getLocation();
+      return "[" + symbolicName + "-" + version + ",url=" + url + "]";
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -29,6 +29,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jboss.osgi.spi.util.BundleInfo;
+
 /**
  * An abstract OSGi capability that can be installed in an {@link OSGiRuntime}.
  * 
@@ -46,7 +48,7 @@
    private Map<String, String> systemProperties;
 
    private List<Capability> dependencies;
-   private List<String> bundles;
+   private List<BundleInfo> bundles;
 
    /**
     * Construct a capability that is identified by the given service name. 
@@ -128,21 +130,22 @@
       getDependenciesInternal().add(dependency);
    }
 
-   public List<String> getBundles()
+   public List<BundleInfo> getBundles()
    {
       return Collections.unmodifiableList(getBundlesInternal());
    }
 
-   protected void addBundle(String bundle)
+   protected void addBundle(String location)
    {
-      getBundlesInternal().add(bundle);
+      BundleInfo info = BundleInfo.createBundleInfo(location);
+      getBundlesInternal().add(info);
    }
 
    private Map<String, String> getPropertiesInternal()
    {
       if (systemProperties == null)
          systemProperties = new HashMap<String, String>();
-      
+
       return systemProperties;
    }
 
@@ -154,10 +157,10 @@
       return dependencies;
    }
 
-   private List<String> getBundlesInternal()
+   private List<BundleInfo> getBundlesInternal()
    {
       if (bundles == null)
-         bundles = new ArrayList<String>();
+         bundles = new ArrayList<BundleInfo>();
 
       return bundles;
    }

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-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2009-12-01 08:46:33 UTC (rev 97207)
@@ -63,33 +63,8 @@
       if (location == null)
          throw new IllegalArgumentException("Location cannot be null");
 
-      // Try location as URL
-      URL url = null;
-      try
-      {
-         url = new URL(location);
-      }
-      catch (MalformedURLException ex)
-      {
-         // ignore
-      }
-
-      // Try location as File
+      URL url = getRealLocation(location);
       if (url == null)
-      {
-         try
-         {
-            File file = new File(location);
-            if (file.exists())
-               url = file.toURI().toURL();
-         }
-         catch (MalformedURLException e)
-         {
-            // ignore
-         }
-      }
-
-      if (url == null)
          throw new IllegalArgumentException("Cannot obtain root url from: " + location);
       
       return new BundleInfo(toVirtualFile(url), location);
@@ -166,6 +141,14 @@
    }
 
    /**
+    * Get the bundle root url
+    */
+   public URL getRootURL()
+   {
+      return toURL(getRoot());
+   }
+
+   /**
     * Get the bundle symbolic name
     */
    public String getSymbolicName()
@@ -197,6 +180,45 @@
       return manifest;
    }
 
+   private static URL getRealLocation(String location)
+   {
+      // Try location as URL
+      URL url = null;
+      try
+      {
+         url = new URL(location);
+      }
+      catch (MalformedURLException ex)
+      {
+         // ignore
+      }
+
+      // Try location as File
+      if (url == null)
+      {
+         try
+         {
+            File file = new File(location);
+            if (file.exists())
+               url = file.toURI().toURL();
+         }
+         catch (MalformedURLException e)
+         {
+            // ignore
+         }
+      }
+      
+      // Try to prefix the location with the test archive directory
+      if (url == null)
+      {
+         String prefix = System.getProperty("test.archive.directory", "target/test-libs");
+         if (new File(prefix).exists())
+            return getRealLocation(prefix + File.separator + location);
+      }
+         
+      return url;
+   }
+
    private static VirtualFile toVirtualFile(URL url)
    {
       try

Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-12-01 08:33:50 UTC (rev 97206)
+++ projects/jboss-osgi/trunk/pom.xml	2009-12-01 08:46:33 UTC (rev 97207)
@@ -53,7 +53,7 @@
     <version.jboss.osgi.blueprint>1.0.0.Alpha3</version.jboss.osgi.blueprint>
     <version.jboss.osgi.common>1.0.4-SNAPSHOT</version.jboss.osgi.common>
     <version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
-    <version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
+    <version.jboss.osgi.deployment>1.0.0-SNAPSHOT</version.jboss.osgi.deployment>
     <version.jboss.osgi.framework>1.0.0.Alpha2-SNAPSHOT</version.jboss.osgi.framework>
     <version.jboss.osgi.hotdeploy>1.0.3</version.jboss.osgi.hotdeploy>
     <version.jboss.osgi.husky>1.0.2-SNAPSHOT</version.jboss.osgi.husky>




More information about the jboss-cvs-commits mailing list