[jboss-cvs] JBossAS SVN: r89546 - in projects/jboss-osgi/trunk: bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat May 30 07:53:38 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-30 07:53:38 -0400 (Sat, 30 May 2009)
New Revision: 89546

Added:
   projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.java
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/ManagementServiceBean.java
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/MicrocontainerServiceBean.java
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/NamingServiceBean.java
Removed:
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
   projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/
Modified:
   projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java
   projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
   projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
   projects/jboss-osgi/trunk/integration/jbossas/pom.xml
Log:
Reuse mc bundle code in jbossas integration - WIP

Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -121,6 +121,9 @@
    {
       String serviceName = DeployerService.class.getName();
       ServiceReference sref = context.getServiceReference(serviceName);
+      if (sref == null)
+         throw new IllegalStateException("Cannot obtain system DeployerService");
+      
       return (DeployerService)context.getService(sref);
    }
 

Added: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -0,0 +1,286 @@
+/*
+ * 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.microcontainer.internal;
+
+//$Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.common.service.BundleInfo;
+import org.jboss.osgi.common.service.DeployerService;
+import org.jboss.osgi.common.service.MicrocontainerService;
+import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.BundleException;
+
+/**
+ * An OSGi Service the gives access to the Kernel.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public abstract class AbstractMicrocontainerService implements DeployerService, MicrocontainerService
+{
+   private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
+   private Map<URL, String> contextMap = Collections.synchronizedMap(new HashMap<URL, String>());
+   
+   public abstract Kernel getKernel();
+   
+   public abstract void logDebug(String message);
+   
+   public abstract void logWarning(String message, Exception ex);
+
+   public void logWarning(String message)
+   {
+      logWarning(message, null);
+   }
+   
+   public List<String> getRegisteredBeans()
+   {
+      List<String> names = new ArrayList<String>();
+
+      AbstractController controller = (AbstractController)getKernel().getController();
+      for (ControllerContext ctx : controller.getAllContexts())
+      {
+         if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
+            names.add(ctx.getName().toString());
+      }
+
+      return names;
+   }
+
+   public Object getRegisteredBean(String beanName)
+   {
+      ControllerContext context = getKernel().getController().getInstalledContext(beanName);
+      return context != null ? context.getTarget() : null;
+   }
+
+   public void deploy(URL url) throws BundleException
+   {
+      BundleInfo info = new LocationOnlyBundleInfo(url);
+      deploy(new BundleInfo[] { info });
+   }
+
+   public boolean undeploy(URL url) throws BundleException
+   {
+      String deploymentName = contextMap.remove(url);
+      if (deploymentName == null)
+      {
+         logWarning("Package not deployed: " + url);
+         return false;
+      }
+
+      try
+      {
+         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+         mainDeployer.removeDeployment(deploymentName);
+         mainDeployer.process();
+         return true;
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         logWarning("Cannot undeploy bundle", ex);
+         return false;
+      }
+   }
+
+   public void deploy(BundleInfo[] bundles) throws BundleException
+   {
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+         List<Deployment> deployments = new ArrayList<Deployment>();
+         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+         for (BundleInfo bundle : bundles)
+         {
+            VirtualFile file = VFS.createNewRoot(bundle.getLocation());
+            VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
+            mainDeployer.addDeployment(deployment);
+            deployments.add(deployment);
+            contextMap.put(bundle.getLocation(), deployment.getName());
+         }
+
+         // Process the deployments
+         mainDeployer.process();
+
+         // Check for completeness
+         Deployment[] depArr = deployments.toArray(new Deployment[deployments.size()]);
+         mainDeployer.checkComplete(depArr);
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         throw new BundleException("Cannot deploy bundles", ex);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(ctxLoader);
+      }
+   }
+
+   public void undeploy(BundleInfo[] bundles) throws BundleException
+   {
+      try
+      {
+         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+         for (BundleInfo bundle : bundles)
+         {
+            String deploymentName = contextMap.remove(bundle.getLocation());
+            if (deploymentName != null)
+            {
+               mainDeployer.removeDeployment(deploymentName);
+            }
+            else
+            {
+               logWarning("Package not deployed: " + bundle.getLocation());
+            }
+         }
+         mainDeployer.process();
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         logWarning("Cannot undeploy bundles", ex);
+      }
+   }
+
+   protected void installBean(KernelController controller, String beanName, Object beanImpl)
+   {
+      try
+      {
+         ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+         controller.install(new PreInstalledControllerContext(beanName, actions, beanImpl));
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Throwable ex)
+      {
+         throw new IllegalStateException("Cannot register bean: " + beanName, ex);
+      }
+   }
+   
+   protected void registerMicrocontainerServiceMBean(MBeanServer mbeanServer)
+   {
+      try
+      {
+         logDebug("Register MicrocontainerServiceMBean");
+         StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
+         mbeanServer.registerMBean(mbean, MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
+      }
+      catch (Exception ex)
+      {
+         throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
+      }
+   }
+
+   protected void unregisterMicrocontainerServiceMBean(MBeanServer mbeanServer)
+   {
+         if (mbeanServer.isRegistered(MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE))
+         {
+            try
+            {
+               logDebug("Unregister MicrocontainerServiceMBean");
+               mbeanServer.unregisterMBean(MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
+            }
+            catch (Exception ex)
+            {
+               logWarning("Cannot unregister MicrocontainerServiceMBean", ex);
+            }
+         }
+   }
+
+   static class PreInstalledControllerContext extends AbstractControllerContext
+   {
+      public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
+      {
+         super(name, actions, null, target);
+      }
+   }
+
+   static class LocationOnlyBundleInfo implements BundleInfo
+   {
+      private URL location;
+
+      public LocationOnlyBundleInfo(URL location)
+      {
+         this.location = location;
+      }
+
+      public URL getLocation()
+      {
+         return location;
+      }
+
+      public State getState()
+      {
+         throw new NotImplementedException();
+      }
+
+      public String getSymbolicName()
+      {
+         throw new NotImplementedException();
+      }
+
+      public String getVersion()
+      {
+         throw new NotImplementedException();
+      }
+   }
+}
\ No newline at end of file


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

Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -24,58 +24,35 @@
 //$Id$
 
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 import javax.management.MBeanServer;
-import javax.management.StandardMBean;
 
-import org.jboss.dependency.plugins.AbstractController;
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractControllerContextActions;
-import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.common.service.BundleInfo;
 import org.jboss.osgi.common.service.DeployerService;
 import org.jboss.osgi.common.service.MicrocontainerService;
 import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.NotImplementedException;
 import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
- * An OSGi Service the gives access to the Kernel.
+ * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
+ * which is installed as a bundle
  * 
  * @author thomas.diesler at jboss.com
  * @since 23-Jan-2009
  */
