[jboss-cvs] JBossAS SVN: r87995 - in projects/jboss-osgi/trunk: bundle/blueprint/src/test/resources and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 29 07:55:49 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-04-29 07:55:49 -0400 (Wed, 29 Apr 2009)
New Revision: 87995

Added:
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/ExportedPackageHelper.java
Modified:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerServiceTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
   projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java
   projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
Log:
XMLParser handling - ok

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerServiceTestCase.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerServiceTestCase.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -26,6 +26,7 @@
 import static org.jboss.osgi.microcontainer.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
 import static org.jboss.osgi.microcontainer.MicrocontainerService.BEAN_SYSTEM_BUNDLE_CONTEXT;
 import static org.jboss.osgi.microcontainer.MicrocontainerService.BEAN_MBEAN_SERVER;
+import static org.jboss.osgi.microcontainer.MicrocontainerService.BEAN_MAIN_DEPLOYER;
 import static org.jboss.osgi.microcontainer.MicrocontainerService.BEAN_KERNEL;
 
 import java.util.List;
@@ -58,6 +59,7 @@
          MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
          List<String> registeredBeans = mcService.getRegisteredBeans();
          assertTrue("MicrocontainerService registered with MC", registeredBeans.contains(BEAN_SYSTEM_BUNDLE_CONTEXT));
+         assertTrue("MainDeployer registered with MC", registeredBeans.contains(BEAN_MAIN_DEPLOYER));
          assertTrue("MBeanServer registered with MC", registeredBeans.contains(BEAN_MBEAN_SERVER));
          assertTrue("Kernel registered with MC", registeredBeans.contains(BEAN_KERNEL));
       }

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties	2009-04-29 11:55:49 UTC (rev 87995)
@@ -10,21 +10,8 @@
 # Properties to configure the Framework
 # All props start with 'framework.prop' 
 framework.prop.org.osgi.framework.storage.clean=onFirstInit
-framework.prop.org.osgi.framework.system.packages=\
-	javax.activation, \
-	javax.management, \
-	javax.naming, \
-	javax.naming.spi, \
-  	javax.net, \
-  	javax.net.ssl, \
-  	javax.xml.bind.annotation, \
-  	javax.xml.bind.annotation.adapters, \
-  	javax.xml.namespace, \
-  	javax.xml.parsers, \
-  	javax.xml.transform, \
-  	javax.xml.transform.sax, \
-  	org.jboss.logging, \
-	org.osgi.framework; version=1.4
+framework.prop.org.osgi.framework.system.packages.extra=\
+	org.jboss.logging
 
 # Bundles that need to be installed with the Framework automatically 
 framework.autoInstall=\

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties	2009-04-29 11:55:49 UTC (rev 87995)
@@ -10,21 +10,10 @@
 # Properties to configure the Framework
 # All props start with 'framework.prop' 
 framework.prop.org.osgi.framework.storage.clean=onFirstInit
-framework.prop.org.osgi.framework.system.packages=\
-	javax.activation, \
-	javax.management, \
-	javax.naming, \
-	javax.naming.spi, \
-  	javax.net, \
-  	javax.net.ssl, \
-  	javax.xml.bind, \
-  	javax.xml.bind.annotation, \
-  	javax.xml.bind.annotation.adapters, \
-  	javax.xml.namespace, \
-  	org.jboss.logging, \
-  	org.jboss.osgi.spi.management, \
-	org.osgi.framework; version=1.4, \
-	org.osgi.service.packageadmin; version=1.2
+framework.prop.org.osgi.framework.system.packages.extra=\
+	org.jboss.logging, \
+  	org.jboss.osgi.spi, \
+  	org.jboss.osgi.spi.management
 
 # Bundles that need to be installed with the Framework automatically 
 framework.autoInstall=\

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml	2009-04-29 11:55:49 UTC (rev 87995)
@@ -108,6 +108,7 @@
               org.jboss.logging, 
               org.jboss.osgi.common.log, 
               org.jboss.osgi.jmx,
+              org.jboss.osgi.spi,
               org.jboss.reflect.*,            
               org.jboss.util.*, 
               org.jboss.xb.*,

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -49,6 +49,11 @@
    /** 
     * The name under which the Kernel is registered: 'jboss.osgi:service=Kernel' 
     */
