[jboss-osgi-commits] JBoss-OSGI SVN: r92698 - in projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi: deployer and 2 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Sat Aug 22 14:17:25 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-08-22 14:17:24 -0400 (Sat, 22 Aug 2009)
New Revision: 92698

Added:
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/
Removed:
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleClassLoaderDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleContainedBeansDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleManagementDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaData.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaDataDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleRealDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartLevelDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartStopDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStructureDeployer.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/helpers/
Modified:
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/BundleDeploymentUnitFilter.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/DeploymentProvidedDeploymentUnitFilter.java
   projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/PackageAdminDependencyItem.java
Log:
Restore package to org.jboss.osgi.deployer

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleClassLoaderDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.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.BundleDeploymentUnitFilter;
+import org.jboss.osgi.deployer.helpers.PackageAdminDependencyItem;
+import org.jboss.osgi.spi.Constants;
+import org.jboss.osgi.spi.util.BundleClassLoader;
+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.createClassLoader(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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleContainedBeansDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployer;
+
+// $Id$
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.osgi.framework.Bundle;
+
+/**
+ * Deploy the bundle contained MC beans onto the Kernel. 
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 06-May-2009
+ */
+public class BundleContainedBeansDeployer extends AbstractComponentDeployer<KernelDeployment, BeanMetaData>
+{
+   /*
+    * Create a new KernelDeploymentDeployer.
+    */
+   public BundleContainedBeansDeployer()
+   {
+      addInput(Bundle.class);
+      addInput(ClassLoaderFactory.class);
+      setDeploymentVisitor(new KernelDeploymentVisitor());
+      setComponentVisitor(new BeanMetaDataVisitor());
+   }
+
+   /*
+    * KernelDeploymentVisitor.
+    */
+   public static class KernelDeploymentVisitor extends BeanMetaDataFactoryVisitor<KernelDeployment>
+   {
+      @Override
+      public void deploy(DeploymentUnit unit, KernelDeployment deployment) throws DeploymentException
+      {
+         ClassLoaderFactory factory = unit.getAttachment(ClassLoaderFactory.class);
+         unit.createClassLoader(factory);
+         
+         super.deploy(unit, deployment);
+      }
+
+      public Class<KernelDeployment> getVisitorType()
+      {
+         return KernelDeployment.class;
+      }
+
+      protected List<BeanMetaData> getBeans(KernelDeployment deployment)
+      {
+         return deployment.getBeans();
+      }
+   }
+
+   /*
+    * BeanMetaDataVisitor.
+    */
+   public static class BeanMetaDataVisitor extends BeanMetaDataFactoryVisitor<BeanMetaData>
+   {
+      public Class<BeanMetaData> getVisitorType()
+      {
+         return BeanMetaData.class;
+      }
+
+      protected List<BeanMetaData> getBeans(BeanMetaData deployment)
+      {
+         return Collections.singletonList(deployment);
+      }
+   }
+}

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleManagementDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleManagementDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.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

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaData.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.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 + "]";
+  }
+}

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaDataDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.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;
+  }
+}

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleRealDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -0,0 +1,123 @@
+/*
+ * 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.ArrayList;
+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 = new ArrayList<URL>();
+
+   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
+      {
+         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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartLevelDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -0,0 +1,80 @@
+/*
+ * 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.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.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Sets the bundle's start level on the StartLevel service.
+ * 
+ * A start level can be given when the bundle is deployed through the 
+ * WebConsole. Currently, neither hot deployment nor SPI test framework
+ * deployments support start levels.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 08-Jul-2009
+ */
+public class BundleStartLevelDeployer extends AbstractSimpleRealDeployer<Bundle>
+{
+   private BundleContext systemContext;
+   private ServiceTracker startLevelTracker;
+
+   public BundleStartLevelDeployer()
+   {
+      super(Bundle.class);
+      addOutput(Constants.PROPERTY_START_LEVEL);
+   }
+
+   public void setSystemContext(BundleContext systemContext)
+   {
+      this.systemContext = systemContext;
+   }
+
+   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      Integer propStart = unit.getAttachment(Constants.PROPERTY_START_LEVEL, Integer.class);
+      StartLevel startLevel = getStartLevel();
+      if (propStart != null && startLevel != null)
+      {
+         startLevel.setBundleStartLevel(bundle, propStart);
+      }
+   }
+   
+   private StartLevel getStartLevel()
+   {
+      if (startLevelTracker == null)
+      {
+         startLevelTracker = new ServiceTracker(systemContext, StartLevel.class.getName(), null);
+         startLevelTracker.open();
+      }
+      return (StartLevel)startLevelTracker.getService();
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartStopDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -0,0 +1,173 @@
+/*
+ * 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.jboss.osgi.spi.logging.ExportedPackageHelper;
+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);
+      addInput(Constants.PROPERTY_START_LEVEL);
+   }
+
+   public void setSystemContext(BundleContext systemContext)
+   {
+      this.systemContext = systemContext;
+   }
+
+   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
+      if (propAutoStart == null || Boolean.TRUE.equals(propAutoStart))
+      {
+         String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+         if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "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
+   {
+      ExportedPackageHelper packageHelper = new ExportedPackageHelper(systemContext);
+      try
+      {
+         // Added support for Bundle.START_ACTIVATION_POLICY on start
+         // http://issues.apache.org/jira/browse/FELIX-1317
+         // bundle.start(Bundle.START_ACTIVATION_POLICY);
+         
+         bundle.start();
+         
+         log.info("Started: " + bundle);
+         packageHelper.logExportedPackages(bundle);
+      }
+      catch (BundleException e)
+      {
+         log.warn("Cannot start bundle", e);
+      }
+   }
+
+   private void deferredStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+   {
+      ExportedPackageHelper packageHelper = new ExportedPackageHelper(systemContext);
+      
+      // 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
+            {
+               // Added support for Bundle.START_ACTIVATION_POLICY on start
+               // http://issues.apache.org/jira/browse/FELIX-1317
+               // auxBundle.start(Bundle.START_ACTIVATION_POLICY);
+               
+               auxBundle.start();
+               
+               packageHelper.logExportedPackages(bundle);
+               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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStructureDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers (from rev 92696, projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/helpers)

Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/BundleDeploymentUnitFilter.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/helpers/BundleDeploymentUnitFilter.java	2009-08-22 18:13:15 UTC (rev 92696)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/BundleDeploymentUnitFilter.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.deployer.helpers;
+package org.jboss.osgi.deployer.helpers;
 
 // $Id$
 

Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/DeploymentProvidedDeploymentUnitFilter.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/helpers/DeploymentProvidedDeploymentUnitFilter.java	2009-08-22 18:13:15 UTC (rev 92696)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/DeploymentProvidedDeploymentUnitFilter.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.deployer.helpers;
+package org.jboss.osgi.deployer.helpers;
 
 // $Id$
 

Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/PackageAdminDependencyItem.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/helpers/PackageAdminDependencyItem.java	2009-08-22 18:13:15 UTC (rev 92696)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/helpers/PackageAdminDependencyItem.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.deployer.helpers;
+package org.jboss.osgi.deployer.helpers;
 
 import org.jboss.dependency.plugins.AbstractDependencyItem;
 import org.jboss.dependency.spi.ControllerState;

Deleted: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleClassLoaderDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleClassLoaderDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleClassLoaderDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.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.runtime.deployer.helpers.BundleDeploymentUnitFilter;
-import org.jboss.osgi.runtime.deployer.helpers.PackageAdminDependencyItem;
-import org.jboss.osgi.spi.Constants;
-import org.jboss.osgi.spi.util.BundleClassLoader;
-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.createClassLoader(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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleContainedBeansDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleContainedBeansDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleContainedBeansDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, 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.runtime.deployer;
-
-// $Id$
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.osgi.framework.Bundle;
-
-/**
- * Deploy the bundle contained MC beans onto the Kernel. 
- *
- * @author Thomas.Diesler at jboss.com
- * @since 06-May-2009
- */
-public class BundleContainedBeansDeployer extends AbstractComponentDeployer<KernelDeployment, BeanMetaData>
-{
-   /*
-    * Create a new KernelDeploymentDeployer.
-    */
-   public BundleContainedBeansDeployer()
-   {
-      addInput(Bundle.class);
-      addInput(ClassLoaderFactory.class);
-      setDeploymentVisitor(new KernelDeploymentVisitor());
-      setComponentVisitor(new BeanMetaDataVisitor());
-   }
-
-   /*
-    * KernelDeploymentVisitor.
-    */
-   public static class KernelDeploymentVisitor extends BeanMetaDataFactoryVisitor<KernelDeployment>
-   {
-      @Override
-      public void deploy(DeploymentUnit unit, KernelDeployment deployment) throws DeploymentException
-      {
-         ClassLoaderFactory factory = unit.getAttachment(ClassLoaderFactory.class);
-         unit.createClassLoader(factory);
-         
-         super.deploy(unit, deployment);
-      }
-
-      public Class<KernelDeployment> getVisitorType()
-      {
-         return KernelDeployment.class;
-      }
-
-      protected List<BeanMetaData> getBeans(KernelDeployment deployment)
-      {
-         return deployment.getBeans();
-      }
-   }
-
-   /*
-    * BeanMetaDataVisitor.
-    */
-   public static class BeanMetaDataVisitor extends BeanMetaDataFactoryVisitor<BeanMetaData>
-   {
-      public Class<BeanMetaData> getVisitorType()
-      {
-         return BeanMetaData.class;
-      }
-
-      protected List<BeanMetaData> getBeans(BeanMetaData deployment)
-      {
-         return Collections.singletonList(deployment);
-      }
-   }
-}

Deleted: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleManagementDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleManagementDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleManagementDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaData.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaData.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaDataDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleMetaDataDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleRealDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleRealDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleRealDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -1,123 +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.runtime.deployer;
-
-//$Id$
-
-import java.net.URL;
-import java.util.ArrayList;
-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 = new ArrayList<URL>();
-
-   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
-      {
-         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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartLevelDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartLevelDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartLevelDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -1,80 +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.runtime.deployer;
-
-// $Id: $
-
-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.service.startlevel.StartLevel;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Sets the bundle's start level on the StartLevel service.
- * 
- * A start level can be given when the bundle is deployed through the 
- * WebConsole. Currently, neither hot deployment nor SPI test framework
- * deployments support start levels.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 08-Jul-2009
- */
-public class BundleStartLevelDeployer extends AbstractSimpleRealDeployer<Bundle>
-{
-   private BundleContext systemContext;
-   private ServiceTracker startLevelTracker;
-
-   public BundleStartLevelDeployer()
-   {
-      super(Bundle.class);
-      addOutput(Constants.PROPERTY_START_LEVEL);
-   }
-
-   public void setSystemContext(BundleContext systemContext)
-   {
-      this.systemContext = systemContext;
-   }
-
-   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      Integer propStart = unit.getAttachment(Constants.PROPERTY_START_LEVEL, Integer.class);
-      StartLevel startLevel = getStartLevel();
-      if (propStart != null && startLevel != null)
-      {
-         startLevel.setBundleStartLevel(bundle, propStart);
-      }
-   }
-   
-   private StartLevel getStartLevel()
-   {
-      if (startLevelTracker == null)
-      {
-         startLevelTracker = new ServiceTracker(systemContext, StartLevel.class.getName(), null);
-         startLevelTracker.open();
-      }
-      return (StartLevel)startLevelTracker.getService();
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartStopDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStartStopDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -1,173 +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.runtime.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.jboss.osgi.spi.logging.ExportedPackageHelper;
-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);
-      addInput(Constants.PROPERTY_START_LEVEL);
-   }
-
-   public void setSystemContext(BundleContext systemContext)
-   {
-      this.systemContext = systemContext;
-   }
-
-   public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
-      if (propAutoStart == null || Boolean.TRUE.equals(propAutoStart))
-      {
-         String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
-         if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "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
-   {
-      ExportedPackageHelper packageHelper = new ExportedPackageHelper(systemContext);
-      try
-      {
-         // Added support for Bundle.START_ACTIVATION_POLICY on start
-         // http://issues.apache.org/jira/browse/FELIX-1317
-         // bundle.start(Bundle.START_ACTIVATION_POLICY);
-         
-         bundle.start();
-         
-         log.info("Started: " + bundle);
-         packageHelper.logExportedPackages(bundle);
-      }
-      catch (BundleException e)
-      {
-         log.warn("Cannot start bundle", e);
-      }
-   }
-
-   private void deferredStart(DeploymentUnit unit, Bundle bundle) throws DeploymentException
-   {
-      ExportedPackageHelper packageHelper = new ExportedPackageHelper(systemContext);
-      
-      // 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
-            {
-               // Added support for Bundle.START_ACTIVATION_POLICY on start
-               // http://issues.apache.org/jira/browse/FELIX-1317
-               // auxBundle.start(Bundle.START_ACTIVATION_POLICY);
-               
-               auxBundle.start();
-               
-               packageHelper.logExportedPackages(bundle);
-               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/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStructureDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStructureDeployer.java	2009-08-22 18:15:34 UTC (rev 92697)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/runtime/deployer/BundleStructureDeployer.java	2009-08-22 18:17:24 UTC (rev 92698)
@@ -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.runtime.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



More information about the jboss-osgi-commits mailing list