[jboss-osgi-commits] JBoss-OSGI SVN: r91497 - in projects/jboss-osgi: projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi and 6 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Tue Jul 21 12:15:45 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-07-21 12:15:43 -0400 (Tue, 21 Jul 2009)
New Revision: 91497
Added:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/SAXParserFactoryImpl.java
Removed:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache/
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/internal/LoggingXMLParserActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/dom/
Modified:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java
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/pom.xml
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
Log:
[JBOSGI-97] Provide SAX/DOM parser example
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 16:15:43 UTC (rev 91497)
@@ -89,7 +89,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.xml.internal.LoggingXMLParserActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.xml.XMLParserActivatorExt</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Private-Package>
org.jboss.osgi.xml.internal
Deleted: 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 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -1,34 +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.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
Deleted: 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 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -1,34 +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.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
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -28,7 +28,11 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParserFactory;
+import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.xml.internal.XMLParserActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
/**
* Activate the XML parser using {@link XMLParserActivatorExt}
@@ -44,6 +48,18 @@
*/
public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware";
+ private LogService log;
+
+ 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)
@@ -154,4 +170,45 @@
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
Copied: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/DocumentBuilderFactoryImpl.java (from rev 91496, 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/internal/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/DocumentBuilderFactoryImpl.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -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.osgi.xml.internal;
+
+//$Id: XercesParserActivator.java 91417 2009-07-20 09:25:44Z thomas.diesler at jboss.com $
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * 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
+{
+ @Override
+ public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ return super.newDocumentBuilder();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/LoggingXMLParserActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/LoggingXMLParserActivator.java 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/LoggingXMLParserActivator.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -1,95 +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.xml.internal;
-
-//$Id: XMLParserActivatorExt.java 91495 2009-07-21 13:54:45Z thomas.diesler at jboss.com $
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.xml.XMLParserActivatorExt;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * Activate the XML parser using {@link LoggingXMLParserActivator}
- *
- * @author thomas.diesler at jboss.com
- * @since 29-Apr-2009
- */
-public class LoggingXMLParserActivator extends XMLParserActivatorExt
-{
- private LogService log;
-
- public void start(BundleContext context) throws Exception
- {
- log = new LogServiceTracker(context);
-
- super.start(context);
-
- logSAXParserFactory(context);
- logDOMParserFactory(context);
- }
-
-
- 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
Copied: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/SAXParserFactoryImpl.java (from rev 91496, 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/internal/SAXParserFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/SAXParserFactoryImpl.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -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.osgi.xml.internal;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+//$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
+{
+ @Override
+ public SAXParser newSAXParser() throws ParserConfigurationException
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ return super.newSAXParser();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+}
\ 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 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory 2009-07-21 16:15:43 UTC (rev 91497)
@@ -1 +1 @@
-org.jboss.osgi.xml.DocumentBuilderFactoryImpl
\ No newline at end of file
+org.jboss.osgi.xml.internal.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 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory 2009-07-21 16:15:43 UTC (rev 91497)
@@ -1 +1 @@
-org.jboss.osgi.xml.SAXParserFactoryImpl
\ No newline at end of file
+org.jboss.osgi.xml.internal.SAXParserFactoryImpl
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 16:15:43 UTC (rev 91497)
@@ -102,8 +102,7 @@
org/jboss/osgi/jmx/*.class,
org/jboss/osgi/jndi/*.class,
org/jboss/osgi/microcontainer/*.class,
- org/jboss/osgi/microcontainer/integration/*.class,
- org/jboss/osgi/xml/internal/*.class,
+ org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.class,
org/jboss/osgi/xml/*.class
</includes>
</configuration>
Modified: projects/jboss-osgi/projects/runtime/jbossas/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 2009-07-21 14:48:51 UTC (rev 91496)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-07-21 16:15:43 UTC (rev 91497)
@@ -34,10 +34,8 @@
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;
/**
@@ -120,10 +118,6 @@
// Register the MicrocontainerServiceMBean
registerMicrocontainerServiceMBean(mbeanServer);
log.debug("MicrocontainerServiceMBean registered");
-
- // Register the DOM/SAX factories
- //XMLParserActivatorExt parserActivator = new XMLParserActivatorExt();
- //parserActivator.start(context);
}
void stop()
More information about the jboss-osgi-commits
mailing list