[jboss-cvs] JBossAS SVN: r87862 - in projects/jboss-osgi/trunk/bundle: blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 27 09:09:03 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-04-27 09:09:03 -0400 (Mon, 27 Apr 2009)
New Revision: 87862
Added:
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/MicrocontainerTestService.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/microcontainer/
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/microcontainer/microcontainer-test.bnd
projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/EmbeddedBeansDeployer.java
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/MicrocontainerTestCase.java
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/microcontainer/.classpath
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
Log:
Embedded MC Service - ok
Modified: projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml 2009-04-27 13:09:03 UTC (rev 87862)
@@ -46,6 +46,9 @@
<!-- jmx-test -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jmx-test.jar" files="${tests.resources.dir}/jmx/jmx-test.bnd" />
+ <!-- microcontainer-test -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/microcontainer-test.jar" files="${tests.resources.dir}/microcontainer/microcontainer-test.bnd" />
+
<!-- Please add alphabetically -->
</target>
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/MicrocontainerTestCase.java 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/MicrocontainerTestCase.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -36,7 +36,7 @@
*/
public class MicrocontainerTestCase extends BlueprintTest
{
- public void testMBeanAccess() throws Exception
+ public void testMCServiceAccess() throws Exception
{
OSGiFramework framework = getBootstrapProvider().getFramework();
@@ -46,6 +46,10 @@
Bundle bundle = installBundle(sysContext, "bundles/jboss-osgi-microcontainer.jar", true);
assertEquals("Microcontainer bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+
+ bundle = installBundle(sysContext, "microcontainer-test.jar", true);
+ assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+
}
finally
{
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/MicrocontainerTestService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/MicrocontainerTestService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/MicrocontainerTestService.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.microcontainer.bundle;
+
+//$Id$
+
+import org.jboss.osgi.microcontainer.MicrocontainerService;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A service that accesses the MicrocontainerService
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class MicrocontainerTestService
+{
+ public MicrocontainerTestService(BundleContext context)
+ {
+ ServiceTracker tracker = new ServiceTracker(context, MicrocontainerService.class.getName(), null);
+ tracker.open();
+
+ MicrocontainerService mcService = (MicrocontainerService)tracker.getService();
+ if (mcService == null)
+ throw new IllegalStateException("No MicrocontainerService");
+
+ Object sysContextBean = mcService.getRegisteredBean(MicrocontainerService.SERVICE_NAME_SYSTEM_BUNDLE_CONTEXT);
+ if (sysContextBean == null)
+ throw new IllegalStateException("No OSGi System Context as MC Bean");
+ }
+}
Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/MicrocontainerTestService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/ServiceActivator.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.microcontainer.bundle;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ MicrocontainerTestService service = new MicrocontainerTestService(context);
+ context.registerService(MicrocontainerTestService.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/microcontainer/bundle/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/microcontainer/microcontainer-test.bnd
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/microcontainer/microcontainer-test.bnd (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/microcontainer/microcontainer-test.bnd 2009-04-27 13:09:03 UTC (rev 87862)
@@ -0,0 +1,5 @@
+# bnd build -classpath target/test-classes -output target/test-libs/microcontainer-test.jar src/test/resources/microcontainer/microcontainer-test.bnd
+
+Bundle-SymbolicName: microcontainer-test
+Bundle-Activator: org.jboss.test.osgi.blueprint.microcontainer.bundle.ServiceActivator
+Export-Package: org.jboss.test.osgi.blueprint.microcontainer.bundle
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -50,6 +50,7 @@
public void start(BundleContext context)
{
log = new LogServiceTracker(context);
+
ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
if (sref == null)
{
Modified: projects/jboss-osgi/trunk/bundle/microcontainer/.classpath
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/.classpath 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/.classpath 2009-04-27 13:09:03 UTC (rev 87862)
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml 2009-04-27 13:09:03 UTC (rev 87862)
@@ -23,6 +23,11 @@
<version>${version}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-client-spi</artifactId>
</dependency>
@@ -69,8 +74,12 @@
com.sun.jdi*;resolution:=optional,
javassist*;resolution:=optional,
javax.activation;resolution:=optional,
- javax.naming;resolution:=optional,
- javax.xml.*;resolution:=optional,
+ javax.naming*;resolution:=optional,
+ javax.net*;resolution:=optional,
+ javax.management,
+ javax.xml.*;resolution:=optional,
+ org.apache.commons.httpclient;resolution:=optional,
+ org.apache.webdav.lib;resolution:=optional,
org.apache.xerces*,
org.apache.xml.resolver*;resolution:=optional,
org.jboss.annotation.*;resolution:=optional,
@@ -78,7 +87,7 @@
org.jboss.classadapter.spi;resolution:=optional,
org.jboss.classloader.*;resolution:=optional,
org.jboss.classloading.*;resolution:=optional,
- org.jboss.config.*;resolution:=optional,
+ org.jboss.config.*,
org.jboss.dependency.*;resolution:=optional,
org.jboss.deployers.*;resolution:=optional,
org.jboss.joinpoint.*;resolution:=optional,
@@ -86,21 +95,27 @@
org.jboss.managed.*;resolution:=optional,
org.jboss.metadata.*;resolution:=optional,
org.jboss.metatype.*;resolution:=optional,
+ org.jboss.osgi.common.log,
org.jboss.reflect.*;resolution:=optional,
org.jboss.test;resolution:=optional,
org.jboss.util*;resolution:=optional,
org.jboss.virtual*;resolution:=optional,
org.jboss.xb.*,
org.osgi.framework;version=1.4,
+ org.osgi.service.log,
org.w3c.dom*,
org.xml.sax*,
sun.io;resolution:=optional
</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>
+ jboss-common-core,
+ jboss-dependency,
jboss-deployers-client-spi,
jboss-deployers-vfs,
+ jboss-mdr,
jboss-kernel,
+ jboss-reflect,
jboss-vfs,
jbossxb,
xml-apis,
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-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerService.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -23,6 +23,8 @@
//$Id$
+import java.util.List;
+
import org.jboss.kernel.Kernel;
/**
@@ -33,13 +35,22 @@
*/
public interface MicrocontainerService
{
+ /** The bean name under which the system bundle context is registered */
+ String SERVICE_NAME_SYSTEM_BUNDLE_CONTEXT = "jboss.osgi:service=SystemBundleContext";
+
/**
* 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);
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/EmbeddedBeansDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/EmbeddedBeansDeployer.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/EmbeddedBeansDeployer.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -0,0 +1,97 @@
+/*
+ * 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 org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * Boostrap the Microcontainer
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 27-Jun-2008
+ */
+public class EmbeddedBeansDeployer extends BasicBootstrap
+{
+ private LogService log;
+ private BasicXMLDeployer deployer;
+
+ public EmbeddedBeansDeployer(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+
+ // Get or bootstrap the kernel
+ if (getKernel() == null)
+ {
+ try
+ {
+ super.bootstrap();
+ log.log(LogService.LOG_DEBUG, "bootstrap kernel: " + kernel);
+ }
+ catch (Throwable e)
+ {
+ throw new IllegalStateException("Cannot bootstrap kernel", e);
+ }
+ }
+ deployer = new BasicXMLDeployer(kernel);
+ }
+
+ /*
+ * * Deploy MC beans from URL
+ */
+ public void deploy(URL url)
+ {
+ log.log(LogService.LOG_DEBUG, "deploy: " + url);
+ try
+ {
+ deployer.deploy(url);
+ deployer.validate();
+ }
+ catch (Throwable e)
+ {
+ throw new IllegalStateException("Cannot deploy beans from: " + url, e);
+ }
+ }
+
+ /*
+ * * Undeploy MC beans from URL
+ */
+ public void undeploy(URL url)
+ {
+ log.log(LogService.LOG_DEBUG, "undeploy: " + url);
+ try
+ {
+ deployer.undeploy(url);
+ }
+ catch (Throwable e)
+ {
+ throw new IllegalStateException("Cannot undeploy beans from: " + url, e);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/EmbeddedBeansDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-04-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -23,7 +23,16 @@
//$Id$
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+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.ControllerState;
import org.jboss.kernel.Kernel;
import org.jboss.osgi.microcontainer.MicrocontainerService;
import org.osgi.framework.BundleContext;
@@ -36,12 +45,28 @@
*/
public class MicrocontainerServiceImpl implements MicrocontainerService
{
- private BundleContext context;
private Kernel kernel;
public MicrocontainerServiceImpl(BundleContext context)
{
- this.context = context;
+ EmbeddedBeansDeployer deployer = new EmbeddedBeansDeployer(context);
+ kernel = deployer.getKernel();
+
+ // Register the OSGi system context as an MC bean
+ try
+ {
+ AbstractControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+ ControllerContext ctrlContext = new AbstractControllerContext(SERVICE_NAME_SYSTEM_BUNDLE_CONTEXT, actions, null, context);
+ kernel.getController().install(ctrlContext);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Throwable ex)
+ {
+ throw new IllegalStateException("Cannot register: " + SERVICE_NAME_SYSTEM_BUNDLE_CONTEXT, ex);
+ }
}
public Kernel getKernel()
@@ -49,12 +74,20 @@
return kernel;
}
+ public List<String> getRegisteredBeans()
+ {
+ List<String> names = new ArrayList<String>();
+
+ AbstractController controller = (AbstractController)kernel.getController();
+ for (ControllerContext ctx : controller.getAllContexts())
+ names.add(ctx.getName().toString());
+
+ return names;
+ }
+
public Object getRegisteredBean(String beanName)
{
- if (kernel == null)
- throw new IllegalArgumentException("Kernel cannot be null");
-
ControllerContext context = kernel.getController().getInstalledContext(beanName);
- return context.getTarget();
+ return context != null ? context.getTarget() : null;
}
}
\ 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-27 12:02:58 UTC (rev 87861)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/ServiceActivator.java 2009-04-27 13:09:03 UTC (rev 87862)
@@ -23,10 +23,12 @@
//$Id$
+import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.microcontainer.MicrocontainerService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
/**
* A BundleActivator that registers the Microcontainer Service
@@ -37,17 +39,32 @@
public class ServiceActivator implements BundleActivator
{
private ServiceRegistration registration;
+ private LogService log;
public void start(BundleContext context)
{
- MicrocontainerServiceImpl mcService = new MicrocontainerServiceImpl(context);
- registration = context.registerService(MicrocontainerService.class.getName(), mcService, null);
+ log = new LogServiceTracker(context);
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ MicrocontainerServiceImpl mcService = new MicrocontainerServiceImpl(context);
+
+ log.log(LogService.LOG_DEBUG, "Register MicrocontainerService");
+ registration = context.registerService(MicrocontainerService.class.getName(), mcService, null);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
}
public void stop(BundleContext context)
{
if (registration != null)
{
+ log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
registration.unregister();
registration = null;
}
More information about the jboss-cvs-commits
mailing list