[jboss-cvs] JBossAS SVN: r96301 - in projects/jboss-osgi: trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 12 02:42:58 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-11-12 02:42:58 -0500 (Thu, 12 Nov 2009)
New Revision: 96301

Modified:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
Log:
Allow clients of the DeployerService to set autoStart behaviour.
Instead of hard coding PROPERTY_AUTO_START=false into the BundleManager.

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-11-12 07:34:09 UTC (rev 96300)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2009-11-12 07:42:58 UTC (rev 96301)
@@ -120,6 +120,11 @@
       return new BundleInfo(root, null);
    }
    
+   public static BundleInfo createBundleInfo(VirtualFile root, String location)
+   {
+      return new BundleInfo(root, location);
+   }
+   
    private BundleInfo(VirtualFile root, String location)
    {
       if (root == null)

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java	2009-11-12 07:34:09 UTC (rev 96300)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java	2009-11-12 07:42:58 UTC (rev 96301)
@@ -48,4 +48,9 @@
       BundleInfo info = BundleInfo.createBundleInfo(file);
       return new DeploymentImpl(info);
    }
+   
+   public Deployment createDeployment(BundleInfo info)
+   {
+      return new DeploymentImpl(info);
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java	2009-11-12 07:34:09 UTC (rev 96300)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java	2009-11-12 07:42:58 UTC (rev 96301)
@@ -28,6 +28,7 @@
 import javax.management.ObjectName;
 
 import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.jboss.osgi.spi.util.BundleInfo;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleException;
 
@@ -54,6 +55,11 @@
     */
    Deployment createDeployment(VirtualFile file);
    
+   /** 
+    * Create a deployment from the given bundle info. 
+    */
+   Deployment createDeployment(BundleInfo info);
+   
    /**
     * Deploy an array of bundles
     */

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-11-12 07:34:09 UTC (rev 96300)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-11-12 07:42:58 UTC (rev 96301)
@@ -65,6 +65,7 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.kernel.Kernel;
 import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.deployer.Deployment;
 import org.jboss.osgi.framework.metadata.OSGiMetaData;
 import org.jboss.osgi.framework.metadata.PackageAttribute;
 import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
@@ -427,7 +428,7 @@
    }
 
    /**
-    * Install a bundle from 
+    * Install a bundle from an input stream.
     * 
     * @param location the bundle's location identifier
     * @param input an optional input stream to read the bundle content from
@@ -478,11 +479,12 @@
          throw new BundleException("Invalid bundle location=" + locationURL, e);
       }
 
-      return install(root, location);
+      return install(root, location, false);
    }
 
    /**
-    * Install a bundle 
+    * Install a bundle from a virtual file.
+    *  
     * @param root the virtual file that point to the bundle
     * 
     * @return the bundle state
@@ -490,17 +492,30 @@
     */
    public AbstractBundleState installBundle(VirtualFile root) throws BundleException
    {
-      return install(root, null);
+      return install(root, root.toString(), false);
    }
 
+   /**
+    * Install a bundle from a deployment. 
+    *  
+    * @param dep the deployment that represents the bundle
+    * 
+    * @return the bundle state
+    * @throws BundleException for any error
+    */
+   public AbstractBundleState installBundle(Deployment dep) throws BundleException
+   {
+      String location = dep.getLocation().toExternalForm();
+      return install(dep.getRoot(), location, dep.isAutoStart());
+   }
+
    /*
-    * Installs a bundle from the given virtual file. If the location is not explicitly
-    * given, it'll be derived from the virtual file.
+    * Installs a bundle from the given virtual file.
     */
-   private AbstractBundleState install(VirtualFile root, String location) throws BundleException
+   private AbstractBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
    {
       if (location == null)
-         location = root.toString();
+         throw new IllegalArgumentException("Null location");
 
       // Create the deployment and deploy it
       try
@@ -508,7 +523,7 @@
          VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
          MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
          att.addAttachment(PROPERTY_BUNDLE_LOCATION, location);
-         att.addAttachment(PROPERTY_AUTO_START, Boolean.FALSE);
+         att.addAttachment(PROPERTY_AUTO_START, autoStart);
 
          deployerClient.deploy(deployment);
          try

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-11-12 07:34:09 UTC (rev 96300)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-11-12 07:42:58 UTC (rev 96301)
@@ -35,6 +35,7 @@
 import org.jboss.osgi.framework.bundle.OSGiBundleManager;
 import org.jboss.osgi.framework.plugins.DeployerServicePlugin;
 import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
+import org.jboss.osgi.spi.util.BundleInfo;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -60,13 +61,13 @@
    public void startService()
    {
       BundleContext context = getSystemContext();
+      delegate = new SystemDeployerService(context);
 
       DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
       context.registerService(DeploymentRegistryService.class.getName(), registry, null);
 
       Properties props = new Properties();
       props.put("provider", "system");
-      delegate = new SystemDeployerService(context);
       context.registerService(DeployerService.class.getName(), this, props);
    }
 
@@ -85,14 +86,21 @@
       return delegate.createDeployment(file);
    }
 
+   public Deployment createDeployment(BundleInfo info)
+   {
+      return delegate.createDeployment(info);
+   }
+
    public void deploy(Deployment[] bundleDeps) throws BundleException
    {
-      delegate.deploy(bundleDeps);
+      for (Deployment dep : bundleDeps)
+         getBundleManager().installBundle(dep);
    }
 
    public void deploy(URL url) throws BundleException
    {
-      delegate.deploy(url);
+      Deployment dep = createDeployment(url);
+      getBundleManager().installBundle(dep);
    }
 
    public void undeploy(Deployment[] bundleDeps) throws BundleException




More information about the jboss-cvs-commits mailing list