[jboss-osgi-commits] JBoss-OSGI SVN: r93337 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src: main/java/org/jboss/osgi/plugins/facade/bundle and 4 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Thu Sep 10 00:35:15 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-10 00:35:14 -0400 (Thu, 10 Sep 2009)
New Revision: 93337

Removed:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleRequiredStageDeployer.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResetDeployer.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolveDeployer.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolver.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleStartStopDeployer.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleResolverDeployer.java
Modified:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
Log:
[JBOSGI-151] Cannot resolve circular dependencies
Exclude package from policy that are imported from another module

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleRequiredStageDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleRequiredStageDeployer.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleRequiredStageDeployer.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.deployers.bundle;
-
-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.jboss.osgi.spi.metadata.OSGiMetaData;
-
-/**
- * Change required stage to reset.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class BundleRequiredStageDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
-{
-   public BundleRequiredStageDeployer()
-   {
-      super(OSGiMetaData.class);
-      setStage(DeploymentStages.POST_CLASSLOADER);
-      setTopLevelOnly(true);
-   }
-
-   public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
-   {
-      unit.setRequiredStage(BundleResolver.RESET_STAGE);
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, OSGiMetaData deployment)
-   {
-      unit.setRequiredStage(DeploymentStages.INSTALLED);   
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResetDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResetDeployer.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResetDeployer.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.deployers.bundle;
-
-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.metadata.OSGiMetaData;
-
-/**
- * Simple bundle reset deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class BundleResetDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
-{
-   private BundleResolver resolver;
-
-   public BundleResetDeployer(BundleResolver resolver)
-   {
-      super(OSGiMetaData.class);
-
-      if (resolver == null)
-         throw new IllegalArgumentException("Null resolver");
-
-      this.resolver = resolver;
-
-      setStage(BundleResolver.RESET_STAGE);
-      setTopLevelOnly(true);
-   }
-
-   public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
-   {
-      resolver.reset(unit);
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolveDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolveDeployer.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolveDeployer.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.deployers.bundle;
-
-import org.jboss.classloading.spi.dependency.Module;
-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.jboss.osgi.spi.metadata.OSGiMetaData;
-
-/**
- * Simple bundle resolve deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class BundleResolveDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
-{
-   private BundleResolver resolver;
-
-   public BundleResolveDeployer(BundleResolver resolver)
-   {
-      super(OSGiMetaData.class);
-
-      if (resolver == null)
-         throw new IllegalArgumentException("Null resolver");
-
-      this.resolver = resolver;
-
-      addInput(Module.class);
-      setStage(DeploymentStages.DESCRIBE);
-      setTopLevelOnly(true);
-   }
-
-   public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
-   {
-      resolver.resolve(unit);
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolver.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolver.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleResolver.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.deployers.bundle;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.deployers.spi.deployer.DeploymentStage;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * Simple bundle resolve helper.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class BundleResolver
-{
-   static final ControllerState DESCRIBED_STATE = new ControllerState(DeploymentStages.DESCRIBE.getName());
-   static final ControllerState CLASSLOADER_STATE = new ControllerState(DeploymentStages.CLASSLOADER.getName());
-
-   static final ControllerState RESET_STATE = new ControllerState("Reset");
-   static final DeploymentStage RESET_STAGE = new DeploymentStage("Reset", "Installed");
-
-   private Set<DeploymentUnit> units = new CopyOnWriteArraySet<DeploymentUnit>();
-
-   public BundleResolver(Controller controller)
-   {
-      controller.addState(RESET_STATE, null);
-   }
-
-   void resolve(DeploymentUnit unit)
-   {
-      run(unit, new Action()
-      {
-         public void resolved(DeploymentUnit unit)
-         {
-            unit.setRequiredStage(DeploymentStages.CLASSLOADER);
-            for (DeploymentUnit unresolved : units)
-            {
-               unresolved.setRequiredStage(DeploymentStages.CLASSLOADER); // try moving
-               ControllerContext context = unresolved.getAttachment(ControllerContext.class);
-               if (context != null)
-                  context.setRequiredState(CLASSLOADER_STATE);
-            }
-         }
-
-         public void unresolved(DeploymentUnit unit)
-         {
-            units.add(unit);
-         }
-      });
-   }
-
-   void reset(DeploymentUnit unit)
-   {
-      units.remove(unit); // remove, as we're clearly resolved
-
-      Set<DeploymentUnit> copy = new HashSet<DeploymentUnit>(units);
-      for (DeploymentUnit unresolved : copy)
-      {
-         run(unresolved, new Action()
-         {
-            public void resolved(DeploymentUnit unit)
-            {
-               units.remove(unit);
-            }
-
-            public void unresolved(DeploymentUnit unit)
-            {
-               unit.setRequiredStage(DeploymentStages.DESCRIBE); // move back
-               ControllerContext context = unit.getAttachment(ControllerContext.class);
-               if (context != null)
-                  context.setRequiredState(DESCRIBED_STATE);
-            }
-         });
-      }
-   }
-
-   protected void run(DeploymentUnit unit, Action action)
-   {
-      ControllerContext context = unit.getAttachment(ControllerContext.class);
-      if (context != null)
-      {
-         DependencyInfo info = context.getDependencyInfo();
-         Set<DependencyItem> unresolvedDependencies = info.getUnresolvedDependencies(CLASSLOADER_STATE);
-         if (unresolvedDependencies == null || unresolvedDependencies.isEmpty())
-            action.resolved(unit);
-         else
-            action.unresolved(unit);
-      }
-   }
-
-   private interface Action
-   {
-      void resolved(DeploymentUnit unit);
-
-      void unresolved(DeploymentUnit unit);
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleStartStopDeployer.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/BundleStartStopDeployer.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.deployers.bundle;
-
-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.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
-import org.osgi.framework.BundleException;
-
-/**
- * Simple bundle start/stop deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class BundleStartStopDeployer extends AbstractSimpleRealDeployer<OSGiBundleState>
-{
-   public BundleStartStopDeployer()
-   {
-      super(OSGiBundleState.class);
-      setStage(DeploymentStages.CLASSLOADER);
-      setTopLevelOnly(true);
-   }
-
-   public void deploy(DeploymentUnit unit, OSGiBundleState deployment) throws DeploymentException
-   {
-      try
-      {
-         deployment.start();
-      }
-      catch (BundleException e)
-      {
-         throw DeploymentException.rethrowAsDeploymentException("Cannot start bundle.", e);
-      }
-   }
-
-   @Override
-   public void undeploy(DeploymentUnit unit, OSGiBundleState deployment)
-   {
-      try
-      {
-         deployment.stop();
-      }
-      catch (BundleException e)
-      {
-         log.warn("Exception stopping bundle: " + e);
-      }
-   }
-}

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleResolverDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleResolverDeployer.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleResolverDeployer.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -1,168 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.plugins.deployers.bundle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.LifecycleCallbackItem;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-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.jboss.logging.Logger;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * OSGiBundleResolverDeployer.
- * 
- * @author Thomas.Diesler at jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleResolverDeployer extends AbstractSimpleRealDeployer<OSGiBundleState>
-{
-   /** The log */
-   private static final Logger log = Logger.getLogger(OSGiBundleResolverDeployer.class);
-
-   /** The list of unresolved bundles */
-   private List<OSGiBundleState> unresolvedBundles = new ArrayList<OSGiBundleState>();
-   
-   public OSGiBundleResolverDeployer()
-   {
-      super(OSGiBundleState.class);
-      setStage(DeploymentStages.DESCRIBE);
-      setTopLevelOnly(true);
-   }
-
-   @Override
-   public void deploy(DeploymentUnit unit, OSGiBundleState bundleState) throws DeploymentException
-   {
-      bundleState.getBundleManager();
-
-      ControllerContext context = unit.getAttachment(ControllerContext.class);
-      DependencyInfo di = context.getDependencyInfo();
-
-      LifecycleCallbackItem lifecycleCallbackItem = new LifecycleCallback(unit);
-      di.addLifecycleCallback(lifecycleCallbackItem);
-   }
-
-   private class LifecycleCallback implements LifecycleCallbackItem
-   {
-      private DeploymentUnit unit;
-      private PackageAdmin packageAdmin;
-      private DeployerClient deployerClient;
-
-      public LifecycleCallback(DeploymentUnit unit)
-      {
-         this.unit = unit;
-
-         OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
-         BundleContext sysContext = bundleState.getBundleManager().getSystemContext();
-         ServiceReference sref = sysContext.getServiceReference(PackageAdmin.class.getName());
-         packageAdmin = (PackageAdmin)sysContext.getService(sref);
-
-         deployerClient = unit.getAttachment(MainDeployer.class);
-      }
-
-      public void uninstall(ControllerContext ctx)
-      {
-         OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
-         unresolvedBundles.remove(bundleState);
-      }
-
-      public void install(ControllerContext ctx) throws Exception
-      {
-         Runnable runnable = new Runnable()
-         {
-            public void run()
-            {
-               try
-               {
-                  // [TODO] remove this hack and find a way to trigger
-                  // PackageAdmin after the context has been deployed
-                  Thread.sleep(100);
-               }
-               catch (InterruptedException e)
-               {
-                  // ignore
-               }
-
-               OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
-
-               // Add the new bundle to the list of unresolved
-               unresolvedBundles.add(0, bundleState);
-               OSGiBundleState[] unresolved = new OSGiBundleState[unresolvedBundles.size()];
-               unresolvedBundles.toArray(unresolved);
-
-               // Try to resolve all unresolved bundles
-               packageAdmin.resolveBundles(unresolved);
-               if (bundleState.getState() != Bundle.RESOLVED)
-                  log.info("Unresolved: " + bundleState);
-                  
-               for (OSGiBundleState aux : unresolved)
-               {
-                  if (aux.getState() == Bundle.RESOLVED)
-                  {
-                     unresolvedBundles.remove(aux);
-                     
-                     try
-                     {
-                        // When resolved progress to INSTALLED
-                        String name = aux.getDeploymentUnit().getName();
-                        deployerClient.change(name, DeploymentStages.INSTALLED);
-                     }
-                     catch (DeploymentException ex)
-                     {
-                        log.error(ex);
-                     }
-                  }
-               }
-            }
-         };
-         new Thread(runnable).start();
-      }
-
-      public ControllerState getWhenRequired()
-      {
-         return new ControllerState(getStage().getName());
-      }
-
-      public ControllerState getDependentState()
-      {
-         return null;
-      }
-
-      public Object getBean()
-      {
-         return null;
-      }
-   }
-}

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -180,7 +180,7 @@
    public Bundle getBundle(long id)
    {
       checkValidBundleContext();
-      AbstractBundleState bundleState = getBundleManager().getBundle(id);
+      AbstractBundleState bundleState = getBundleManager().getBundleById(id);
       return bundleState != null ? bundleState.getBundleInternal() : null;
    }
 

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -419,7 +419,7 @@
       if (id == 0)
          throw new IllegalArgumentException("Cannot uninstall system bundle");
 
