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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 8 07:56:33 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-07-08 07:56:32 -0400 (Wed, 08 Jul 2009)
New Revision: 90927

Added:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java
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/service/hotdeploy/internal/DeploymentScannerImpl.java
   projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
   projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
   projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.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/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
Log:
[JBOSGI-99] No explicit control over bundle.start()

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-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -23,20 +23,14 @@
 
 //$Id: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler at jboss.com $
 
-import java.io.IOException;
 import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 
 import org.jboss.osgi.spi.service.DeployerService;
 import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.util.BundleDeployment;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
 
 /**
  * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
@@ -52,30 +46,6 @@
    {
    }
 
-   public BundleDeployment createBundleDeployment(URL url) throws BundleException
-   {
-      Manifest manifest;
-      try
-      {
-         JarFile jarFile = new JarFile(url.getPath());
-         manifest = jarFile.getManifest();
-         jarFile.close();
-      }
-      catch (IOException ex)
-      {
-         throw new BundleException("Cannot get manifest from: " + url);
-
-      }
-
-      Attributes attribs = manifest.getMainAttributes();
-      String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
-      if (symbolicName == null)
-         throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
-      String version = attribs.getValue(Constants.BUNDLE_VERSION);
-      return new BundleDeployment(url, symbolicName, version);
-   }
-
    public void registerBundleDeployment(BundleDeployment dep)
    {
       deployments.add(dep);

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-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -32,6 +32,7 @@
 import org.jboss.osgi.spi.service.DeployerService;
 import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -134,8 +135,7 @@
 
    public void deploy(URL url) throws BundleException
    {
-      DeploymentRegistryService registry = getDeploymentRegistry();
-      BundleDeployment dep = registry.createBundleDeployment(url);
+      BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
       deploy(new BundleDeployment[] { dep });
    }
 

Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -38,9 +38,9 @@
 
 import org.jboss.osgi.common.log.LogServiceTracker;
 import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.service.DeploymentScannerService;
 import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -64,7 +64,6 @@
    private long scanCount;
    private long lastChange;
 
-   private DeploymentRegistryService registry;
    private DeployerService deployer;
    private ScannerThread scannerThread;
    private List<BundleDeployment> lastScan = new ArrayList<BundleDeployment>();
@@ -81,10 +80,6 @@
       ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
       deployer = (DeployerService)context.getService(sref);
 
-      // Get the DeploymentRegistryService
-      sref = context.getServiceReference(DeploymentRegistryService.class.getName());
-      registry = (DeploymentRegistryService)context.getService(sref);
-
       initScanner(context);
    }
 
@@ -260,7 +255,7 @@
                try
                {
                   // hot-deploy bundles are started automatically
-                  dep = registry.createBundleDeployment(bundleURL);
+                  dep = BundleDeploymentFactory.createBundleDeployment(bundleURL);
                   dep.setAutoStart(true);
                   
                   deploymentCache.put(bundleURL.toExternalForm(), dep);

Modified: projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -30,8 +30,8 @@
 
 import org.apache.felix.webconsole.internal.core.InstallAction;
 import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -60,16 +60,13 @@
       }
       final DeployerService deployer = (DeployerService)context.getService(sref);
       
-      sref = context.getServiceReference(DeploymentRegistryService.class.getName());
-      final DeploymentRegistryService registry = (DeploymentRegistryService)context.getService(sref);
-      
       Thread t = new InstallHelper(this, "Background Install " + bundleFile, bundleFile, refreshPackages)
       {
          protected Bundle doRun(InputStream bundleStream) throws BundleException
          {
             URL bundleURL = getBundleURL(bundleFile);
             
-            BundleDeployment dep = registry.createBundleDeployment(bundleURL);
+            BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(bundleURL);
             dep.setStartLevel(startlevel);
             dep.setAutoStart(doStart);
 

Modified: projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -67,7 +67,7 @@
    public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
    {
       Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
-      if (propAutoStart == null || propAutoStart == Boolean.TRUE)
+      if (propAutoStart == null || Boolean.TRUE.equals(propAutoStart))
       {
          String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
          if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "true") == true)

Modified: projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -54,6 +54,7 @@
 import org.jboss.osgi.spi.service.DeploymentRegistryService;
 import org.jboss.osgi.spi.service.MicrocontainerService;
 import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleContext;
@@ -110,8 +111,7 @@
 
    public void deploy(URL url) throws BundleException
    {
-      DeploymentRegistryService registry = getDeploymentRegistry();
-      BundleDeployment dep = registry.createBundleDeployment(url);
+      BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
       deploy(new BundleDeployment[] { dep });
    }
 

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-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -26,7 +26,6 @@
 import java.net.URL;
 
 import org.jboss.osgi.spi.util.BundleDeployment;
-import org.osgi.framework.BundleException;
 
 /**
  * A Service to register/unregister bundle deployments.
@@ -38,11 +37,6 @@
 {
    /**
     * Create a bundle deployment from the given bundle URL
-    */
-   BundleDeployment createBundleDeployment(URL url) throws BundleException;
-   
-   /**
-    * Create a bundle deployment from the given bundle URL
     * @return null, if this service does not maintain the bundle deployment
     */
    BundleDeployment getBundleDeployment(URL url);

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -197,7 +197,7 @@
       invokeDeployerService("undeploy", archiveURL);
    }
 
