[jboss-osgi-commits] JBoss-OSGI SVN: r87936 - in projects/jboss-osgi/trunk/bundle: blueprint/src/test/java/org/jboss/test/osgi/blueprint and 10 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Apr 28 07:36:06 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-04-28 07:36:05 -0400 (Tue, 28 Apr 2009)
New Revision: 87936

Added:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/DeploymentServiceTestCase.java
   projects/jboss-osgi/trunk/bundle/deployment/
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleClassLoaderDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleManagementDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaData.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaDataDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleRealDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStartStopDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStructureDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServiceImpl.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/ServiceActivator.java
Removed:
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/helpers/
Modified:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MCServiceTestCase.java
   projects/jboss-osgi/trunk/bundle/deployment/pom.xml
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleClassLoader.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleDeploymentUnitFilter.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentProvidedDeploymentUnitFilter.java
   projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/PackageAdminDependencyItem.java
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java
   projects/jboss-osgi/trunk/bundle/pom.xml
Log:
Add deployment bundle

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java	2009-04-28 10:04:21 UTC (rev 87935)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -42,10 +42,16 @@
    {
       OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
       OSGiFramework framework = configProvider.getFramework();
-      
-      Bundle bundle = framework.getSystemBundle();
+      try
+      {
+         Bundle bundle = framework.getSystemBundle();
 
-      assertEquals("BundleId == 0", 0, bundle.getBundleId());
-      assertEquals("SymbolicName", "org.apache.felix.framework", bundle.getSymbolicName());
+         assertEquals("BundleId == 0", 0, bundle.getBundleId());
+         assertEquals("SymbolicName", "org.apache.felix.framework", bundle.getSymbolicName());
+      }
+      finally
+      {
+         framework.stop();
+      }
    }
 }
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/DeploymentServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/DeploymentServiceTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/DeploymentServiceTestCase.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,55 @@
+/*
+ * 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.test.osgi.blueprint.deployment;
+
+//$Id$
+
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.test.osgi.blueprint.BlueprintTest;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A test that checks whether the DeploymentService can be accessed
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 12-Feb-2009
+ */
+public class DeploymentServiceTestCase extends BlueprintTest
+{
+   public void testServiceAccess() throws Exception
+   {
+      OSGiFramework framework = getBootstrapProvider().getFramework();
+      try
+      {
+         BundleContext sysContext = framework.getSystemBundleContext();
+         
+         //Bundle bundle = installBundle(sysContext, "bundles/jboss-osgi-deployment.jar", true);
+         //assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+         
+      }
+      finally
+      {
+         framework.stop();
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/deployment/DeploymentServiceTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MCServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MCServiceTestCase.java	2009-04-28 10:04:21 UTC (rev 87935)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MCServiceTestCase.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -69,7 +69,7 @@
    
    public void testBeansDeployment() throws Exception
    {
-      MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
+      //MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
       //mcService.deploy(getTestArchiveURL("mcservice-beans.jar"));
    }
 }
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/deployment (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer)


Property changes on: projects/jboss-osgi/trunk/bundle/deployment
___________________________________________________________________
Name: svn:ignore
   + target

Name: svn:mergeinfo
   + 

Modified: projects/jboss-osgi/trunk/bundle/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/pom.xml	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/pom.xml	2009-04-28 11:36:05 UTC (rev 87936)
@@ -2,15 +2,15 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <name>JBossOSGi - Runtime Deployer</name>
+  <name>JBossOSGi - Bundle Deployment</name>
 
   <groupId>org.jboss.osgi</groupId>
-  <artifactId>jboss-osgi-runtime-deployer</artifactId>
-  <packaging>jar</packaging>
+  <artifactId>jboss-osgi-deployment</artifactId>
+  <packaging>bundle</packaging>
 
   <parent>
     <groupId>org.jboss.osgi</groupId>
-    <artifactId>jboss-osgi-runtime</artifactId>
+    <artifactId>jboss-osgi-bundle</artifactId>
     <version>1.0.0.Beta2</version>
   </parent>
 
@@ -21,6 +21,19 @@
   <!-- Dependencies -->
   <dependencies>
     <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-spi</artifactId>
+      <version>${version}</version>
+    </dependency>
+    
+    <!-- Provided DEpendencies -->
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-microcontainer</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>
@@ -31,14 +44,10 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-spi</artifactId>
-      <version>${version}</version>
-    </dependency>
-    <dependency>
       <groupId>org.jboss.deployers</groupId>
       <artifactId>jboss-deployers-spi</artifactId>
       <version>${version.jboss.deployers}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.jboss.jbossas</groupId>
@@ -50,7 +59,39 @@
   <!-- Build -->
   <build>
     <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>jboss-osgi-deployment</Bundle-SymbolicName>
+            <Bundle-Activator>org.jboss.osgi.deployment.internal.ServiceActivator</Bundle-Activator>
+            <Export-Package>
+              org.jboss.osgi.deployment;version=${version}
+            </Export-Package>
+            <Private-Package>
+              org.jboss.osgi.deployment.internal
+            </Private-Package>
+            <Import-Package>
+            javax.management, 
+            org.jboss.dependency.plugins, 
+            org.jboss.dependency.spi, 
+            org.jboss.deployers.*, 
+            org.jboss.logging, 
+            org.jboss.osgi.common.log, 
+            org.jboss.osgi.spi.management, 
+            org.jboss.virtual, 
+            org.osgi.framework, 
+            org.osgi.service.log, 
+            org.osgi.service.packageadmin
+            </Import-Package>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Embed-Dependency>
+            </Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
-
 </project>

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-// $Id$
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.DeploymentUnitFilter;
-import org.jboss.osgi.deployer.helpers.BundleClassLoader;
-import org.jboss.osgi.deployer.helpers.BundleDeploymentUnitFilter;
-import org.jboss.osgi.deployer.helpers.PackageAdminDependencyItem;
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * A deployer that attaches a {@link ClassLoaderFactory} that creates a 
- * {@link BundleClassLoader} for the deployed Bundle.  
- *
- * @author Ales.Justin at jboss.org
- * @author Thomas.Diesler at jboss.org
- * @since 03-Feb-2009
- */
-public class BundleClassLoaderDeployer extends AbstractSimpleRealDeployer<Bundle>
-{
-   private DeploymentUnitFilter filter = new BundleDeploymentUnitFilter();
-   private BundleContext systemContext;
-
-   public BundleClassLoaderDeployer()
-   {
-      super(Bundle.class);
-      addOutput(ClassLoaderFactory.class);
-      setStage(DeploymentStages.POST_PARSE);
-   }
-
-   public void setSystemContext(BundleContext systemContext)
-   {
-      this.systemContext = systemContext;
-   }
-
-   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      // create bundle delegate classloader
-      ClassLoaderFactory factory = createClassLoaderFactory(bundle);
-      unit.addAttachment(ClassLoaderFactory.class, factory);
-
-      // create dependency items
-      String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
-      if (Boolean.parseBoolean(propStart != null ? propStart : "true") == false)
-         unit.addIDependOn(new PackageAdminDependencyItem(systemContext, bundle));
-
-      // skip annotations scanning, if filter is set
-      if (filter != null)
-         unit.addAttachment(DeploymentUnitFilter.class, filter);
-   }
-
-   /**
-    * Create classloader factory.
-    *
-    * @param bundle the bundle
-    * @return new classloader factory
-    */
-   protected ClassLoaderFactory createClassLoaderFactory(final Bundle bundle)
-   {
-      return new ClassLoaderFactory()
-      {
-         public ClassLoader createClassLoader(DeploymentUnit unit) throws Exception
-         {
-            return BundleClassLoader.createBundleClassLoader(bundle);
-         }
-
-         public void removeClassLoader(DeploymentUnit unit) throws Exception
-         {
-         }
-      };
-   }
-
-   /**
-    * Set deployment filter.
-    *
-    * @param filter the deployment filter
-    */
-   public void setFilter(DeploymentUnitFilter filter)
-   {
-      this.filter = filter;
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-// $Id: $
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.spi.management.ManagedBundle;
-import org.osgi.framework.Bundle;
-
-/**
- * Register the Bundle as MBean with JMX.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 04-Mar-2009
- */
-public class BundleManagementDeployer extends AbstractSimpleRealDeployer<Bundle>
-{
-   private MBeanServer mbeanServer;
-
-   public BundleManagementDeployer()
-   {
-      super(Bundle.class);
-   }
-
-   public void setMbeanServer(MBeanServer mbeanServer)
-   {
-      this.mbeanServer = mbeanServer;
-   }
-
-   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      if (mbeanServer != null)
-      {
-         ManagedBundle mb = new ManagedBundle(bundle);
-         ObjectName oname = mb.getObjectName();
-         try
-         {
-            mbeanServer.registerMBean(mb, oname);
-            unit.addAttachment(ManagedBundle.class, mb);
-         }
-         catch (Exception ex)
-         {
-            DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
-         }
-      }
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, Bundle bundle)
-   {
-      if (mbeanServer != null)
-      {
-         try
-         {
-            ManagedBundle mb = unit.getAttachment(ManagedBundle.class);
-            if (mb != null && mbeanServer.isRegistered(mb.getObjectName()))
-               mbeanServer.unregisterMBean(mb.getObjectName());
-         }
-         catch (Exception ex)
-         {
-            log.warn("Cannot unregister: " + bundle, ex);
-         }
-      }
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-//$Id$
-
-import java.net.URL;
-
-import org.jboss.deployers.vfs.spi.deployer.helpers.AbstractManifestMetaData;
-
-
-/**
- * The Bundle metadata.
- * 
- * @author Thomas.Diesler at jboss.org
- * @since 03-Feb-2009
- */
-public class BundleMetaData extends AbstractManifestMetaData
-{
-  private String symbolicName;
-  private URL bundleLocation;
-
-   // exteralizable usage
-  public BundleMetaData()
-  {
-  }
-
-   public BundleMetaData(String symbolicName)
-  {
-    this.symbolicName = symbolicName;
-  }
-
-  public String getSymbolicName()
-  {
-    return symbolicName;
-  }
-
-  public URL getBundleLocation()
-  {
-    return bundleLocation;
-  }
-
-  public void setBundleLocation(URL bundleLocation)
-  {
-    this.bundleLocation = bundleLocation;
-  }
-  
-  public String toString()
-  {
-    return "Bundle[name=" + symbolicName + "]";
-  }
-}

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-//$Id$
-
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.vfs.spi.deployer.ManifestDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Constants;
-
-/**
- * Create {@link BundleMetaData} from Manifest Headers. 
- * 
- * If the manifest does not contain a header (named &quot;Bundle-SymbolicName&quot;) this deployer does nothing.
- * 
- * @author Thomas.Diesler at jboss.org
- * @since 03-Feb-2009
- */
-public class BundleMetaDataDeployer extends ManifestDeployer<BundleMetaData>
-{
-  public BundleMetaDataDeployer()
-  {
-    super(BundleMetaData.class);
-  }
-
-  @Override
-  protected BundleMetaData parse(VFSDeploymentUnit unit, VirtualFile file, BundleMetaData root) throws Exception
-  {
-    BundleMetaData metaData = super.parse(unit, file, root);
-    if (metaData != null)
-    {
-      metaData.setBundleLocation(unit.getRoot().toURL());
-      log.debug("Bundle-SymbolicName: " + metaData.getSymbolicName() + " in " + file);
-    }
-    return metaData;
-  }
-  
-  @Override
-  protected BundleMetaData createMetaData(Manifest manifest) throws Exception
-  {
-    Attributes attribs = manifest.getMainAttributes();
-    String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
-    if (symbolicName != null)
-      return new BundleMetaData(symbolicName);
-
-    return null;
-  }
-}

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-//$Id$
-
-import java.net.URL;
-import java.util.List;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * Installs the Bundle into the Framework's SystemContext.
- * 
- * This deployer does not start the bundle. It leaves it in state INSTALLED.
- * On undeploy the Bundle gets uninstalled from the Framework's SystemContext.
- *
- * @author Thomas.Diesler at jboss.org
- * @author Ales.Justin at jboss.org
- * @since 03-Feb-2009
- */
-public class BundleRealDeployer extends AbstractSimpleRealDeployer<BundleMetaData>
-{
-   private BundleContext systemContext;
-   private List<URL> skipBundles;
-
-   public BundleRealDeployer()
-   {
-      super(BundleMetaData.class);
-      addOutput(Bundle.class);
-      setStage(DeploymentStages.POST_PARSE);
-   }
-
-   public void setSystemContext(BundleContext bundleContext)
-   {
-      this.systemContext = bundleContext;
-   }
-
-   public void setSkipBundles(List<URL> skipBundles)
-   {
-      this.skipBundles = skipBundles;
-   }
-
-   public void deploy(DeploymentUnit unit, BundleMetaData metadata) throws DeploymentException
-   {
-      URL bundleURL = metadata.getBundleLocation();
-      if (bundleURL == null)
-         throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
-
-      String bundlePath = bundleURL.getPath();
-      if (bundlePath.endsWith("/"))
-         bundlePath = bundlePath.substring(0, bundlePath.length() - 1);
-      
-      try
-      {
-         if (skipBundles != null)
-         {
-            boolean skipBundle = false;
-            for (URL skip : skipBundles)
-            {
-               String skipPath = skip.getPath();
-               if (skipPath.equals(bundlePath))
-               {
-                  skipBundle = true;
-                  break;
-               }
-            }
-            if (skipBundle == false)
-            {
-               Bundle bundle = systemContext.installBundle(bundleURL.toString());
-               unit.addAttachment(Bundle.class, bundle);
-               
-               log.info("Installed: " + bundle);
-            }
-         }
-      }
-      catch (BundleException ex)
-      {
-         throw DeploymentException.rethrowAsDeploymentException("Cannot install bundle: " + metadata, ex);
-      }
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, BundleMetaData osGiMetaData)
-   {
-      Bundle bundle = unit.getAttachment(Bundle.class);
-      if (bundle != null)
-      {
-         try
-         {
-            bundle.uninstall();
-            log.info("Uninstalled: " + bundle);
-         }
-         catch (BundleException ex)
-         {
-            log.warn(ex);
-         }
-      }
-   }
-}

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-// $Id: $
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * This is the Bundle start/stop Deployer
- *
- * @author Ales.Justin at jboss.org
- * @author Thomas.Diesler at jboss.com
- * @since 27-Feb-2009
- */
-public class BundleStartStopDeployer extends AbstractSimpleRealDeployer<Bundle>
-{
-   private BundleContext systemContext;
-   private PackageAdmin packageAdmin;
-
-   // The list of unresolved bundles
-   private List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
-
-   public BundleStartStopDeployer()
-   {
-      super(Bundle.class);
-   }
-
-   public void setSystemContext(BundleContext systemContext)
-   {
-      this.systemContext = systemContext;
-   }
-
-   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
-      if (Boolean.parseBoolean(propStart != null ? propStart : "true") == true)
-      {
-         deferredStart(unit, bundle);
-      }
-      else
-      {
-         simpleStart(unit, bundle);
-      }
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, Bundle bundle)
-   {
-      try
-      {
-         bundle.stop();
-         
-         unresolvedBundles.remove(bundle);
-
-         log.info("Stoped: " + bundle);
-      }
-      catch (BundleException e)
-      {
-         log.warn("Cannot stop bundle: " + e);
-      }
-   }
-
-   private void simpleStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      try
-      {
-         bundle.start();
-         log.info("Started: " + bundle);
-      }
-      catch (BundleException e)
-      {
-         log.warn("Cannot start bundle", e);
-      }
-   }
-
-   private void deferredStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      // Get the required dependency on the PackageAdmin service
-      if (packageAdmin == null)
-      {
-         ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
-         packageAdmin = (PackageAdmin)systemContext.getService(sref);
-         if (packageAdmin == null)
-            throw new IllegalStateException("Cannot obtain PackageAdmin service");
-      }
-
-      // Always add the bundle as unresolved
-      unresolvedBundles.add(bundle);
-
-      Bundle[] bundleArr = new Bundle[unresolvedBundles.size()];
-      unresolvedBundles.toArray(bundleArr);
-
-      // Try to resolve the bundles
-      packageAdmin.resolveBundles(bundleArr);
-
-      // Find resolved bundles and start them
-      Iterator<Bundle> it = unresolvedBundles.iterator();
-      while (it.hasNext())
-      {
-         Bundle auxBundle = it.next();
-         if ((Bundle.RESOLVED & auxBundle.getState()) == Bundle.RESOLVED)
-         {
-            it.remove();
-            try
-            {
-               auxBundle.start();
-               log.info("Started: " + bundle);
-            }
-            catch (BundleException e)
-            {
-               log.warn("Cannot start bundle", e);
-            }
-         }
-      }
-
-      // Report unresolved bundles
-      if (unresolvedBundles.size() > 0)
-         log.info("Unresolved: " + unresolvedBundles);
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer;
-
-// $Id$
-
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Constants;
-
-/**
- * Determine the structure of a Bundle deployment.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-Apr-2009
- */
-public class BundleStructureDeployer extends AbstractVFSStructureDeployer
-{
-   /**
-    * Sets the default relative order 9000.
-    */
-   public BundleStructureDeployer()
-   {
-      setRelativeOrder(9000);
-   }
-
-   /**
-    * Determine the structure of a bundle deployment
-    * 
-    * @param context the structure context
-    * @return true when it recognised the context
-    * @throws DeploymentException for an error
-    */
-   public boolean determineStructure(StructureContext structureContext) throws DeploymentException
-   {
-      ContextInfo context = null;
-      VirtualFile file = structureContext.getFile();
-      VirtualFile root = structureContext.getRoot();
-
-      try
-      {
-         // This file is not for me, because I'm only interested
-         // in root deployments that contain a MANIFEST.MF
-         Manifest manifest = VFSUtils.getManifest(file);
-         if (file != root || manifest == null)
-            return false;
-
-         // This file is also not for me, because I need to see Bundle-SymbolicName
-         Attributes attribs = manifest.getMainAttributes();
-         String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
-         if (symbolicName == null)
-            return false;
-
-         // Create a context for this jar file with META-INF as the location for metadata
-         context = createContext(structureContext, "META-INF");
-
-         return true;
-      }
-      catch (Exception e)
-      {
-         // Remove the invalid context
-         if (context != null)
-            structureContext.removeChild(context);
-
-         throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
-      }
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleClassLoaderDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleClassLoaderDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleClassLoaderDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+// $Id$
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnitFilter;
+import org.jboss.osgi.deployment.internal.BundleClassLoader;
+import org.jboss.osgi.deployment.internal.BundleDeploymentUnitFilter;
+import org.jboss.osgi.deployment.internal.PackageAdminDependencyItem;
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A deployer that attaches a {@link ClassLoaderFactory} that creates a 
+ * {@link BundleClassLoader} for the deployed Bundle.  
+ *
+ * @author Ales.Justin at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ * @since 03-Feb-2009
+ */
+public class BundleClassLoaderDeployer extends AbstractSimpleRealDeployer<Bundle>
+{
+   private DeploymentUnitFilter filter = new BundleDeploymentUnitFilter();
+   private BundleContext systemContext;
+
+   public BundleClassLoaderDeployer()
+   {
+      super(Bundle.class);
+      addOutput(ClassLoaderFactory.class);
+      setStage(DeploymentStages.POST_PARSE);
+   }
+
+   public void setSystemContext(BundleContext systemContext)
+   {
+      this.systemContext = systemContext;
+   }
+
+   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      // create bundle delegate classloader
+      ClassLoaderFactory factory = createClassLoaderFactory(bundle);
+      unit.addAttachment(ClassLoaderFactory.class, factory);
+
+      // create dependency items
+      String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+      if (Boolean.parseBoolean(propStart != null ? propStart : "true") == false)
+         unit.addIDependOn(new PackageAdminDependencyItem(systemContext, bundle));
+
+      // skip annotations scanning, if filter is set
+      if (filter != null)
+         unit.addAttachment(DeploymentUnitFilter.class, filter);
+   }
+
+   /**
+    * Create classloader factory.
+    *
+    * @param bundle the bundle
+    * @return new classloader factory
+    */
+   protected ClassLoaderFactory createClassLoaderFactory(final Bundle bundle)
+   {
+      return new ClassLoaderFactory()
+      {
+         public ClassLoader createClassLoader(DeploymentUnit unit) throws Exception
+         {
+            return BundleClassLoader.createBundleClassLoader(bundle);
+         }
+
+         public void removeClassLoader(DeploymentUnit unit) throws Exception
+         {
+         }
+      };
+   }
+
+   /**
+    * Set deployment filter.
+    *
+    * @param filter the deployment filter
+    */
+   public void setFilter(DeploymentUnitFilter filter)
+   {
+      this.filter = filter;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleManagementDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleManagementDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleManagementDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+// $Id: $
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.spi.management.ManagedBundle;
+import org.osgi.framework.Bundle;
+
+/**
+ * Register the Bundle as MBean with JMX.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 04-Mar-2009
+ */
+public class BundleManagementDeployer extends AbstractSimpleRealDeployer<Bundle>
+{
+   private MBeanServer mbeanServer;
+
+   public BundleManagementDeployer()
+   {
+      super(Bundle.class);
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      if (mbeanServer != null)
+      {
+         ManagedBundle mb = new ManagedBundle(bundle);
+         ObjectName oname = mb.getObjectName();
+         try
+         {
+            mbeanServer.registerMBean(mb, oname);
+            unit.addAttachment(ManagedBundle.class, mb);
+         }
+         catch (Exception ex)
+         {
+            DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+         }
+      }
+   }
+
+   @Override
+   public void undeploy(DeploymentUnit unit, Bundle bundle)
+   {
+      if (mbeanServer != null)
+      {
+         try
+         {
+            ManagedBundle mb = unit.getAttachment(ManagedBundle.class);
+            if (mb != null && mbeanServer.isRegistered(mb.getObjectName()))
+               mbeanServer.unregisterMBean(mb.getObjectName());
+         }
+         catch (Exception ex)
+         {
+            log.warn("Cannot unregister: " + bundle, ex);
+         }
+      }
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaData.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaData.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaData.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.deployers.vfs.spi.deployer.helpers.AbstractManifestMetaData;
+
+
+/**
+ * The Bundle metadata.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 03-Feb-2009
+ */
+public class BundleMetaData extends AbstractManifestMetaData
+{
+  private String symbolicName;
+  private URL bundleLocation;
+
+   // exteralizable usage
+  public BundleMetaData()
+  {
+  }
+
+   public BundleMetaData(String symbolicName)
+  {
+    this.symbolicName = symbolicName;
+  }
+
+  public String getSymbolicName()
+  {
+    return symbolicName;
+  }
+
+  public URL getBundleLocation()
+  {
+    return bundleLocation;
+  }
+
+  public void setBundleLocation(URL bundleLocation)
+  {
+    this.bundleLocation = bundleLocation;
+  }
+  
+  public String toString()
+  {
+    return "Bundle[name=" + symbolicName + "]";
+  }
+}

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaDataDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaDataDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleMetaDataDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+//$Id$
+
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.vfs.spi.deployer.ManifestDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Constants;
+
+/**
+ * Create {@link BundleMetaData} from Manifest Headers. 
+ * 
+ * If the manifest does not contain a header (named &quot;Bundle-SymbolicName&quot;) this deployer does nothing.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 03-Feb-2009
+ */
+public class BundleMetaDataDeployer extends ManifestDeployer<BundleMetaData>
+{
+  public BundleMetaDataDeployer()
+  {
+    super(BundleMetaData.class);
+  }
+
+  @Override
+  protected BundleMetaData parse(VFSDeploymentUnit unit, VirtualFile file, BundleMetaData root) throws Exception
+  {
+    BundleMetaData metaData = super.parse(unit, file, root);
+    if (metaData != null)
+    {
+      metaData.setBundleLocation(unit.getRoot().toURL());
+      log.debug("Bundle-SymbolicName: " + metaData.getSymbolicName() + " in " + file);
+    }
+    return metaData;
+  }
+  
+  @Override
+  protected BundleMetaData createMetaData(Manifest manifest) throws Exception
+  {
+    Attributes attribs = manifest.getMainAttributes();
+    String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+    if (symbolicName != null)
+      return new BundleMetaData(symbolicName);
+
+    return null;
+  }
+}

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleRealDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleRealDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleRealDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+//$Id$
+
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * Installs the Bundle into the Framework's SystemContext.
+ * 
+ * This deployer does not start the bundle. It leaves it in state INSTALLED.
+ * On undeploy the Bundle gets uninstalled from the Framework's SystemContext.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author Ales.Justin at jboss.org
+ * @since 03-Feb-2009
+ */
+public class BundleRealDeployer extends AbstractSimpleRealDeployer<BundleMetaData>
+{
+   private BundleContext systemContext;
+   private List<URL> skipBundles;
+
+   public BundleRealDeployer()
+   {
+      super(BundleMetaData.class);
+      addOutput(Bundle.class);
+      setStage(DeploymentStages.POST_PARSE);
+   }
+
+   public void setSystemContext(BundleContext bundleContext)
+   {
+      this.systemContext = bundleContext;
+   }
+
+   public void setSkipBundles(List<URL> skipBundles)
+   {
+      this.skipBundles = skipBundles;
+   }
+
+   public void deploy(DeploymentUnit unit, BundleMetaData metadata) throws DeploymentException
+   {
+      URL bundleURL = metadata.getBundleLocation();
+      if (bundleURL == null)
+         throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
+
+      String bundlePath = bundleURL.getPath();
+      if (bundlePath.endsWith("/"))
+         bundlePath = bundlePath.substring(0, bundlePath.length() - 1);
+      
+      try
+      {
+         if (skipBundles != null)
+         {
+            boolean skipBundle = false;
+            for (URL skip : skipBundles)
+            {
+               String skipPath = skip.getPath();
+               if (skipPath.equals(bundlePath))
+               {
+                  skipBundle = true;
+                  break;
+               }
+            }
+            if (skipBundle == false)
+            {
+               Bundle bundle = systemContext.installBundle(bundleURL.toString());
+               unit.addAttachment(Bundle.class, bundle);
+               
+               log.info("Installed: " + bundle);
+            }
+         }
+      }
+      catch (BundleException ex)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Cannot install bundle: " + metadata, ex);
+      }
+   }
+
+   @Override
+   public void undeploy(DeploymentUnit unit, BundleMetaData osGiMetaData)
+   {
+      Bundle bundle = unit.getAttachment(Bundle.class);
+      if (bundle != null)
+      {
+         try
+         {
+            bundle.uninstall();
+            log.info("Uninstalled: " + bundle);
+         }
+         catch (BundleException ex)
+         {
+            log.warn(ex);
+         }
+      }
+   }
+}

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStartStopDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStartStopDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStartStopDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+// $Id: $
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * This is the Bundle start/stop Deployer
+ *
+ * @author Ales.Justin at jboss.org
+ * @author Thomas.Diesler at jboss.com
+ * @since 27-Feb-2009
+ */
+public class BundleStartStopDeployer extends AbstractSimpleRealDeployer<Bundle>
+{
+   private BundleContext systemContext;
+   private PackageAdmin packageAdmin;
+
+   // The list of unresolved bundles
+   private List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
+
+   public BundleStartStopDeployer()
+   {
+      super(Bundle.class);
+   }
+
+   public void setSystemContext(BundleContext systemContext)
+   {
+      this.systemContext = systemContext;
+   }
+
+   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+      if (Boolean.parseBoolean(propStart != null ? propStart : "true") == true)
+      {
+         deferredStart(unit, bundle);
+      }
+      else
+      {
+         simpleStart(unit, bundle);
+      }
+   }
+
+   @Override
+   public void undeploy(DeploymentUnit unit, Bundle bundle)
+   {
+      try
+      {
+         bundle.stop();
+         
+         unresolvedBundles.remove(bundle);
+
+         log.info("Stoped: " + bundle);
+      }
+      catch (BundleException e)
+      {
+         log.warn("Cannot stop bundle: " + e);
+      }
+   }
+
+   private void simpleStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      try
+      {
+         bundle.start();
+         log.info("Started: " + bundle);
+      }
+      catch (BundleException e)
+      {
+         log.warn("Cannot start bundle", e);
+      }
+   }
+
+   private void deferredStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      // Get the required dependency on the PackageAdmin service
+      if (packageAdmin == null)
+      {
+         ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
+         packageAdmin = (PackageAdmin)systemContext.getService(sref);
+         if (packageAdmin == null)
+            throw new IllegalStateException("Cannot obtain PackageAdmin service");
+      }
+
+      // Always add the bundle as unresolved
+      unresolvedBundles.add(bundle);
+
+      Bundle[] bundleArr = new Bundle[unresolvedBundles.size()];
+      unresolvedBundles.toArray(bundleArr);
+
+      // Try to resolve the bundles
+      packageAdmin.resolveBundles(bundleArr);
+
+      // Find resolved bundles and start them
+      Iterator<Bundle> it = unresolvedBundles.iterator();
+      while (it.hasNext())
+      {
+         Bundle auxBundle = it.next();
+         if ((Bundle.RESOLVED & auxBundle.getState()) == Bundle.RESOLVED)
+         {
+            it.remove();
+            try
+            {
+               auxBundle.start();
+               log.info("Started: " + bundle);
+            }
+            catch (BundleException e)
+            {
+               log.warn("Cannot start bundle", e);
+            }
+         }
+      }
+
+      // Report unresolved bundles
+      if (unresolvedBundles.size() > 0)
+         log.info("Unresolved: " + unresolvedBundles);
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStructureDeployer.java (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStructureDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/BundleStructureDeployer.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+// $Id$
+
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Constants;
+
+/**
+ * Determine the structure of a Bundle deployment.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2009
+ */
+public class BundleStructureDeployer extends AbstractVFSStructureDeployer
+{
+   /**
+    * Sets the default relative order 9000.
+    */
+   public BundleStructureDeployer()
+   {
+      setRelativeOrder(9000);
+   }
+
+   /**
+    * Determine the structure of a bundle deployment
+    * 
+    * @param context the structure context
+    * @return true when it recognised the context
+    * @throws DeploymentException for an error
+    */
+   public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+   {
+      ContextInfo context = null;
+      VirtualFile file = structureContext.getFile();
+      VirtualFile root = structureContext.getRoot();
+
+      try
+      {
+         // This file is not for me, because I'm only interested
+         // in root deployments that contain a MANIFEST.MF
+         Manifest manifest = VFSUtils.getManifest(file);
+         if (file != root || manifest == null)
+            return false;
+
+         // This file is also not for me, because I need to see Bundle-SymbolicName
+         Attributes attribs = manifest.getMainAttributes();
+         String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+         if (symbolicName == null)
+            return false;
+
+         // Create a context for this jar file with META-INF as the location for metadata
+         context = createContext(structureContext, "META-INF");
+
+         return true;
+      }
+      catch (Exception e)
+      {
+         // Remove the invalid context
+         if (context != null)
+            structureContext.removeChild(context);
+
+         throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
+      }
+   }
+}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+// $Id$
+
+/**
+ * The JBossOSGi deployment service
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 28-Apr-2009
+ */
+public interface DeploymentService
+{
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal (from rev 87920, projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/helpers)

Modified: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/helpers/BundleClassLoader.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleClassLoader.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -19,7 +19,7 @@
  * 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.deployer.helpers;
+package org.jboss.osgi.deployment.internal;
 
 // $Id: $
 

Modified: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleDeploymentUnitFilter.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/helpers/BundleDeploymentUnitFilter.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/BundleDeploymentUnitFilter.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -19,7 +19,7 @@
  * 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.deployer.helpers;
+package org.jboss.osgi.deployment.internal;
 
 // $Id$
 

Modified: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentProvidedDeploymentUnitFilter.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/helpers/DeploymentProvidedDeploymentUnitFilter.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentProvidedDeploymentUnitFilter.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -19,7 +19,7 @@
  * 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.deployer.helpers;
+package org.jboss.osgi.deployment.internal;
 
 // $Id$
 

Added: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServiceImpl.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServiceImpl.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,40 @@
+/*
+ * 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.deployment.internal;
+
+//$Id$
+
+import org.jboss.osgi.deployment.DeploymentService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The DeploymentService implementation
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 28-Apr-2009
+ */
+public class DeploymentServiceImpl implements DeploymentService
+{
+   public DeploymentServiceImpl(BundleContext context)
+   {
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServiceImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/PackageAdminDependencyItem.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/helpers/PackageAdminDependencyItem.java	2009-04-28 04:35:10 UTC (rev 87920)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/PackageAdminDependencyItem.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -19,7 +19,7 @@
  * 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.deployer.helpers;
+package org.jboss.osgi.deployment.internal;
 
 import org.jboss.dependency.plugins.AbstractDependencyItem;
 import org.jboss.dependency.spi.ControllerState;

Added: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/ServiceActivator.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -0,0 +1,62 @@
+/*
+ * 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.deployment.internal;
+
+//$Id$
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.deployment.DeploymentService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+
+/**
+ * A BundleActivator that registers the {@link DeploymentService}
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+   private ServiceRegistration registration;
+   private LogService log;
+
+   public void start(BundleContext context)
+   {
+      log = new LogServiceTracker(context);
+      
+      log.log(LogService.LOG_DEBUG, "Register DeploymentService");
+      DeploymentServiceImpl service = new DeploymentServiceImpl(context);
+      registration = context.registerService(DeploymentService.class.getName(), service, null);
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (registration != null)
+      {
+         log.log(LogService.LOG_DEBUG, "Unregister DeploymentService");
+         registration.unregister();
+         registration = null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/deployment/src/main/java/org/jboss/osgi/deployment/internal/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-04-28 10:04:21 UTC (rev 87935)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -44,7 +44,7 @@
    /** 
     * The name under which the MBeanServer is registered: 'jboss.osgi:service=MBeanServer' 
     */
-   String BEAN_MBEAN_SERVER = "jboss.osgi:service=SystemBundleContext";
+   String BEAN_MBEAN_SERVER = "jboss.osgi:service=MBeanServer";
 
    /** 
     * The name under which the Kernel is registered: 'jboss.osgi:service=Kernel' 

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java	2009-04-28 10:04:21 UTC (rev 87935)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java	2009-04-28 11:36:05 UTC (rev 87936)
@@ -47,7 +47,7 @@
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
- * A BundleActivator that registers the Microcontainer Service
+ * A BundleActivator that registers the {@link MicrocontainerService}
  * 
  * @author thomas.diesler at jboss.com
  * @since 24-Apr-2009
@@ -74,9 +74,12 @@
    {
       if (registration != null)
       {
+         MBeanServer server = (MBeanServer)mbeanServerTracker.getService();
+         if (server != null)
+            unregisterMBean(server);
+         
          log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
          registration.unregister();
-         unregisterMBean(context);
          registration = null;
       }
    }
@@ -99,10 +102,9 @@
       }
    }
 
-   private void unregisterMBean(BundleContext context)
+   private void unregisterMBean(MBeanServer server)
    {
-      MBeanServer server = (MBeanServer)mbeanServerTracker.getService();
-      if (server != null && server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
+      if (server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
       {
          try
          {
@@ -163,6 +165,9 @@
       @Override
       public void removedService(ServiceReference reference, Object service)
       {
+         // Unregister MBean
+         unregisterMBean((MBeanServer)service);
+         
          // Uninstall the MBeanServer from the Kernel
          try
          {

Modified: projects/jboss-osgi/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/pom.xml	2009-04-28 10:04:21 UTC (rev 87935)
+++ projects/jboss-osgi/trunk/bundle/pom.xml	2009-04-28 11:36:05 UTC (rev 87936)
@@ -11,15 +11,16 @@
     <version>1.0.0.Beta2</version>
   </parent>
   
-  <!-- Modules -->
+  <!-- Modules --> 
   <modules>
     <module>blueprint</module>
     <module>common</module>
+    <!-- module>deployment</module -->
     <module>jmx</module>
     <module>logging</module>
     <module>microcontainer</module>
     <module>remotelog</module>
     <module>webconsole</module>
   </modules>
-
+  
 </project>




More information about the jboss-osgi-commits mailing list