-      OSGiBundleState state = (OSGiBundleState)getBundle(id);
+      OSGiBundleState state = (OSGiBundleState)getBundleById(id);
       if (state == null)
          throw new BundleException(bundle + " not installed");
 
@@ -537,26 +537,6 @@
    }
 
    /**
-    * Get a bundle by id
-    * 
-    * @param id the id of the bundle
-    * @return the bundle or null if there is no bundle with that id
-    */
-   public AbstractBundleState getBundle(long id)
-   {
-      AbstractBundleState result = null;
-      for (AbstractBundleState aux : bundles)
-      {
-         if (id == aux.getBundleId())
-         {
-            result = aux;
-            break;
-         }
-      }
-      return result;
-   }
-
-   /**
     * Get the system bundle
     * 
     * @return the system bundle
@@ -587,7 +567,7 @@
       if (id == 0)
          throw new IllegalArgumentException("Cannot get deployment from system bundle");
 
-      OSGiBundleState bundleState = (OSGiBundleState)getBundle(id);
+      OSGiBundleState bundleState = (OSGiBundleState)getBundleById(id);
       if (bundleState == null)
          return null;
 
@@ -595,6 +575,47 @@
    }
 
    /**
+    * Get a bundle by id
+    * 
+    * @param id the id of the bundle
+    * @return the bundle or null if there is no bundle with that id
+    */
+   public AbstractBundleState getBundleById(long id)
+   {
+      AbstractBundleState result = null;
+      for (AbstractBundleState aux : bundles)
+      {
+         if (id == aux.getBundleId())
+         {
+            result = aux;
+            break;
+         }
+      }
+      return result;
+   }
+
+   /**
+    * Get a bundle by location
+    * 
+    * @param location the location of the bundle
+    * @return the bundle or null if there is no bundle with that location
+    */
+   public AbstractBundleState getBundleByLocation(String location)
+   {
+      AbstractBundleState result = null;
+      for (AbstractBundleState aux : bundles)
+      {
+         String auxLocation = aux.getLocation();
+         if (auxLocation.equals(location))
+         {
+            result = aux;
+            break;
+         }
+      }
+      return result;
+   }
+
+   /**
     * Get all the bundles
     * 
     * @return the bundles

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -99,14 +99,7 @@
          return url.toString();
 
       DeploymentUnit unit = getDeploymentUnit();
-      if (unit instanceof VFSDeploymentUnit)
-      {
-         VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
-         VirtualFile root = vfsDeploymentUnit.getRoot();
-         return root.getPathName();
-      }
-
-      return null;
+      return unit.getName();
    }
 
    public URL getEntry(String path)

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -21,17 +21,34 @@
 */
 package org.jboss.osgi.plugins.facade.classloading;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
 import org.jboss.classloader.spi.ClassLoaderDomain;
 import org.jboss.classloader.spi.ClassLoaderPolicy;
 import org.jboss.classloader.spi.ClassLoaderSystem;
 import org.jboss.classloader.spi.ParentPolicy;
 import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloader.spi.filter.PackageClassFilter;
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.osgi.plugins.facade.bundle.AbstractBundleState;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
 
 /**
- * OSGiClassLoaderSystem.<p>
+ * OSGiClassLoaderSystem.
+ * <p>
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @author Thomas.Diesler at jboss.com
@@ -39,14 +56,21 @@
  */
 public class OSGiClassLoaderSystem extends ClassLoaderSystem
 {
+   private OSGiBundleManager bundleManager;
+
    /**
     * Create a new OSGiClassLoaderSystem.
+    * 
     * @throws IllegalArgumentException for a null bundle manager
     */
-   public OSGiClassLoaderSystem()
+   public OSGiClassLoaderSystem(OSGiBundleManager bundleManager)
    {
+      if (bundleManager == null)
+         throw new IllegalArgumentException("Null bundleManager");
+      this.bundleManager = bundleManager;
+
       ClassLoaderDomain domain = getDefaultDomain();
-      
+
       domain.setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
       AbstractJDKChecker.getExcluded().add(AbstractBundleState.class);
       AbstractJDKChecker.getExcluded().add(OSGiBundleState.class);
@@ -57,9 +81,75 @@
    {
       return new ClassLoaderDomain(name);
    }
-   
+
+   @Override
    protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy)
    {
+      // Get excluded packages
+      List<String> excludedPackages = getExcludedPackages(policy);
+      
+      // Exclude the packages from the policy
+      if (excludedPackages.isEmpty() == false && policy instanceof VFSClassLoaderPolicy)
+      {
+         String[] packageArr = new String[excludedPackages.size()];
+         excludedPackages.toArray(packageArr);
+
+         VFSClassLoaderPolicy vfsPolicy = (VFSClassLoaderPolicy)policy;
+         vfsPolicy.setExcluded(new PackageClassFilter(packageArr));
+      }
+
       return new OSGiBundleClassLoader(policy);
    }
+
+   private List<String> getExcludedPackages(ClassLoaderPolicy policy)
+   {
+      // Get the bundle location from the policy id
+      String location = policy.getObjectName().getKeyProperty("id");
+      if (location.startsWith("\"") && location.endsWith("\""))
+         location = location.substring(1, location.length() - 1);
+
+      List<String> exportedPackages = new ArrayList<String>();
+      List<String> excludedPackages = new ArrayList<String>();
+
+      OSGiBundleState bundle = (OSGiBundleState)bundleManager.getBundleByLocation(location);
+      if (bundle != null)
+      {
+         // Collect the exported package names
+         DeploymentUnit unit = bundle.getDeploymentUnit();
+         ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
+         for (Capability capability : metadata.getCapabilities().getCapabilities())
+         {
+            if (capability instanceof PackageCapability)
+            {
+               PackageCapability packageCapability = (PackageCapability)capability;
+               exportedPackages.add(packageCapability.getName());
+            }
+         }
+         
+         // Collect the imported package names
+         DependencyInfo di = unit.getAttachment(ControllerContext.class).getDependencyInfo();
+         for (DependencyItem item : di.getIDependOn(RequirementDependencyItem.class))
+         {
+            RequirementDependencyItem reqdi = (RequirementDependencyItem)item;
+            Requirement requirement = reqdi.getRequirement();
+            if (requirement instanceof PackageRequirement)
+            {
+               PackageRequirement packageRequirement = (PackageRequirement)requirement;
+               String packageName = packageRequirement.getName();
+               
+               // If the imported package is also an exported package
+               if (exportedPackages.contains(packageName))
+               {
+                  // Exclude if the import comes from another module
+                  Object other = item.getIDependOn();
+                  if (other != null && location.equals(other) == false)
+                  {
+                     excludedPackages.add(packageName);
+                  }
+               }
+            }
+         }
+      }
+      return excludedPackages;
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -100,7 +100,7 @@
          throw new IllegalStateException("Cannot obtain installed bean: " + OSGiBundleManager.BEAN_BUNDLE_MANAGER);
 
       OSGiBundleManager manager = (OSGiBundleManager)managerContext.getTarget();
-      OSGiSystemState sysBundle = (OSGiSystemState)manager.getBundle(0);
+      OSGiSystemState sysBundle = (OSGiSystemState)manager.getBundleById(0);
       
       return new OSGiFramework(manager, sysBundle);
    }

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java	2009-09-10 04:35:14 UTC (rev 93337)
@@ -122,7 +122,7 @@
     */
    protected Bundle getSystemBundle()
    {
-      return getBundleManager().getBundle(0).getBundleInternal();
+      return getBundleManager().getBundleById(0).getBundleInternal();
    }
 
    /**

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml	2009-09-10 01:03:11 UTC (rev 93336)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml	2009-09-10 04:35:14 UTC (rev 93337)
@@ -140,7 +140,9 @@
   ********************************
   -->
   
-  <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderSystem" />
+  <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderSystem" >
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
   <bean name="OSGiClassLoaderDomain" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderDomain" >
     <constructor><parameter>OSGiClassLoaderDomain</parameter></constructor>
     <property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>



More information about the jboss-osgi-commits mailing list