-   private void invokeDeployerService(String method, URL archiveURL) throws Exception
+   protected void invokeDeployerService(String method, URL archiveURL) throws Exception
    {
       ObjectName oname = new ObjectName("jboss.osgi:service=DeployerService");
       getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -23,6 +23,7 @@
 
 // $Id$
 
+import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -44,6 +45,7 @@
 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.BundleDeploymentFactory;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
@@ -94,15 +96,39 @@
    @Override
    public void deploy(String location) throws Exception
    {
-      super.deploy(location);
+      URL archiveURL = getTestHelper().getTestArchiveURL(location);
+      
+      if (isBundleArchive(location))
+         invokeDeployerService("deploy", archiveURL);
+      else
+         invokeMainDeployer("deploy", archiveURL);
    }
 
    @Override
    public void undeploy(String location) throws Exception
    {
-      super.undeploy(location);
+      URL archiveURL = getTestHelper().getTestArchiveURL(location);
+      
+      if (isBundleArchive(location))
+         invokeDeployerService("undeploy", archiveURL);
+      else
+         invokeMainDeployer("undeploy", archiveURL);
    }
 
+   private boolean isBundleArchive(String location)
+   {
+      try
+      {
+         URL archiveURL = getTestHelper().getTestArchiveURL(location);
+         BundleDeploymentFactory.createBundleDeployment(archiveURL);
+         return true;
+      }
+      catch (BundleException ex)
+      {
+         return false;
+      }
+   }
+
    public OSGiBundle[] getBundles()
    {
       try
@@ -283,4 +309,10 @@
          }
       };
    }
+
+   private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+   {
+      ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
+      getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
+   }
 }

Added: 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	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.util;
+
+//$Id: BundleDeployment.java 90925 2009-07-08 10:12:31Z thomas.diesler at jboss.com $
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * A factory for bundle deployments.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2009
+ */
+public abstract class BundleDeploymentFactory 
+{
+   public static BundleDeployment createBundleDeployment(URL url) throws BundleException
+   {
+      Manifest manifest;
+      try
+      {
+         JarFile jarFile = new JarFile(url.getPath());
+         manifest = jarFile.getManifest();
+         jarFile.close();
+      }
+      catch (IOException ex)
+      {
+         throw new BundleException("Cannot get manifest from: " + url);
+
+      }
+
+      Attributes attribs = manifest.getMainAttributes();
+      String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+      if (symbolicName == null)
+         throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+      String version = attribs.getValue(Constants.BUNDLE_VERSION);
+      return new BundleDeployment(url, symbolicName, version);
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java	2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java	2009-07-08 11:56:32 UTC (rev 90927)
@@ -71,9 +71,6 @@
    {
       ((RemoteRuntime)runtime).undeploy("jbosgi36-mbean.jar");
       
-      if (bundle != null)
-         bundle.uninstall();
-      
       runtime.shutdown();
    }
 




More information about the jboss-cvs-commits mailing list