-public class MicrocontainerServiceImpl implements DeployerService, MicrocontainerService, MicrocontainerServiceMBean
+public class MicrocontainerServiceImpl extends AbstractMicrocontainerService implements MicrocontainerServiceMBean
 {
    private BundleContext context;
    private EmbeddedBeansDeployer deployer;
    private LogService log;
 
-   private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
-   private Map<URL, String> contextMap = Collections.synchronizedMap(new HashMap<URL, String>());
 
    public MicrocontainerServiceImpl(BundleContext context)
    {
@@ -92,127 +69,18 @@
       return deployer.getKernel();
    }
 
-   public List<String> getRegisteredBeans()
+   @Override
+   public void logDebug(String message)
    {
-      List<String> names = new ArrayList<String>();
-
-      AbstractController controller = (AbstractController)getKernel().getController();
-      for (ControllerContext ctx : controller.getAllContexts())
-      {
-         if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
-            names.add(ctx.getName().toString());
-      }
-
-      return names;
+      log.log(LogService.LOG_DEBUG, message);
    }
 
-   public Object getRegisteredBean(String beanName)
+   @Override
+   public void logWarning(String message, Exception ex)
    {
-      ControllerContext context = getKernel().getController().getInstalledContext(beanName);
-      return context != null ? context.getTarget() : null;
+      log.log(LogService.LOG_WARNING, message, ex);
    }
 
-   public void deploy(BundleInfo[] bundles) throws BundleException
-   {
-      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
-      try
-      {
-         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
-         List<Deployment> deployments = new ArrayList<Deployment>();
-         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
-         for (BundleInfo bundle : bundles)
-         {
-            VirtualFile file = VFS.createNewRoot(bundle.getLocation());
-            VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
-            mainDeployer.addDeployment(deployment);
-            deployments.add(deployment);
-            contextMap.put(bundle.getLocation(), deployment.getName());
-         }
-
-         // Process the deployments
-         mainDeployer.process();
-
-         // Check for completeness
-         Deployment[] depArr = deployments.toArray(new Deployment[deployments.size()]);
-         mainDeployer.checkComplete(depArr);
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         throw new BundleException("Cannot deploy bundles", ex);
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(ctxLoader);
-      }
-   }
-
-   public void undeploy(BundleInfo[] bundles) throws BundleException
-   {
-      try
-      {
-         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
-         for (BundleInfo bundle : bundles)
-         {
-            String deploymentName = contextMap.remove(bundle.getLocation());
-            if (deploymentName != null)
-            {
-               mainDeployer.removeDeployment(deploymentName);
-            }
-            else
-            {
-               log.log(LogService.LOG_WARNING, "Package not deployed: " + bundle.getLocation());
-            }
-         }
-         mainDeployer.process();
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         log.log(LogService.LOG_WARNING, "Cannot undeploy bundles", ex);
-      }
-   }
-
-   public void deploy(URL url) throws BundleException
-   {
-      BundleInfo info = new LocationOnlyBundleInfo(url);
-      deploy(new BundleInfo[] { info });
-   }
-
-   public boolean undeploy(URL url) throws BundleException
-   {
-      String deploymentName = contextMap.remove(url);
-      if (deploymentName == null)
-      {
-         log.log(LogService.LOG_WARNING, "Package not deployed: " + url);
-         return false;
-      }
-
-      try
-      {
-         MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
-         mainDeployer.removeDeployment(deploymentName);
-         mainDeployer.process();
-         return true;
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         log.log(LogService.LOG_WARNING, "Cannot undeploy bundle", ex);
-         return false;
-      }
-   }
-
    void start()
    {
       final MicrocontainerService mcServiceImpl = this;
@@ -260,97 +128,11 @@
 
    void stop()
    {
-      unregisterMicrocontainerServiceMBean();
-   }
-
-   private void installBean(KernelController controller, String beanName, Object beanImpl)
-   {
-      try
-      {
-         ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
-         controller.install(new PreInstalledControllerContext(beanName, actions, beanImpl));
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Throwable ex)
-      {
-         throw new IllegalStateException("Cannot register bean: " + beanName, ex);
-      }
-   }
-
-   private void registerMicrocontainerServiceMBean(MBeanServer mbeanServer)
-   {
-      // Register the MicrocontainerServiceMBean
-      try
-      {
-         log.log(LogService.LOG_DEBUG, "Register MicrocontainerServiceMBean");
-         StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
-         mbeanServer.registerMBean(mbean, MBEAN_MICROCONTAINER_SERVICE);
-      }
-      catch (Exception ex)
-      {
-         throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
-      }
-   }
-
-   private void unregisterMicrocontainerServiceMBean()
-   {
       ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
       if (sref != null)
       {
          MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
-         if (mbeanServer.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
-         {
-            try
-            {
-               log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerServiceMBean");
-               mbeanServer.unregisterMBean(MBEAN_MICROCONTAINER_SERVICE);
-            }
-            catch (Exception ex)
-            {
-               log.log(LogService.LOG_ERROR, "Cannot unregister MicrocontainerServiceMBean", ex);
-            }
-         }
+         unregisterMicrocontainerServiceMBean(mbeanServer);
       }
    }
-
-   static class PreInstalledControllerContext extends AbstractControllerContext
-   {
-      public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
-      {
-         super(name, actions, null, target);
-      }
-   }
-
-   static class LocationOnlyBundleInfo implements BundleInfo
-   {
-      private URL location;
-
-      public LocationOnlyBundleInfo(URL location)
-      {
-         this.location = location;
-      }
-
-      public URL getLocation()
-      {
-         return location;
-      }
-
-      public State getState()
-      {
-         throw new NotImplementedException();
-      }
-
-      public String getSymbolicName()
-      {
-         throw new NotImplementedException();
-      }
-
-      public String getVersion()
-      {
-         throw new NotImplementedException();
-      }
-   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh	2009-05-30 11:53:38 UTC (rev 89546)
@@ -134,8 +134,6 @@
 echo ""
 echo "  JAVA_OPTS: $JAVA_OPTS"
 echo ""
-echo "  CLASSPATH: $OSGI_CLASSPATH"
-echo ""
 echo "========================================================================="
 echo ""
 

Modified: projects/jboss-osgi/trunk/integration/jbossas/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/pom.xml	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/integration/jbossas/pom.xml	2009-05-30 11:53:38 UTC (rev 89546)
@@ -22,6 +22,14 @@
       <groupId>org.jboss.osgi</groupId>
       <artifactId>jboss-osgi-spi</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi.bundles</groupId>
+      <artifactId>jboss-osgi-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi.bundles</groupId>
+      <artifactId>jboss-osgi-microcontainer</artifactId>
+    </dependency>
     
     <!-- OSGi Dependencies -->
     <dependency>

Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/ManagementServiceBean.java (from rev 89533, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/ManagementServiceBean.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/ManagementServiceBean.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jbossas.integration;
+
+//$Id$
+
+import javax.management.MBeanServer;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to the MBeanServer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ManagementServiceBean 
+{
+   private MBeanServer mbeanServer;
+   private BundleContext context;
+   
+   public void setSystemContext(BundleContext context)
+   {
+      this.context = context;
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void start()
+   {
+      context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/MicrocontainerServiceBean.java (from rev 89533, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/MicrocontainerServiceBean.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/MicrocontainerServiceBean.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -0,0 +1,115 @@
+/*
+ * 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.jbossas.integration;
+
+//$Id$
+
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+
+import org.apache.log4j.Logger;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.osgi.common.service.DeployerService;
+import org.jboss.osgi.common.service.MicrocontainerService;
+import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.jboss.osgi.microcontainer.internal.AbstractMicrocontainerService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
+ * which is installed as MC bean in jbossas.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class MicrocontainerServiceBean extends AbstractMicrocontainerService implements MicrocontainerServiceMBean
+{
+   private static Logger log = Logger.getLogger(MicrocontainerServiceBean.class);
+
+   private BundleContext context;
+   private MBeanServer mbeanServer;
+   private Kernel kernel;
+
+   public void setSystemContext(BundleContext context)
+   {
+      this.context = context;
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void setKernel(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+
+   public Kernel getKernel()
+   {
+      return kernel;
+   }
+
+   @Override
+   public void logDebug(String message)
+   {
+      log.debug(message);
+   }
+
+   @Override
+   public void logWarning(String message, Exception ex)
+   {
+      log.warn(message, ex);
+   }
+
+   public void start()
+   {
+      Kernel kernel = getKernel();
+      KernelController controller = kernel.getController();
+
+      // Preregister some beans
+      installBean(controller, BEAN_SYSTEM_BUNDLE_CONTEXT, context);
+      installBean(controller, BEAN_KERNEL, kernel);
+      installBean(controller, BEAN_KERNEL_CONTROLLER, controller);
+      installBean(controller, BEAN_MBEAN_SERVER, mbeanServer);
+
+      // Register the MicrocontainerService
+      log.debug("Register MicrocontainerService");
+      context.registerService(MicrocontainerService.class.getName(), this, null);
+
+      // Register the DeployerService
+      Properties props = new Properties();
+      props.setProperty("provider", "microcontainer");
+      log.debug("Register DeployerService");
+      context.registerService(DeployerService.class.getName(), this, props);
+
+      // Register the MicrocontainerServiceMBean
+      registerMicrocontainerServiceMBean(mbeanServer);
+   }
+
+   void stop()
+   {
+      unregisterMicrocontainerServiceMBean(mbeanServer);
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/NamingServiceBean.java (from rev 89533, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/NamingServiceBean.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jbossas/integration/NamingServiceBean.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -0,0 +1,58 @@
+/*
+ * 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.jbossas.integration;
+
+//$Id$
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to JNDI
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class NamingServiceBean 
+{
+   private BundleContext context;
+   
+   public void setSystemContext(BundleContext context)
+   {
+      this.context = context;
+   }
+
+   public void start()
+   {
+      try
+      {
+         InitialContext initialContext = new InitialContext();
+         context.registerService(InitialContext.class.getName(), initialContext, null);
+      }
+      catch (NamingException ex)
+      {
+         throw new IllegalStateException("Cannot register InitialContext", ex);
+      }
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -1,84 +0,0 @@
-/*
- * 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.microcontainer;
-
-//$Id$
-
-import java.net.URL;
-import java.util.List;
-
-import org.jboss.kernel.Kernel;
-
-/**
- * A service the gives access to the Microcontainer.
- * 
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public interface MicrocontainerService
-{
-   /*
-    * The name under which the system bundle context is registered: 'jboss.osgi:service=BundleContext'
-    */
-   String BEAN_SYSTEM_BUNDLE_CONTEXT = "jboss.osgi:service=BundleContext";
-
-   /*
-    * The name under which the MBeanServer is registered: 'jboss.osgi:service=MBeanServer'
-    */
-   String BEAN_MBEAN_SERVER = "jboss.osgi:service=MBeanServer";
-
-   /*
-    * The name under which the KernelController is registered: 'jboss.kernel:service=KernelController'
-    */
-   String BEAN_KERNEL_CONTROLLER = "jboss.kernel:service=KernelController";
-   
-   /*
-    * The name under which the Kernel is registered: 'jboss.kernel:service=Kernel'
-    */
-   String BEAN_KERNEL = "jboss.kernel:service=Kernel";
-
-   /*
-    * * Get the Microcontainer Kernel
-    */
-   Kernel getKernel();
-
-   /*
-    * * Get the list of registered beans.
-    */
-   List<String> getRegisteredBeans();
-
-   /*
-    * * Get a registered bean from the Kernel.
-    * @return null if there is no bean registered under this name
-    */
-   Object getRegisteredBean(String beanName);
-
-   /*
-    * * Deploy MC beans from URL
-    */
-   void deploy(URL url) throws Exception;
-
-   /*
-    * * Undeploy MC beans from URL
-    */
-   void undeploy(URL url) throws Exception;
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java	2009-05-30 10:24:42 UTC (rev 89545)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java	2009-05-30 11:53:38 UTC (rev 89546)
@@ -1,60 +0,0 @@
-/*
- * 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.microcontainer;
-
-//$Id$
-
-import java.net.URL;
-import java.util.List;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-
-/**
- * An OSGi Service the gives access to the Kernel and MBeanServer.
- * 
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public interface MicrocontainerServiceMBean
-{
-   /** 
-    * The object name under which the MicrocontainerService is registered: 'jboss.osgi:service=MicrocontainerService' 
-    */
-   ObjectName MBEAN_MICROCONTAINER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=MicrocontainerService");
-
-   /**
-    * Get the list of registered beans.
-    */
-   List<String> getRegisteredBeans();
-
-   /** 
-    * Deploy MC beans from URL
-    */
-   void deploy(URL url) throws Exception;
-
-   /**
-    * Undeploy MC beans from URL
-    */
-   void undeploy(URL url) throws Exception;
-}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list