+   String BEAN_MAIN_DEPLOYER = "jboss.osgi:service=MainDeployer";
+
+   /** 
+    * The name under which the Kernel is registered: 'jboss.osgi:service=Kernel' 
+    */
    String BEAN_KERNEL = "jboss.osgi:service=Kernel";
 
    /**

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -28,6 +28,10 @@
 import java.util.HashMap;
 import java.util.List;
 
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+import javax.xml.parsers.SAXParserFactory;
+
 import org.jboss.dependency.plugins.AbstractController;
 import org.jboss.dependency.plugins.AbstractControllerContext;
 import org.jboss.dependency.plugins.AbstractControllerContextActions;
@@ -35,11 +39,18 @@
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerContextActions;
 import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.osgi.common.log.LogServiceTracker;
 import org.jboss.osgi.microcontainer.MicrocontainerService;
 import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * An OSGi Service the gives access to the Kernel.
@@ -49,29 +60,20 @@
  */
 public class MicrocontainerServiceImpl implements MicrocontainerService, MicrocontainerServiceMBean
 {
+   private static final SAXParserFactory saxFactory = SAXParserFactory.newInstance();
+
+   private BundleContext context;
    private EmbeddedBeansDeployer deployer;
+   private MBeanServerTracker mbeanServerTracker;
+   private ServiceRegistration registration;
+   private LogService log;
 
    public MicrocontainerServiceImpl(BundleContext context)
    {
+      this.context = context;
+      this.log = new LogServiceTracker(context);
+
       deployer = new EmbeddedBeansDeployer(context);
-      
-      // Preregister some beans
-      try
-      {
-         Kernel kernel = getKernel();
-         KernelController controller = kernel.getController();
-         ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
-         controller.install(new AbstractControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, null, context));
-         controller.install(new AbstractControllerContext(BEAN_KERNEL, actions, null, kernel));
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Throwable ex)
-      {
-         throw new IllegalStateException("Cannot register MC bean", ex);
-      }
    }
 
    public Kernel getKernel()
@@ -82,11 +84,11 @@
    public List<String> getRegisteredBeans()
    {
       List<String> names = new ArrayList<String>();
-      
+
       AbstractController controller = (AbstractController)getKernel().getController();
       for (ControllerContext ctx : controller.getAllContexts())
          names.add(ctx.getName().toString());
-         
+
       return names;
    }
 
@@ -98,29 +100,135 @@
 
    public void deploy(URL url)
    {
-      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+      MainDeployer mainDeployer = (MainDeployer)getRegisteredBean(BEAN_MAIN_DEPLOYER);
+   }
+
+   public void undeploy(URL url)
+   {
+      throw new NotImplementedException();
+   }
+
+   void start()
+   {
+      // Preregister some beans
       try
       {
-         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-         deployer.deploy(url);
+         Kernel kernel = getKernel();
+         KernelController controller = kernel.getController();
+         ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+         controller.install(new AbstractControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, null, context));
+         controller.install(new AbstractControllerContext(BEAN_KERNEL, actions, null, kernel));
+
+         URL deployersURL = context.getBundle().getResource("META-INF/base-deployers-beans.xml");
+         deployer.deploy(deployersURL);
       }
-      finally
+      catch (RuntimeException rte)
       {
-         Thread.currentThread().setContextClassLoader(ctxLoader);
+         throw rte;
       }
+      catch (Throwable ex)
+      {
+         throw new IllegalStateException("Cannot register MC bean", ex);
+      }
+
+      log.log(LogService.LOG_DEBUG, "Register MicrocontainerService");
+      registration = context.registerService(MicrocontainerService.class.getName(), this, null);
+
+      // Track the MBeanServer to register the MicrocontainerServiceMBean
+      mbeanServerTracker = new MBeanServerTracker(context, this);
+      mbeanServerTracker.open();
    }
 
