[jboss-osgi-commits] JBoss-OSGI SVN: r91495 - in projects/jboss-osgi/projects: bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache/xerces and 11 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Tue Jul 21 09:54:51 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-07-21 09:54:45 -0400 (Tue, 21 Jul 2009)
New Revision: 91495
Added:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
Removed:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache/xerces/internal/
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
Modified:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory
projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath
projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
Log:
[JBOSGI-92] XMLParserActivator in compendium cannot load SAXParserFactory - WIP
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 13:54:45 UTC (rev 91495)
@@ -89,7 +89,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.apache.xerces.internal.XercesParserActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.xml.XMLParserActivatorExt</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Private-Package>
org.jboss.osgi.apache.xerces.internal
@@ -108,7 +108,7 @@
<!-- import -->
org.jboss.osgi.common.log;version=1.0,
- org.jboss.osgi.spi.capability;version=1.0,
+ org.jboss.osgi.spi.capability;version=1.0,
org.osgi.framework,
org.osgi.service.log,
org.osgi.util.xml,
Added: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java 2009-07-21 13:54:45 UTC (rev 91495)
@@ -0,0 +1,34 @@
+/*
+ * 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.xml;
+
+//$Id: XercesParserActivator.java 91417 2009-07-20 09:25:44Z thomas.diesler at jboss.com $
+
+/**
+ * A DocumentBuilderFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2009
+ */
+public class DocumentBuilderFactoryImpl extends org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
+{
+}
\ No newline at end of file
Added: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java 2009-07-21 13:54:45 UTC (rev 91495)
@@ -0,0 +1,34 @@
+/*
+ * 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.xml;
+
+//$Id: XercesParserActivator.java 91417 2009-07-20 09:25:44Z thomas.diesler at jboss.com $
+
+/**
+ * A SAXParserFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2009
+ */
+public class SAXParserFactoryImpl extends org.apache.xerces.jaxp.SAXParserFactoryImpl
+{
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java (from rev 91485, projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache/xerces/internal/XercesParserActivator.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java 2009-07-21 13:54:45 UTC (rev 91495)
@@ -0,0 +1,213 @@
+/*
+ * 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.xml;
+
+//$Id$
+
+import java.util.Hashtable;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.xml.XMLParserActivator;
+
+/**
+ * Activate the XML parser using {@link XMLParserActivatorExt}
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 29-Apr-2009
+ */
+public class XMLParserActivatorExt extends XMLParserActivator
+{
+ private LogService log;
+
+ /*
+ * Service property specifying if factory is configured to support XInclude aware parsers.
+ * The value is of type <code>Boolean</code>.
+ */
+ public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware";
+
+ public void start(BundleContext context) throws Exception
+ {
+ log = new LogServiceTracker(context);
+ super.start(context);
+ logSAXParserFactory(context);
+ logDOMParserFactory(context);
+ }
+
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void setDOMProperties(DocumentBuilderFactory factory, Hashtable props)
+ {
+ // check if this parser can be configured to validate
+ boolean validating = true;
+ factory.setValidating(true);
+ factory.setNamespaceAware(false);
+ try
+ {
+ factory.newDocumentBuilder();
+ }
+ catch (Exception pce_val)
+ {
+ validating = false;
+ }
+
+ // check if this parser can be configured to be namespaceaware
+ boolean namespaceaware = true;
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ try
+ {
+ factory.newDocumentBuilder();
+ }
+ catch (Exception pce_nsa)
+ {
+ namespaceaware = false;
+ }
+
+ // check if this parser can be configured to be xinclude aware
+ boolean xinclude = true;
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ factory.setXIncludeAware(true);
+ try
+ {
+ factory.newDocumentBuilder();
+ }
+ catch (Exception pce_inc)
+ {
+ xinclude = false;
+ }
+
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ factory.setXIncludeAware(xinclude);
+
+ // set the OSGi service properties
+ props.put(PARSER_VALIDATING, new Boolean(validating));
+ props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ props.put(PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+ }
+
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void setSAXProperties(SAXParserFactory factory, Hashtable props)
+ {
+ // check if this parser can be configured to validate
+ boolean validating = true;
+ factory.setValidating(true);
+ factory.setNamespaceAware(false);
+ try
+ {
+ factory.newSAXParser();
+ }
+ catch (Exception pce_val)
+ {
+ validating = false;
+ }
+
+ // check if this parser can be configured to be namespaceaware
+ boolean namespaceaware = true;
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ try
+ {
+ factory.newSAXParser();
+ }
+ catch (Exception pce_nsa)
+ {
+ namespaceaware = false;
+ }
+
+ // check if this parser can be configured to be xinclude aware
+ boolean xinclude = true;
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ factory.setXIncludeAware(true);
+ try
+ {
+ factory.newSAXParser();
+ }
+ catch (Exception pce_inc)
+ {
+ xinclude = false;
+ }
+
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ factory.setXIncludeAware(xinclude);
+
+ // set the OSGi service properties
+ props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ props.put(PARSER_VALIDATING, new Boolean(validating));
+ props.put(PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+ }
+
+
+ private void logSAXParserFactory(BundleContext context)
+ {
+ ServiceReference saxRef = context.getServiceReference(SAXParserFactory.class.getName());
+ if (saxRef != null)
+ {
+ Object factory = context.getService(saxRef);
+ log.log(LogService.LOG_DEBUG, "SAXParserFactory: " + factory.getClass().getName());
+
+ for (String key : saxRef.getPropertyKeys())
+ {
+ Object value = saxRef.getProperty(key);
+ log.log(LogService.LOG_DEBUG, " " + key + "=" + value);
+ }
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "No SAXParserFactory registered");
+ }
+ }
+
+ private void logDOMParserFactory(BundleContext context)
+ {
+ ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
+ if (domRef != null)
+ {
+ Object factory = context.getService(domRef);
+ log.log(LogService.LOG_DEBUG, "DocumentBuilderFactory: " + factory.getClass().getName());
+
+ for (String key : domRef.getPropertyKeys())
+ {
+ Object value = domRef.getProperty(key);
+ log.log(LogService.LOG_DEBUG, " " + key + "=" + value);
+ }
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory 2009-07-21 13:54:45 UTC (rev 91495)
@@ -1 +1 @@
-org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
\ No newline at end of file
+org.jboss.osgi.xml.DocumentBuilderFactoryImpl
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory 2009-07-21 13:54:45 UTC (rev 91495)
@@ -1 +1 @@
-org.apache.xerces.jaxp.SAXParserFactoryImpl
\ No newline at end of file
+org.jboss.osgi.xml.SAXParserFactoryImpl
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-07-21 13:54:45 UTC (rev 91495)
@@ -1,139 +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.integration;
-
-//$Id$
-
-import java.util.Properties;
-
-import javax.management.MBeanServer;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.microcontainer.MicrocontainerService;
-import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.service.DeployerService;
-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();
-
- // Register the MBeanServer
- context.registerService(MBeanServer.class.getName(), mbeanServer, null);
- log.debug("MBeanServer registered");
-
- // Register the InitialContext service
- registerInitialContext();
- log.debug("InitialContext registered");
-
- // 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);
- log.debug("MicrocontainerService registered");
-
- // Register the DeployerService
- Properties props = new Properties();
- props.setProperty("provider", "microcontainer");
- context.registerService(DeployerService.class.getName(), this, props);
- log.debug("DeployerService registered");
-
- // Register the MicrocontainerServiceMBean
- registerMicrocontainerServiceMBean(mbeanServer);
- log.debug("MicrocontainerServiceMBean registered");
- }
-
- void stop()
- {
- unregisterMicrocontainerServiceMBean(mbeanServer);
- }
-
- public void registerInitialContext()
- {
- 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
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath 2009-07-21 13:54:45 UTC (rev 91495)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" path="src/main/java"/>
<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/projects/runtime/jbossas/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 10:05:53 UTC (rev 91494)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 13:54:45 UTC (rev 91495)
@@ -31,6 +31,7 @@
<properties>
<version.jboss.osgi.microcontainer>1.0.0-SNAPSHOT</version.jboss.osgi.microcontainer>
+ <version.osgi>r4v41</version.osgi>
</properties>
<!-- Dependencies -->
@@ -40,6 +41,18 @@
<artifactId>jboss-osgi-microcontainer</artifactId>
<version>${version.jboss.osgi.microcontainer}</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${version.osgi}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${version.osgi}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<!-- Build -->
Copied: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java (from rev 91485, projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-07-21 13:54:45 UTC (rev 91495)
@@ -0,0 +1,146 @@
+/*
+ * 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.integration;
+
+
+//$Id$
+
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.microcontainer.MicrocontainerService;
+import org.jboss.osgi.microcontainer.integration.AbstractMicrocontainerService;
+import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
+import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.xml.XMLParserActivatorExt;
+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() throws Exception
+ {
+ Kernel kernel = getKernel();
+ KernelController controller = kernel.getController();
+
+ // Register the MBeanServer
+ context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+ log.debug("MBeanServer registered");
+
+ // Register the InitialContext service
+ registerInitialContext();
+ log.debug("InitialContext registered");
+
+ // 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);
+ log.debug("MicrocontainerService registered");
+
+ // Register the DeployerService
+ Properties props = new Properties();
+ props.setProperty("provider", "microcontainer");
+ context.registerService(DeployerService.class.getName(), this, props);
+ log.debug("DeployerService registered");
+
+ // Register the MicrocontainerServiceMBean
+ registerMicrocontainerServiceMBean(mbeanServer);
+ log.debug("MicrocontainerServiceMBean registered");
+
+ // Register the DOM/SAX factories
+ XMLParserActivatorExt parserActivator = new XMLParserActivatorExt();
+ parserActivator.start(context);
+ }
+
+ void stop()
+ {
+ unregisterMicrocontainerServiceMBean(mbeanServer);
+ }
+
+ public void registerInitialContext()
+ {
+ 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
More information about the jboss-osgi-commits
mailing list