-   public void undeploy(URL url)
+   void stop()
    {
-      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
-      try
+      if (registration != null)
       {
-         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-         deployer.undeploy(url);
+         log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
+         registration.unregister();
+         registration = null;
       }
-      finally
+   }
+
+   private void unregisterMBean(MBeanServer server)
+   {
+      if (server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
       {
-         Thread.currentThread().setContextClassLoader(ctxLoader);
+         try
+         {
+            log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerServiceMBean");
+            server.unregisterMBean(MBEAN_MICROCONTAINER_SERVICE);
+         }
+         catch (Exception ex)
+         {
+            log.log(LogService.LOG_ERROR, "Cannot register MicrocontainerServiceMBean", ex);
+         }
       }
    }
+
+   class MBeanServerTracker extends ServiceTracker
+   {
+      private MicrocontainerServiceImpl mcService;
+
+      public MBeanServerTracker(BundleContext context, MicrocontainerServiceImpl mcService)
+      {
+         super(context, MBeanServer.class.getName(), null);
+         this.mcService = mcService;
+      }
+
+      public Object addingService(ServiceReference reference)
+      {
+         MBeanServer server = (MBeanServer)super.addingService(reference);
+
+         // Register the MicrocontainerServiceMBean
+         try
+         {
+            log.log(LogService.LOG_DEBUG, "Register MicrocontainerServiceMBean");
+            StandardMBean mbean = new StandardMBean(mcService, MicrocontainerServiceMBean.class);
+            server.registerMBean(mbean, MBEAN_MICROCONTAINER_SERVICE);
+         }
+         catch (Exception ex)
+         {
+            throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
+         }
+
+         // Install the MBeanServer with the Kernel
+         try
+         {
+            ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+            mcService.getKernel().getController().install(new AbstractControllerContext(BEAN_MBEAN_SERVER, actions, null, server));
+         }
+         catch (RuntimeException rte)
+         {
+            throw rte;
+         }
+         catch (Throwable ex)
+         {
+            throw new IllegalStateException("Cannot register MC bean", ex);
+         }
+
+         return server;
+      }
+
+      @Override
+      public void removedService(ServiceReference reference, Object service)
+      {
+         // Unregister MBean
+         unregisterMBean((MBeanServer)service);
+
+         // Uninstall the MBeanServer from the Kernel
+         try
+         {
+            mcService.getKernel().getController().uninstall(BEAN_MBEAN_SERVER);
+         }
+         catch (RuntimeException rte)
+         {
+            throw rte;
+         }
+         catch (Throwable ex)
+         {
+            throw new IllegalStateException("Cannot register MC bean", ex);
+         }
+         super.removedService(reference, service);
+      }
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -23,28 +23,9 @@
 
 //$Id$
 
-import static org.jboss.osgi.microcontainer.MicrocontainerService.BEAN_MBEAN_SERVER;
-import static org.jboss.osgi.microcontainer.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
-
-import java.util.HashMap;
-
-import javax.management.MBeanServer;
-import javax.management.StandardMBean;
-
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractControllerContextActions;
-import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.osgi.common.log.LogServiceTracker;
 import org.jboss.osgi.microcontainer.MicrocontainerService;
-import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * A BundleActivator that registers the {@link MicrocontainerService}
@@ -54,47 +35,16 @@
  */
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-   private MBeanServerTracker mbeanServerTracker;
-   private LogService log;
+   private MicrocontainerServiceImpl mcService;
 
    public void start(BundleContext context)
    {
-      log = new LogServiceTracker(context);
-
-      // Register the MicrocontainerService as OSGi service
-      MicrocontainerServiceImpl mcService = registerOSGiService(context);
-
-      // Track the MBeanServer to register the MicrocontainerServiceMBean
-      mbeanServerTracker = new MBeanServerTracker(context, mcService);
-      mbeanServerTracker.open();
-   }
-
-   public void stop(BundleContext context)
-   {
-      if (registration != null)
-      {
-         MBeanServer server = (MBeanServer)mbeanServerTracker.getService();
-         if (server != null)
-            unregisterMBean(server);
-         
-         log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
-         registration.unregister();
-         registration = null;
-      }
-   }
-
-   private MicrocontainerServiceImpl registerOSGiService(BundleContext context)
-   {
       ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
       try
       {
          Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-         MicrocontainerServiceImpl service = new MicrocontainerServiceImpl(context);
-
-         log.log(LogService.LOG_DEBUG, "Register MicrocontainerService");
-         registration = context.registerService(MicrocontainerService.class.getName(), service, null);
-         return service;
+         mcService = new MicrocontainerServiceImpl(context);
+         mcService.start();
       }
       finally
       {
@@ -102,86 +52,9 @@
       }
    }
 
-   private void unregisterMBean(MBeanServer server)
+   public void stop(BundleContext context)
    {
-      if (server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
-      {
-         try
-         {
-            log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerServiceMBean");
-            server.unregisterMBean(MBEAN_MICROCONTAINER_SERVICE);
-         }
-         catch (Exception ex)
-         {
-            log.log(LogService.LOG_ERROR, "Cannot register MicrocontainerServiceMBean", ex);
-         }
-      }
+      if (mcService != null)
+         mcService.stop();
    }
-
-   class MBeanServerTracker extends ServiceTracker
-   {
-      private MicrocontainerServiceImpl mcService;
-
-      public MBeanServerTracker(BundleContext context, MicrocontainerServiceImpl mcService)
-      {
-         super(context, MBeanServer.class.getName(), null);
-         this.mcService = mcService;
-      }
-
-      public Object addingService(ServiceReference reference)
-      {
-         MBeanServer server = (MBeanServer)super.addingService(reference);
-         
-         // Register the MicrocontainerServiceMBean
-         try
-         {
-            log.log(LogService.LOG_DEBUG, "Register MicrocontainerServiceMBean");
-            StandardMBean mbean = new StandardMBean(mcService, MicrocontainerServiceMBean.class);
-            server.registerMBean(mbean, MBEAN_MICROCONTAINER_SERVICE);
-         }
-         catch (Exception ex)
-         {
-            throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
-         }
-         
-         // Install the MBeanServer with the Kernel
-         try
-         {
-            ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
-            mcService.getKernel().getController().install(new AbstractControllerContext(BEAN_MBEAN_SERVER, actions, null, server));
-         }
-         catch (RuntimeException rte)
-         {
-            throw rte;
-         }
-         catch (Throwable ex)
-         {
-            throw new IllegalStateException("Cannot register MC bean", ex);
-         }
-         
-         return server;
-      }
-
-      @Override
-      public void removedService(ServiceReference reference, Object service)
-      {
-         // Unregister MBean
-         unregisterMBean((MBeanServer)service);
-         
-         // Uninstall the MBeanServer from the Kernel
-         try
-         {
-            mcService.getKernel().getController().uninstall(BEAN_MBEAN_SERVER);
-         }
-         catch (RuntimeException rte)
-         {
-            throw rte;
-         }
-         catch (Throwable ex)
-         {
-            throw new IllegalStateException("Cannot register MC bean", ex);
-         }
-         super.removedService(reference, service);
-      }
-   }
 }
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml	2009-04-29 11:55:49 UTC (rev 87995)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   The base deployers
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- The MainDeployer -->
+   <bean name="jboss.osgi:service=MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+   </bean>
+   
+</deployment>
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -32,6 +32,7 @@
 import org.apache.felix.framework.Felix;
 import org.jboss.logging.Logger;
 import org.jboss.osgi.spi.FrameworkException;
+import org.jboss.osgi.spi.framework.ExportedPackageHelper;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -146,7 +147,8 @@
          try
          {
             Bundle bundle = context.installBundle(bundleURL.toString());
-            log.info("Installed bundle: " + bundle.getSymbolicName());
+            long bundleId = bundle.getBundleId();
+            log.info("Installed bundle [" + bundleId + "]: " + bundle.getSymbolicName());
             autoBundles.put(bundleURL, bundle);
          }
          catch (BundleException ex)
@@ -156,13 +158,18 @@
       }
 
       // Start autoStart bundles
+      ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
       for (URL bundleURL : autoStart)
       {
          try
          {
             Bundle bundle = autoBundles.get(bundleURL);
-            bundle.start();
-            log.info("Started bundle: " + bundle.getSymbolicName());
+            if (bundle != null)
+            {
+               bundle.start();
+               packageHelper.logExportedPackages(bundle);
+               log.info("Started bundle: " + bundle.getSymbolicName());
+            }
          }
          catch (BundleException ex)
          {

Added: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/ExportedPackageHelper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/ExportedPackageHelper.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/ExportedPackageHelper.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.framework;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * A helper the logs the exported packages for a bundle.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public final class ExportedPackageHelper
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(ExportedPackageHelper.class);
+
+   private PackageAdmin packageAdmin;
+
+   public ExportedPackageHelper(BundleContext context)
+   {
+      ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+      packageAdmin = (PackageAdmin)context.getService(sref);
+   }
+
+   public boolean resolveBundle(Bundle bundle)
+   {
+      return packageAdmin.resolveBundles(new Bundle[] { bundle });
+   }
+
+   public boolean resolveBundles(Bundle[] bundles)
+   {
+      return packageAdmin.resolveBundles(bundles);
+   }
+
+   /*
+    * * Log the list of exported packages
+    */
+   public void logExportedPackages(Bundle bundle)
+   {
+      log.debug("Exported-Packages: " + bundle.getSymbolicName());
+      
+      List<String> packages = new ArrayList<String>();
+      for (ExportedPackage exp : packageAdmin.getExportedPackages(bundle))
+         packages.add("  " + exp.getName() + ";version=" + exp.getVersion());
+      
+      Collections.sort(packages);
+      for (String exp : packages)
+         log.debug(exp);
+   }
+}
\ No newline at end of file


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

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java	2009-04-29 11:54:59 UTC (rev 87994)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java	2009-04-29 11:55:49 UTC (rev 87995)
@@ -25,6 +25,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
+import org.jboss.osgi.spi.framework.ExportedPackageHelper;
 import org.jboss.osgi.spi.framework.OSGiBootstrap;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.spi.framework.OSGiFramework;
@@ -173,8 +174,15 @@
    {
       Bundle bundle = sysContext.installBundle(getTestArchiveURL(bundlePath).toExternalForm());
 
+      ExportedPackageHelper packageHelper = new ExportedPackageHelper(sysContext);
+      packageHelper.resolveBundle(bundle);
+      
       if (start == true)
+      {
          bundle.start();
+      }
+      
+      packageHelper.logExportedPackages(bundle);
 
       return bundle;
    }




More information about the jboss-cvs-commits mailing list