JBoss-OSGI SVN: r91540 - in projects/jboss-osgi: projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml and 8 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-22 04:12:03 -0400 (Wed, 22 Jul 2009)
New Revision: 91540
Added:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java
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/jboss-xml-binding/trunk/src/main/java/org/jboss/osgi/jbossxb/internal/XMLBindingActivator.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/distribution/installer/scripts/assembly-deploy-artifacts.xml
projects/jboss-osgi/trunk/reactor/
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/reactor/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
Log:
[JBOSGI-92] Class.forName issue with XMLParserActivator
Use apache felix compendium. @Ignore the test.
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-22 08:12:03 UTC (rev 91540)
@@ -91,6 +91,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.xml.XMLParserActivatorExt</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+ <Privat-Package>
+ org.jboss.osgi.xml.internal
+ </Privat-Package>
<Export-Package>
org.jboss.osgi.xml;version=${version}
</Export-Package>
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-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java 2009-07-22 08:12:03 UTC (rev 91540)
@@ -29,10 +29,10 @@
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;
-import org.osgi.util.xml.XMLParserActivator;
/**
* Activate the XML parser using {@link XMLParserActivatorExt}
Added: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java 2009-07-22 08:12:03 UTC (rev 91540)
@@ -0,0 +1,535 @@
+/*
+ * $Header: /cvshome/build/org.osgi.util.xml/src/org/osgi/util/xml/XMLParserActivator.java,v 1.11 2006/10/27 18:17:06 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2002, 2006). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.osgi.xml.internal;
+
+import java.io.*;
+import java.net.URL;
+import java.util.*;
+
+import javax.xml.parsers.*;
+
+import org.osgi.framework.*;
+
+/**
+ * This is a copy of the original XMLParserActivator, because we cannot use the one
+ * from the Apache Felix org.osgi.compendium-1.2.0.jar
+ *
+ * [JBOSGI-92] Class.forName issue with XMLParserActivator
+ * https://jira.jboss.org/jira/browse/JBOSGI-92
+ */
+
+/**
+ * A BundleActivator class that allows any JAXP compliant XML Parser to register
+ * itself as an OSGi parser service.
+ *
+ * Multiple JAXP compliant parsers can concurrently register by using this
+ * BundleActivator class. Bundles who wish to use an XML parser can then use the
+ * framework's service registry to locate available XML Parsers with the desired
+ * characteristics such as validating and namespace-aware.
+ *
+ * <p>
+ * The services that this bundle activator enables a bundle to provide are:
+ * <ul>
+ * <li><code>javax.xml.parsers.SAXParserFactory</code>({@link #SAXFACTORYNAME})
+ * <li><code>javax.xml.parsers.DocumentBuilderFactory</code>(
+ * {@link #DOMFACTORYNAME})
+ * </ul>
+ *
+ * <p>
+ * The algorithm to find the implementations of the abstract parsers is derived
+ * from the JAR file specifications, specifically the Services API.
+ * <p>
+ * An XMLParserActivator assumes that it can find the class file names of the
+ * factory classes in the following files:
+ * <ul>
+ * <li><code>/META-INF/services/javax.xml.parsers.SAXParserFactory</code> is
+ * a file contained in a jar available to the runtime which contains the
+ * implementation class name(s) of the SAXParserFactory.
+ * <li><code>/META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
+ * is a file contained in a jar available to the runtime which contains the
+ * implementation class name(s) of the <code>DocumentBuilderFactory</code>
+ * </ul>
+ * <p>
+ * If either of the files does not exist, <code>XMLParserActivator</code>
+ * assumes that the parser does not support that parser type.
+ *
+ * <p>
+ * <code>XMLParserActivator</code> attempts to instantiate both the
+ * <code>SAXParserFactory</code> and the <code>DocumentBuilderFactory</code>.
+ * It registers each factory with the framework along with service properties:
+ * <ul>
+ * <li>{@link #PARSER_VALIDATING}- indicates if this factory supports
+ * validating parsers. It's value is a <code>Boolean</code>.
+ * <li>{@link #PARSER_NAMESPACEAWARE}- indicates if this factory supports
+ * namespace aware parsers It's value is a <code>Boolean</code>.
+ * </ul>
+ * <p>
+ * Individual parser implementations may have additional features, properties,
+ * or attributes which could be used to select a parser with a filter. These can
+ * be added by extending this class and overriding the
+ * <code>setSAXProperties</code> and <code>setDOMProperties</code> methods.
+ */
+public class XMLParserActivator implements BundleActivator, ServiceFactory {
+ /** Context of this bundle */
+ private BundleContext context;
+ /**
+ * Filename containing the SAX Parser Factory Class name. Also used as the
+ * basis for the <code>SERVICE_PID<code> registration property.
+ */
+ public static final String SAXFACTORYNAME = "javax.xml.parsers.SAXParserFactory";
+ /**
+ * Filename containing the DOM Parser Factory Class name. Also used as the
+ * basis for the <code>SERVICE_PID</code> registration property.
+ */
+ public static final String DOMFACTORYNAME = "javax.xml.parsers.DocumentBuilderFactory";
+ /** Path to the factory class name files */
+ private static final String PARSERCLASSFILEPATH = "/META-INF/services/";
+ /** Fully qualified path name of SAX Parser Factory Class Name file */
+ public static final String SAXCLASSFILE = PARSERCLASSFILEPATH
+ + SAXFACTORYNAME;
+ /** Fully qualified path name of DOM Parser Factory Class Name file */
+ public static final String DOMCLASSFILE = PARSERCLASSFILEPATH
+ + DOMFACTORYNAME;
+ /** SAX Factory Service Description */
+ private static final String SAXFACTORYDESCRIPTION = "A JAXP Compliant SAX Parser";
+ /** DOM Factory Service Description */
+ private static final String DOMFACTORYDESCRIPTION = "A JAXP Compliant DOM Parser";
+ /**
+ * Service property specifying if factory is configured to support
+ * validating parsers. The value is of type <code>Boolean</code>.
+ */
+ public static final String PARSER_VALIDATING = "parser.validating";
+ /**
+ * Service property specifying if factory is configured to support namespace
+ * aware parsers. The value is of type <code>Boolean</code>.
+ */
+ public static final String PARSER_NAMESPACEAWARE = "parser.namespaceAware";
+ /**
+ * Key for parser factory name property - this must be saved in the parsers
+ * properties hashtable so that the parser factory can be instantiated from
+ * a ServiceReference
+ */
+ private static final String FACTORYNAMEKEY = "parser.factoryname";
+
+ /**
+ * Called when this bundle is started so the Framework can perform the
+ * bundle-specific activities necessary to start this bundle. This method
+ * can be used to register services or to allocate any resources that this
+ * bundle needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * <p>
+ * This method attempts to register a SAX and DOM parser with the
+ * Framework's service registry.
+ *
+ * @param context The execution context of the bundle being started.
+ * @throws java.lang.Exception If this method throws an exception, this
+ * bundle is marked as stopped and the Framework will remove this
+ * bundle's listeners, unregister all services registered by this
+ * bundle, and release all services used by this bundle.
+ */
+ public void start(BundleContext context) throws Exception {
+ this.context = context;
+ Bundle parserBundle = context.getBundle();
+ try {
+ // check for sax parsers
+ registerSAXParsers(getParserFactoryClassNames(parserBundle
+ .getResource(SAXCLASSFILE)));
+ // check for dom parsers
+ registerDOMParsers(getParserFactoryClassNames(parserBundle
+ .getResource(DOMCLASSFILE)));
+ }
+ catch (IOException ioe) {
+ // if there were any IO errors accessing the resource files
+ // containing the class names
+ ioe.printStackTrace();
+ throw new FactoryConfigurationError(ioe);
+ }
+ }
+
+ /**
+ * This method has nothing to do as all active service registrations will
+ * automatically get unregistered when the bundle stops.
+ *
+ * @param context The execution context of the bundle being stopped.
+ * @throws java.lang.Exception If this method throws an exception, the
+ * bundle is still marked as stopped, and the Framework will remove
+ * the bundle's listeners, unregister all services registered by the
+ * bundle, and release all services used by the bundle.
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+ /**
+ * Given the URL for a file, reads and returns the parser class names. There
+ * may be multiple classes specified in this file, one per line. There may
+ * also be comment lines in the file, which begin with "#".
+ *
+ * @param parserUrl The URL of the service file containing the parser class
+ * names
+ * @return A vector of strings containing the parser class names or null if
+ * parserUrl is null
+ * @throws IOException if there is a problem reading the URL input stream
+ */
+ private Vector getParserFactoryClassNames(URL parserUrl) throws IOException {
+ Vector v = new Vector(1);
+ if (parserUrl != null) {
+ String parserFactoryClassName = null;
+ InputStream is = parserUrl.openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ while (true) {
+ parserFactoryClassName = br.readLine();
+ if (parserFactoryClassName == null) {
+ break; // end of file reached
+ }
+ String pfcName = parserFactoryClassName.trim();
+ if (pfcName.length() == 0) {
+ continue; // blank line
+ }
+ int commentIdx = pfcName.indexOf("#");
+ if (commentIdx == 0) { // comment line
+ continue;
+ }
+ else
+ if (commentIdx < 0) { // no comment on this line
+ v.addElement(pfcName);
+ }
+ else {
+ v.addElement(pfcName.substring(0, commentIdx).trim());
+ }
+ }
+ return v;
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Register SAX Parser Factory Services with the framework.
+ *
+ * @param parserFactoryClassNames - a <code>Vector</code> of
+ * <code>String</code> objects containing the names of the parser
+ * Factory Classes
+ * @throws FactoryConfigurationError if thrown from <code>getFactory</code>
+ */
+ private void registerSAXParsers(Vector parserFactoryClassNames)
+ throws FactoryConfigurationError {
+ if (parserFactoryClassNames != null) {
+ Enumeration e = parserFactoryClassNames.elements();
+ int index = 0;
+ while (e.hasMoreElements()) {
+ String parserFactoryClassName = (String) e.nextElement();
+ // create a sax parser factory just to get it's default
+ // properties. It will never be used since
+ // this class will operate as a service factory and give each
+ // service requestor it's own SaxParserFactory
+ SAXParserFactory factory = (SAXParserFactory) getFactory(parserFactoryClassName);
+ Hashtable properties = new Hashtable(7);
+ // figure out the default properties of the parser
+ setDefaultSAXProperties(factory, properties, index);
+ // store the parser factory class name in the properties so that
+ // it can be retrieved when getService is called
+ // to return a parser factory
+ properties.put(FACTORYNAMEKEY, parserFactoryClassName);
+ // release the factory
+ factory = null;
+ // register the factory as a service
+ context.registerService(SAXFACTORYNAME, this, properties);
+ index++;
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Set the SAX Parser Service Properties. By default, the following
+ * properties are set:
+ * <ul>
+ * <li><code>SERVICE_DESCRIPTION</code>
+ * <li><code>SERVICE_PID</code>
+ * <li><code>PARSER_VALIDATING</code>- instantiates a parser and queries
+ * it to find out whether it is validating or not
+ * <li><code>PARSER_NAMESPACEAWARE</code>- instantiates a parser and
+ * queries it to find out whether it is namespace aware or not
+ * <ul>
+ *
+ * @param factory The <code>SAXParserFactory</code> object
+ * @param props <code>Hashtable</code> of service properties.
+ */
+ private void setDefaultSAXProperties(SAXParserFactory factory,
+ Hashtable props, int index) {
+ props.put(Constants.SERVICE_DESCRIPTION, SAXFACTORYDESCRIPTION);
+ props.put(Constants.SERVICE_PID, SAXFACTORYNAME + "."
+ + context.getBundle().getBundleId() + "." + index);
+ setSAXProperties(factory, props);
+ }
+
+ /**
+ * <p>
+ * Set the customizable SAX Parser Service Properties.
+ *
+ * <p>
+ * This method attempts to instantiate a validating parser and a
+ * namespaceaware parser to determine if the parser can support those
+ * features. The appropriate properties are then set in the specified
+ * properties object.
+ *
+ * <p>
+ * This method can be overridden to add additional SAX2 features and
+ * properties. If you want to be able to filter searches of the OSGi service
+ * registry, this method must put a key, value pair into the properties
+ * object for each feature or property. For example,
+ *
+ * properties.put("http://www.acme.com/features/foo", Boolean.TRUE);
+ *
+ * @param factory - the SAXParserFactory object
+ * @param properties - the properties object for the service
+ */
+ public void setSAXProperties(SAXParserFactory factory, Hashtable properties) {
+ // 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;
+ }
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ // set the OSGi service properties
+ properties.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ properties.put(PARSER_VALIDATING, new Boolean(validating));
+ }
+
+ /**
+ * Register DOM Parser Factory Services with the framework.
+ *
+ * @param parserFactoryClassNames - a <code>Vector</code> of
+ * <code>String</code> objects containing the names of the parser
+ * Factory Classes
+ * @throws FactoryConfigurationError if thrown from <code>getFactory</code>
+ */
+ private void registerDOMParsers(Vector parserFactoryClassNames)
+ throws FactoryConfigurationError {
+ if (parserFactoryClassNames != null) {
+ Enumeration e = parserFactoryClassNames.elements();
+ int index = 0;
+ while (e.hasMoreElements()) {
+ String parserFactoryClassName = (String) e.nextElement();
+ // create a dom parser factory just to get it's default
+ // properties. It will never be used since
+ // this class will operate as a service factory and give each
+ // service requestor it's own DocumentBuilderFactory
+ DocumentBuilderFactory factory = (DocumentBuilderFactory) getFactory(parserFactoryClassName);
+ Hashtable properties = new Hashtable(7);
+ // figure out the default properties of the parser
+ setDefaultDOMProperties(factory, properties, index);
+ // store the parser factory class name in the properties so that
+ // it can be retrieved when getService is called
+ // to return a parser factory
+ properties.put(FACTORYNAMEKEY, parserFactoryClassName);
+ // release the factory
+ factory = null;
+ // register the factory as a service
+ context.registerService(DOMFACTORYNAME, this, properties);
+ index++;
+ }
+ }
+ }
+
+ /**
+ * Set the DOM parser service properties.
+ *
+ * By default, the following properties are set:
+ * <ul>
+ * <li><code>SERVICE_DESCRIPTION</code>
+ * <li><code>SERVICE_PID</code>
+ * <li><code>PARSER_VALIDATING</code>
+ * <li><code>PARSER_NAMESPACEAWARE</code>
+ * <ul>
+ *
+ * @param factory The <code>DocumentBuilderFactory</code> object
+ * @param props <code>Hashtable</code> of service properties.
+ */
+ private void setDefaultDOMProperties(DocumentBuilderFactory factory,
+ Hashtable props, int index) {
+ props.put(Constants.SERVICE_DESCRIPTION, DOMFACTORYDESCRIPTION);
+ props.put(Constants.SERVICE_PID, DOMFACTORYNAME + "."
+ + context.getBundle().getBundleId() + "." + index);
+ setDOMProperties(factory, props);
+ }
+
+ /**
+ * <p>
+ * Set the customizable DOM Parser Service Properties.
+ *
+ * <p>
+ * This method attempts to instantiate a validating parser and a
+ * namespaceaware parser to determine if the parser can support those
+ * features. The appropriate properties are then set in the specified props
+ * object.
+ *
+ * <p>
+ * This method can be overridden to add additional DOM2 features and
+ * properties. If you want to be able to filter searches of the OSGi service
+ * registry, this method must put a key, value pair into the properties
+ * object for each feature or property. For example,
+ *
+ * properties.put("http://www.acme.com/features/foo", Boolean.TRUE);
+ *
+ * @param factory - the DocumentBuilderFactory object
+ * @param props - Hashtable of service properties.
+ */
+ 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;
+ }
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ // set the OSGi service properties
+ props.put(PARSER_VALIDATING, new Boolean(validating));
+ props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ }
+
+ /**
+ * Given a parser factory class name, instantiate that class.
+ *
+ * @param parserFactoryClassName A <code>String</code> object containing
+ * the name of the parser factory class
+ * @return a parserFactoryClass Object
+ * @pre parserFactoryClassName!=null
+ */
+ private Object getFactory(String parserFactoryClassName)
+ throws FactoryConfigurationError {
+ Exception e = null;
+ try {
+ return Class.forName(parserFactoryClassName).newInstance();
+ }
+ catch (ClassNotFoundException cnfe) {
+ e = cnfe;
+ }
+ catch (InstantiationException ie) {
+ e = ie;
+ }
+ catch (IllegalAccessException iae) {
+ e = iae;
+ }
+ throw new FactoryConfigurationError(e);
+ }
+
+ /**
+ * Creates a new XML Parser Factory object.
+ *
+ * <p>
+ * A unique XML Parser Factory object is returned for each call to this
+ * method.
+ *
+ * <p>
+ * The returned XML Parser Factory object will be configured for validating
+ * and namespace aware support as specified in the service properties of the
+ * specified ServiceRegistration object.
+ *
+ * This method can be overridden to configure additional features in the
+ * returned XML Parser Factory object.
+ *
+ * @param bundle The bundle using the service.
+ * @param registration The <code>ServiceRegistration</code> object for the
+ * service.
+ * @return A new, configured XML Parser Factory object or null if a
+ * configuration error was encountered
+ */
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ ServiceReference sref = registration.getReference();
+ String parserFactoryClassName = (String) sref
+ .getProperty(FACTORYNAMEKEY);
+ try {
+ // need to set factory properties
+ Object factory = getFactory(parserFactoryClassName);
+ if (factory instanceof SAXParserFactory) {
+ ((SAXParserFactory) factory).setValidating(((Boolean) sref
+ .getProperty(PARSER_VALIDATING)).booleanValue());
+ ((SAXParserFactory) factory).setNamespaceAware(((Boolean) sref
+ .getProperty(PARSER_NAMESPACEAWARE)).booleanValue());
+ }
+ else
+ if (factory instanceof DocumentBuilderFactory) {
+ ((DocumentBuilderFactory) factory)
+ .setValidating(((Boolean) sref
+ .getProperty(PARSER_VALIDATING))
+ .booleanValue());
+ ((DocumentBuilderFactory) factory)
+ .setNamespaceAware(((Boolean) sref
+ .getProperty(PARSER_NAMESPACEAWARE))
+ .booleanValue());
+ }
+ return factory;
+ }
+ catch (FactoryConfigurationError fce) {
+ fce.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Releases a XML Parser Factory object.
+ *
+ * @param bundle The bundle releasing the service.
+ * @param registration The <code>ServiceRegistration</code> object for the
+ * service.
+ * @param service The XML Parser Factory object returned by a previous call
+ * to the <code>getService</code> method.
+ */
+ public void ungetService(Bundle bundle, ServiceRegistration registration,
+ Object service) {
+ }
+}
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/main/java/org/jboss/osgi/jbossxb/internal/XMLBindingActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/main/java/org/jboss/osgi/jbossxb/internal/XMLBindingActivator.java 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/src/main/java/org/jboss/osgi/jbossxb/internal/XMLBindingActivator.java 2009-07-22 08:12:03 UTC (rev 91540)
@@ -44,44 +44,46 @@
public class XMLBindingActivator implements BundleActivator
{
private LogService log;
-
+
public void start(BundleContext context) throws Exception
{
log = new LogServiceTracker(context);
-
+
ServiceTracker saxTracker = new ServiceTracker(context, SAXParserFactory.class.getName(), null)
{
@Override
public Object addingService(ServiceReference reference)
{
SAXParserFactory saxFactory = (SAXParserFactory)super.addingService(reference);
- log.log(LogService.LOG_DEBUG, "JBossXB SAXParserFactory: " + saxFactory);
-
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
+ if (context.getServiceReference(XMLBindingService.class.getName()) == null)
{
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ log.log(LogService.LOG_DEBUG, "JBossXB SAXParserFactory: " + saxFactory);
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
- // SaxJBossXBParser initializes the SAXParserFactory in a static block
- // using SAXParserFactory.newInstance(), which internally uses the TCCL
- new SaxJBossXBParser();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ try
+ {
+ // SaxJBossXBParser initializes the SAXParserFactory in a static block
+ // using SAXParserFactory.newInstance(), which internally uses the TCCL
+ new SaxJBossXBParser();
+ }
+ catch (JBossXBException ex)
+ {
+ throw new IllegalStateException("Cannot initialize SaxJBossXBParser", ex);
+ }
+
+ // Register the XMLBindingService
+ XMLBindingService service = new XMLBindingService(){};
+ context.registerService(XMLBindingService.class.getName(), service, null);
+ log.log(LogService.LOG_INFO, "XMLBindingService registered");
}
- catch (JBossXBException ex)
+ finally
{
- throw new IllegalStateException("Cannot initialize SaxJBossXBParser", ex);
+ Thread.currentThread().setContextClassLoader(ctxLoader);
}
-
- // Register the XMLBindingService
- XMLBindingService service = new XMLBindingService(){};
- context.registerService(XMLBindingService.class.getName(), service, null);
- log.log(LogService.LOG_INFO, "XMLBindingService registered");
}
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
-
return saxFactory;
}
};
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-07-22 08:12:03 UTC (rev 91540)
@@ -28,6 +28,7 @@
import java.util.Properties;
import java.util.Set;
+import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.naming.InitialContext;
@@ -88,6 +89,14 @@
{
throw rte;
}
+ catch (MBeanException ex)
+ {
+ Exception target = ex.getTargetException();
+ if (target instanceof BundleException)
+ throw (BundleException)target;
+
+ throw new BundleException("Cannot install: " + location, target);
+ }
catch (Exception ex)
{
throw new BundleException("Cannot install: " + location, ex);
Modified: projects/jboss-osgi/trunk/distribution/installer/scripts/assembly-deploy-artifacts.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/scripts/assembly-deploy-artifacts.xml 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/trunk/distribution/installer/scripts/assembly-deploy-artifacts.xml 2009-07-22 08:12:03 UTC (rev 91540)
@@ -24,6 +24,10 @@
<outputDirectory>lib</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
+ <excludes>
+ <!-- [JBOSGI-92] Class.forName issue with XMLParserActivator -->
+ <exclude>org.osgi:org.osgi.compendium:jar</exclude>
+ </excludes>
<scope>compile</scope>
<unpack>false</unpack>
</dependencySet>
Property changes on: projects/jboss-osgi/trunk/reactor
___________________________________________________________________
Name: svn:externals
- #spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
+ spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-07-22 08:12:03 UTC (rev 91540)
@@ -74,10 +74,12 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml 2009-07-22 08:12:03 UTC (rev 91540)
@@ -25,7 +25,7 @@
<include>*:jboss-osgi-microcontainer:jar</include>
<include>*:jboss-osgi-xml-binding:jar</include>
<include>*:org.apache.felix.log:jar</include>
- <include>*:org.osgi.compendium:jar</include>
+ <include>org.apache.felix:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
Modified: projects/jboss-osgi/trunk/reactor/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-22 08:12:03 UTC (rev 91540)
@@ -27,7 +27,10 @@
</parent>
<modules>
+ <module>spi</module>
<module>bundles/apache-xerces</module>
+ <module>bundles/jboss-xml-binding</module>
+ <module>bundles/microcontainer</module>
<module>blueprint</module>
</modules>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-07-22 06:02:38 UTC (rev 91539)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-07-22 08:12:03 UTC (rev 91540)
@@ -34,6 +34,7 @@
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -64,6 +65,7 @@
}
@Test
+ @Ignore("Fails with apache felix compendium-1.2.0")
public void testDeployParsers() throws Exception
{
OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
14 years, 10 months
JBoss-OSGI SVN: r91513 - in projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi: jbosgi108 and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 15:48:28 -0400 (Tue, 21 Jul 2009)
New Revision: 91513
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
Removed:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
Log:
[JBOSGI-92] Class.forName issue with XMLParserActivator
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108
___________________________________________________________________
Name: svn:mergeinfo
-
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,176 @@
+/*
+ * 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.jbosgi108;
+
+//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.osgi.jmx.JMXCapability;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.jbosgi108.bundleA.SomeBeanMBean;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-108] Investigate statics on PackageAdmin.refresh
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-108
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Jun-2009
+ */
+public class OSGI108TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime.addCapability(new JMXCapability());
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Before
+ public void setUp()
+ {
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(null);
+ }
+
+ @Test
+ public void testRedeploySingle() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+
+ bundleA.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleA.uninstall();
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be recreated
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleA.uninstall();
+ }
+
+ @Test
+ public void testRedeployWithReference() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
+
+ bundleA.start();
+ bundleB.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 2, messages.size());
+
+ bundleA.uninstall();
+
+ // After uninstall bundleA, bundleB still holds a reference on
+ // bundleA.SomeBean
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be reused
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 4, messages.size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
+ }
+
+ @Test
+ public void testRedeployWithReferenceAndRefresh() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
+
+ bundleA.start();
+ bundleB.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 2, messages.size());
+
+ bundleA.uninstall();
+
+ // After uninstall bundleA, bundleB still holds a reference on
+ // bundleA.SomeBean
+
+ // Refresh all packages
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(null);
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be recreated
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
+ }
+
+ private List<String> report(List<String> messages)
+ {
+ // System.out.println(">>>>>>>>>>>>");
+ // for (String aux : messages)
+ // System.out.println(aux);
+ // System.out.println("<<<<<<<<<<<");
+
+ return messages;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,81 +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.test.osgi.jbosgi92;
-
-//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-
-import static org.junit.Assert.assertEquals;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiServiceReference;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * [JBOSGI-92] Class.forName issue with XMLParserActivator
- *
- * https://jira.jboss.org/jira/browse/JBOSGI-92
- *
- * @author thomas.diesler(a)jboss.com
- * @since 21-Jul-2009
- */
-public class OSGI92TestCase
-{
- private static OSGiRuntime runtime;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- runtime = new OSGiTestHelper().getDefaultRuntime();
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (runtime != null)
- runtime.shutdown();
- }
-
- @Test
- public void testDeployParsers() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
- bundleA.start();
-
- assertEquals(Bundle.ACTIVE, bundleA.getState());
-
- String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
- OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
- assertEquals("DocumentBuilderFactory servce available", 1, domRefs.length);
-
- OSGiServiceReference[] saxRefs = runtime.getServiceReferences(SAXParserFactory.class.getName(), filter);
- assertEquals("SAXParserFactory servce available", 1, saxRefs.length);
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -19,70 +19,57 @@
* 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.jbosgi92.bundleA;
+package org.jboss.test.osgi.jbosgi108.bundleA;
//$Id: ServiceActivator.java 87064 2009-04-09 11:08:56Z thomas.diesler(a)jboss.com $
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
+import javax.management.MBeanServer;
-import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.xml.XMLParserActivator;
-public class ActivatorBundleA extends XMLParserActivator
+public class ActivatorBundleA implements BundleActivator
{
- private LogService log;
+ private SomeBean bean;
- public void start(BundleContext context) throws Exception
+ public void start(BundleContext context)
{
- log = new LogServiceTracker(context);
+ bean = new SomeBean();
- super.start(context);
-
- logSAXParserFactory(context);
- logDOMParserFactory(context);
- }
-
- private void logSAXParserFactory(BundleContext context)
- {
- ServiceReference saxRef = context.getServiceReference(SAXParserFactory.class.getName());
- if (saxRef != null)
+ // Register the MBean
+ try
{
- Object factory = context.getService(saxRef);
- log.log(LogService.LOG_INFO, "SAXParserFactory: " + factory.getClass().getName());
-
- for (String key : saxRef.getPropertyKeys())
- {
- Object value = saxRef.getProperty(key);
- log.log(LogService.LOG_INFO, " " + key + "=" + value);
- }
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ MBeanServer service = (MBeanServer)context.getService(sref);
+ service.registerMBean(bean, SomeBean.MBEAN_NAME);
}
- else
+ catch (Exception ex)
{
- log.log(LogService.LOG_WARNING, "No SAXParserFactory registered");
+ throw new IllegalStateException(ex);
}
+
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
}
- private void logDOMParserFactory(BundleContext context)
+ public void stop(BundleContext context)
{
- ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
- if (domRef != null)
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+
+ // Register the MBean
+ try
{
- Object factory = context.getService(domRef);
- log.log(LogService.LOG_INFO, "DocumentBuilderFactory: " + factory.getClass().getName());
-
- for (String key : domRef.getPropertyKeys())
- {
- Object value = domRef.getProperty(key);
- log.log(LogService.LOG_INFO, " " + key + "=" + value);
- }
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ MBeanServer service = (MBeanServer)context.getService(sref);
+ service.unregisterMBean(SomeBean.MBEAN_NAME);
}
- else
+ catch (Exception ex)
{
- log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
+ throw new IllegalStateException(ex);
}
}
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,59 +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.test.osgi.jbosgi92.bundleA;
-
-//$Id$
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
-{
- @Override
- public Object getAttribute(String name) throws IllegalArgumentException
- {
- return null;
- }
-
- @Override
- public boolean getFeature(String name) throws ParserConfigurationException
- {
- return false;
- }
-
- @Override
- public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
- {
- return null;
- }
-
- @Override
- public void setAttribute(String name, Object value) throws IllegalArgumentException
- {
- }
-
- @Override
- public void setFeature(String name, boolean value) throws ParserConfigurationException
- {
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,52 +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.test.osgi.jbosgi92.bundleA;
-
-//$Id$
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-
-public class SAXParserFactoryImpl extends SAXParserFactory
-{
- @Override
- public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
- {
- return false;
- }
-
- @Override
- public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
- {
- return null;
- }
-
- @Override
- public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
- {
- }
-}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,43 @@
+/*
+ * 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.jbosgi108.bundleA;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class SomeBean implements SomeBeanMBean
+{
+ private static List<String> messages = new ArrayList<String>();
+
+ public void addMessage(String msg)
+ {
+ messages.add(msg);
+ }
+
+ public List<String> getMessages()
+ {
+ return Collections.unmodifiableList(messages);
+ }
+}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,37 @@
+/*
+ * 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.jbosgi108.bundleA;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+
+//$Id$
+
+public interface SomeBeanMBean
+{
+ ObjectName MBEAN_NAME = ObjectNameFactory.create("jboss.osgi:bean=SomeBean");
+
+ List<String> getMessages();
+}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB)
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-14 09:41:15 UTC (rev 91196)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,47 +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.test.osgi.jbosgi108.bundleB;
-
-//$Id$
-
-import org.jboss.test.osgi.jbosgi108.bundleA.SomeBean;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class ActivatorBundleB implements BundleActivator
-{
- private SomeBean bean = new SomeBean();
-
- public void start(BundleContext context)
- {
- ClassLoader cl = getClass().getClassLoader();
- String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
- }
-
- public void stop(BundleContext context)
- {
- ClassLoader cl = getClass().getClassLoader();
- String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,47 @@
+/*
+ * 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.jbosgi108.bundleB;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi108.bundleA.SomeBean;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class ActivatorBundleB implements BundleActivator
+{
+ private SomeBean bean = new SomeBean();
+
+ public void start(BundleContext context)
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+ }
+
+ public void stop(BundleContext context)
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.jbosgi92;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-92] Class.forName issue with XMLParserActivator
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-92
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2009
+ */
+public class OSGI92TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testDeployParsers() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
+ bundleA.start();
+
+ assertEquals(Bundle.ACTIVE, bundleA.getState());
+
+ String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
+ OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
+ assertEquals("DocumentBuilderFactory servce available", 1, domRefs.length);
+
+ OSGiServiceReference[] saxRefs = runtime.getServiceReferences(SAXParserFactory.class.getName(), filter);
+ assertEquals("SAXParserFactory servce available", 1, saxRefs.length);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,88 @@
+/*
+ * 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.jbosgi92.bundleA;
+
+//$Id$
+
+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;
+
+public class ActivatorBundleA extends XMLParserActivator
+{
+ 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_INFO, "SAXParserFactory: " + factory.getClass().getName());
+
+ for (String key : saxRef.getPropertyKeys())
+ {
+ Object value = saxRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + 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_INFO, "DocumentBuilderFactory: " + factory.getClass().getName());
+
+ for (String key : domRef.getPropertyKeys())
+ {
+ Object value = domRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + key + "=" + value);
+ }
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,59 @@
+/*
+ * 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.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
+{
+ @Override
+ public Object getAttribute(String name) throws IllegalArgumentException
+ {
+ return null;
+ }
+
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException
+ {
+ return false;
+ }
+
+ @Override
+ public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
+ {
+ return null;
+ }
+
+ @Override
+ public void setAttribute(String name, Object value) throws IllegalArgumentException
+ {
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,52 @@
+/*
+ * 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.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+public class SAXParserFactoryImpl extends SAXParserFactory
+{
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ return false;
+ }
+
+ @Override
+ public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
+ {
+ return null;
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
14 years, 10 months
JBoss-OSGI SVN: r91510 - in projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108: bundleA and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 15:40:28 -0400 (Tue, 21 Jul 2009)
New Revision: 91510
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java
Removed:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
Log:
[JBOSGI-92] Class.forName issue with XMLParserActivator
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java 2009-07-21 19:38:01 UTC (rev 91509)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -1,176 +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.test.osgi.jbosgi108;
-
-//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jboss.osgi.jmx.JMXCapability;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.test.osgi.jbosgi108.bundleA.SomeBeanMBean;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.osgi.framework.BundleException;
-
-/**
- * [JBOSGI-108] Investigate statics on PackageAdmin.refresh
- *
- * https://jira.jboss.org/jira/browse/JBOSGI-108
- *
- * @author thomas.diesler(a)jboss.com
- * @since 19-Jun-2009
- */
-public class OSGI108TestCase
-{
- private static OSGiRuntime runtime;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- runtime = new OSGiTestHelper().getDefaultRuntime();
- runtime.addCapability(new JMXCapability());
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (runtime != null)
- runtime.shutdown();
- }
-
- @Before
- public void setUp()
- {
- OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
- packageAdmin.refreshPackages(null);
- }
-
- @Test
- public void testRedeploySingle() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
-
- bundleA.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleA.uninstall();
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be recreated
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleA.uninstall();
- }
-
- @Test
- public void testRedeployWithReference() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
-
- bundleA.start();
- bundleB.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 2, messages.size());
-
- bundleA.uninstall();
-
- // After uninstall bundleA, bundleB still holds a reference on
- // bundleA.SomeBean
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be reused
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 4, messages.size());
-
- bundleB.uninstall();
- bundleA.uninstall();
- }
-
- @Test
- public void testRedeployWithReferenceAndRefresh() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
-
- bundleA.start();
- bundleB.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 2, messages.size());
-
- bundleA.uninstall();
-
- // After uninstall bundleA, bundleB still holds a reference on
- // bundleA.SomeBean
-
- // Refresh all packages
- OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
- packageAdmin.refreshPackages(null);
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be recreated
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleB.uninstall();
- bundleA.uninstall();
- }
-
- private List<String> report(List<String> messages)
- {
- // System.out.println(">>>>>>>>>>>>");
- // for (String aux : messages)
- // System.out.println(aux);
- // System.out.println("<<<<<<<<<<<");
-
- return messages;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java (from rev 91496, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.jbosgi92;
+
+//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-92] Class.forName issue with XMLParserActivator
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-92
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2009
+ */
+public class OSGI92TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testDeployParsers() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
+ bundleA.start();
+
+ assertEquals(Bundle.ACTIVE, bundleA.getState());
+
+ String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
+ OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
+ assertEquals("DocumentBuilderFactory servce available", 1, domRefs.length);
+
+ OSGiServiceReference[] saxRefs = runtime.getServiceReferences(SAXParserFactory.class.getName(), filter);
+ assertEquals("SAXParserFactory servce available", 1, saxRefs.length);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:38:01 UTC (rev 91509)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -19,57 +19,70 @@
* 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.jbosgi108.bundleA;
+package org.jboss.test.osgi.jbosgi92.bundleA;
//$Id: ServiceActivator.java 87064 2009-04-09 11:08:56Z thomas.diesler(a)jboss.com $
-import javax.management.MBeanServer;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
-import org.osgi.framework.BundleActivator;
+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;
-public class ActivatorBundleA implements BundleActivator
+public class ActivatorBundleA extends XMLParserActivator
{
- private SomeBean bean;
+ private LogService log;
- public void start(BundleContext context)
+ public void start(BundleContext context) throws Exception
{
- bean = new SomeBean();
+ log = new LogServiceTracker(context);
- // Register the MBean
- try
+ super.start(context);
+
+ logSAXParserFactory(context);
+ logDOMParserFactory(context);
+ }
+
+ private void logSAXParserFactory(BundleContext context)
+ {
+ ServiceReference saxRef = context.getServiceReference(SAXParserFactory.class.getName());
+ if (saxRef != null)
{
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- MBeanServer service = (MBeanServer)context.getService(sref);
- service.registerMBean(bean, SomeBean.MBEAN_NAME);
+ Object factory = context.getService(saxRef);
+ log.log(LogService.LOG_INFO, "SAXParserFactory: " + factory.getClass().getName());
+
+ for (String key : saxRef.getPropertyKeys())
+ {
+ Object value = saxRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + key + "=" + value);
+ }
}
- catch (Exception ex)
+ else
{
- throw new IllegalStateException(ex);
+ log.log(LogService.LOG_WARNING, "No SAXParserFactory registered");
}
-
- ClassLoader cl = getClass().getClassLoader();
- String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
}
- public void stop(BundleContext context)
+ private void logDOMParserFactory(BundleContext context)
{
- ClassLoader cl = getClass().getClassLoader();
- String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
-
- // Register the MBean
- try
+ ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
+ if (domRef != null)
{
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- MBeanServer service = (MBeanServer)context.getService(sref);
- service.unregisterMBean(SomeBean.MBEAN_NAME);
+ Object factory = context.getService(domRef);
+ log.log(LogService.LOG_INFO, "DocumentBuilderFactory: " + factory.getClass().getName());
+
+ for (String key : domRef.getPropertyKeys())
+ {
+ Object value = domRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + key + "=" + value);
+ }
}
- catch (Exception ex)
+ else
{
- throw new IllegalStateException(ex);
+ log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
}
}
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java (from rev 91496, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -0,0 +1,59 @@
+/*
+ * 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.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
+{
+ @Override
+ public Object getAttribute(String name) throws IllegalArgumentException
+ {
+ return null;
+ }
+
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException
+ {
+ return false;
+ }
+
+ @Override
+ public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
+ {
+ return null;
+ }
+
+ @Override
+ public void setAttribute(String name, Object value) throws IllegalArgumentException
+ {
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException
+ {
+ }
+}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:38:01 UTC (rev 91509)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -27,11 +27,9 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
public class SAXParserFactoryImpl extends SAXParserFactory
{
@@ -44,44 +42,7 @@
@Override
public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
{
- return new SAXParser()
- {
-
- @Override
- public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
- {
- }
-
- @Override
- public boolean isValidating()
- {
- return false;
- }
-
- @Override
- public boolean isNamespaceAware()
- {
- return false;
- }
-
- @Override
- public XMLReader getXMLReader() throws SAXException
- {
- return null;
- }
-
- @Override
- public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
- {
- return null;
- }
-
- @Override
- public Parser getParser() throws SAXException
- {
- return null;
- }
- };
+ return null;
}
@Override
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java 2009-07-21 19:38:01 UTC (rev 91509)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -1,43 +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.test.osgi.jbosgi108.bundleA;
-
-//$Id$
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class SomeBean implements SomeBeanMBean
-{
- private static List<String> messages = new ArrayList<String>();
-
- public void addMessage(String msg)
- {
- messages.add(msg);
- }
-
- public List<String> getMessages()
- {
- return Collections.unmodifiableList(messages);
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java 2009-07-21 19:38:01 UTC (rev 91509)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java 2009-07-21 19:40:28 UTC (rev 91510)
@@ -1,37 +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.test.osgi.jbosgi108.bundleA;
-
-import java.util.List;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-
-//$Id$
-
-public interface SomeBeanMBean
-{
- ObjectName MBEAN_NAME = ObjectNameFactory.create("jboss.osgi:bean=SomeBean");
-
- List<String> getMessages();
-}
14 years, 10 months
JBoss-OSGI SVN: r91509 - in projects/jboss-osgi: projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml and 8 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 15:38:01 -0400 (Tue, 21 Jul 2009)
New Revision: 91509
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/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.DocumentBuilderFactory
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.SAXParserFactory
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/jbosgi92-bundleA.bnd
Removed:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/
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/trunk/reactor/
projects/jboss-osgi/trunk/reactor/pom.xml
projects/jboss-osgi/trunk/testsuite/example/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
Log:
[JBOSGI-92] Class.forName issue with XMLParserActivator
Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 19:38:01 UTC (rev 91509)
@@ -91,9 +91,6 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.xml.XMLParserActivatorExt</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
- <Private-Package>
- org.jboss.osgi.xml.internal
- </Private-Package>
<Export-Package>
org.jboss.osgi.xml;version=${version}
</Export-Package>
Copied: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java (from rev 91504, 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/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java 2009-07-21 19:38:01 UTC (rev 91509)
@@ -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;
+
+//$Id: XercesParserActivator.java 91417 2009-07-20 09:25:44Z thomas.diesler(a)jboss.com $
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * A DocumentBuilderFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler(a)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
Copied: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java (from rev 91504, projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/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 19:38:01 UTC (rev 91509)
@@ -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;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+//$Id: XercesParserActivator.java 91417 2009-07-20 09:25:44Z thomas.diesler(a)jboss.com $
+
+/**
+ * A SAXParserFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler(a)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/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 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java 2009-07-21 19:38:01 UTC (rev 91509)
@@ -29,10 +29,10 @@
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;
+import org.osgi.util.xml.XMLParserActivator;
/**
* Activate the XML parser using {@link XMLParserActivatorExt}
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 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory 2009-07-21 19:38:01 UTC (rev 91509)
@@ -1 +1 @@
-org.jboss.osgi.xml.internal.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 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory 2009-07-21 19:38:01 UTC (rev 91509)
@@ -1 +1 @@
-org.jboss.osgi.xml.internal.SAXParserFactoryImpl
\ No newline at end of file
+org.jboss.osgi.xml.SAXParserFactoryImpl
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor
___________________________________________________________________
Name: svn:externals
- #spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
#bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
+ #spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
Modified: projects/jboss-osgi/trunk/reactor/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-21 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-21 19:38:01 UTC (rev 91509)
@@ -27,6 +27,7 @@
</parent>
<modules>
+ <module>bundles/apache-xerces</module>
<module>blueprint</module>
</modules>
Modified: projects/jboss-osgi/trunk/testsuite/example/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/pom.xml 2009-07-21 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/trunk/testsuite/example/pom.xml 2009-07-21 19:38:01 UTC (rev 91509)
@@ -11,6 +11,15 @@
<!-- $Id: pom.xml 91197 2009-07-14 09:48:24Z thomas.diesler(a)jboss.com $ -->
+ <!--
+ Set these VM properties in your IDE debugger
+
+ -Dlog4j.output.dir=${workspace_loc:jboss-osgi-testsuite-example/target}
+ -Djboss.osgi.framework.properties=jboss-osgi-felix.properties
+ -Dorg.jboss.osgi.husky.Invoker=org.jboss.osgi.husky.internal.OSGiInvoker
+ -Dtest.archive.directory=${workspace_loc:jboss-osgi-testsuite-example/target}/test-libs
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
Modified: projects/jboss-osgi/trunk/testsuite/functional/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-07-21 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-07-21 19:38:01 UTC (rev 91509)
@@ -11,6 +11,15 @@
<!-- $Id: pom.xml 91197 2009-07-14 09:48:24Z thomas.diesler(a)jboss.com $ -->
+ <!--
+ Set these VM properties in your IDE debugger
+
+ -Dlog4j.output.dir=${workspace_loc:jboss-osgi-testsuite-functional/target}
+ -Djboss.osgi.framework.properties=jboss-osgi-felix.properties
+ -Dorg.jboss.osgi.husky.Invoker=org.jboss.osgi.husky.internal.OSGiInvoker
+ -Dtest.archive.directory=${workspace_loc:jboss-osgi-testsuite-functional/target}/test-libs
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2009-07-21 19:35:31 UTC (rev 91508)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2009-07-21 19:38:01 UTC (rev 91509)
@@ -81,6 +81,9 @@
<!-- jbosgi99 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi99-bundleA.jar" files="${tests.resources.dir}/jbosgi99/jbosgi99-bundleA.bnd" />
+ <!-- jbosgi92 -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi92-bundleA.jar" files="${tests.resources.dir}/jbosgi92/jbosgi92-bundleA.bnd" />
+
<!-- jbosgi108 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi108-bundleA.jar" files="${tests.resources.dir}/jbosgi108/jbosgi108-bundleA.bnd" />
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi108-bundleB.jar" files="${tests.resources.dir}/jbosgi108/jbosgi108-bundleB.bnd" />
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:38:01 UTC (rev 91509)
@@ -0,0 +1,91 @@
+/*
+ * 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.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Parser;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+
+public class SAXParserFactoryImpl extends SAXParserFactory
+{
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ return false;
+ }
+
+ @Override
+ public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
+ {
+ return new SAXParser()
+ {
+
+ @Override
+ public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ }
+
+ @Override
+ public boolean isValidating()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isNamespaceAware()
+ {
+ return false;
+ }
+
+ @Override
+ public XMLReader getXMLReader() throws SAXException
+ {
+ return null;
+ }
+
+ @Override
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ return null;
+ }
+
+ @Override
+ public Parser getParser() throws SAXException
+ {
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.DocumentBuilderFactory
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.DocumentBuilderFactory (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.DocumentBuilderFactory 2009-07-21 19:38:01 UTC (rev 91509)
@@ -0,0 +1 @@
+org.jboss.test.osgi.jbosgi92.bundleA.DocumentBuilderFactoryImpl
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.SAXParserFactory
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.SAXParserFactory (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/javax.xml.parsers.SAXParserFactory 2009-07-21 19:38:01 UTC (rev 91509)
@@ -0,0 +1 @@
+org.jboss.test.osgi.jbosgi92.bundleA.SAXParserFactoryImpl
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/jbosgi92-bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/jbosgi92-bundleA.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi92/jbosgi92-bundleA.bnd 2009-07-21 19:38:01 UTC (rev 91509)
@@ -0,0 +1,11 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi92-bundleA.jar src/test/resources/jbosgi92/jbosgi92-bundleA.bnd
+
+Bundle-SymbolicName: jbosgi92-bundleA
+
+Bundle-Activator: org.jboss.test.osgi.jbosgi92.bundleA.ActivatorBundleA
+
+Export-Package: org.jboss.test.osgi.jbosgi92.bundleA
+
+Include-Resource: \
+ META-INF/services/javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.DocumentBuilderFactory, \
+ META-INF/services/javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory
14 years, 10 months
JBoss-OSGI SVN: r91507 - in projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky: runtime/osgi and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 15:30:45 -0400 (Tue, 21 Jul 2009)
New Revision: 91507
Added:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java
Removed:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
Log:
Remove duplicate LogServiceTracker reference
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java (from rev 91504, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -0,0 +1,85 @@
+/*
+ * 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.husky.internal;
+
+//$Id$
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A combined ServiceTracker/LogService that bundles can use to access the registered LogService.
+ *
+ * If a LogService is registered, the LogServiceTracker delegates to that LogService.
+ * If there is no LogService registered, the LogServiceTracker delegates to the {@link HuskySystemLog}
+ *
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 11-Apr-2009
+ */
+public class HuskyLogService extends ServiceTracker implements LogService
+{
+ private LogService log;
+
+ public HuskyLogService(BundleContext context)
+ {
+ super(context, LogService.class.getName(), null);
+ log = new HuskySystemLog(context);
+ open();
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ log = (LogService)super.addingService(reference);
+ return log;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ super.removedService(reference, service);
+ log = new HuskySystemLog(context);
+ }
+
+ public void log(int level, String message)
+ {
+ log.log(level, message);
+ }
+
+ public void log(int level, String message, Throwable exception)
+ {
+ log.log(level, message, exception);
+ }
+
+ public void log(ServiceReference sr, int level, String message)
+ {
+ log.log(sr, level, message);
+ }
+
+ public void log(ServiceReference sr, int level, String message, Throwable exception)
+ {
+ log.log(sr, level, message, exception);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java (from rev 91504, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -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.husky.internal;
+
+//$Id$
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * A basic LogService that writes to System.out
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 11-Apr-2009
+ */
+class HuskySystemLog implements LogService
+{
+ private BundleContext context;
+
+ public HuskySystemLog(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void log(int level, String message)
+ {
+ logInternal(null, level, message, null);
+ }
+
+ public void log(int level, String message, Throwable exception)
+ {
+ logInternal(null, level, message, exception);
+ }
+
+ public void log(ServiceReference sr, int level, String message)
+ {
+ logInternal(sr, level, message, null);
+ }
+
+ public void log(ServiceReference sr, int level, String message, Throwable exception)
+ {
+ logInternal(sr, level, message, exception);
+ }
+
+ private void logInternal(ServiceReference sref, int level, String message, Throwable exception)
+ {
+ long time = System.currentTimeMillis();
+ Bundle bundle = context.getBundle();
+
+ String bndStr = bundle.getSymbolicName();
+
+ String srefStr = null;
+ if (sref != null && sref.getBundle() != null)
+ srefStr = sref.getBundle().getSymbolicName();
+
+ String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
+ String l = " " + logLevel(level);
+ String s = srefStr != null ? ",sref=" + srefStr : "";
+ String b = ",bnd=" + bndStr;
+ String m = ",msg=" + message;
+ String e = exception != null ? ",ex=" + exception : "";
+
+ System.out.println("[" + t + l + b + s + m + e + "]");
+
+ if (exception != null)
+ exception.printStackTrace(System.out);
+ }
+
+ private String logLevel(int level)
+ {
+ String logLevel;
+ switch (level)
+ {
+ case LogService.LOG_DEBUG:
+ logLevel = "DEBUG";
+ break;
+ case LogService.LOG_INFO:
+ logLevel = "INFO";
+ break;
+ case LogService.LOG_WARNING:
+ logLevel = "WARN";
+ break;
+ case LogService.LOG_ERROR:
+ logLevel = "ERROR";
+ break;
+ default:
+ logLevel = "Level=" + level;
+ }
+ return logLevel;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java 2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -1,85 +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.husky.internal;
-
-//$Id$
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A combined ServiceTracker/LogService that bundles can use to access the registered LogService.
- *
- * If a LogService is registered, the LogServiceTracker delegates to that LogService.
- * If there is no LogService registered, the LogServiceTracker delegates to the {@link SystemLogService}
- *
- *
- * @author thomas.diesler(a)jboss.com
- * @since 11-Apr-2009
- */
-public class LogServiceTracker extends ServiceTracker implements LogService
-{
- private LogService log;
-
- public LogServiceTracker(BundleContext context)
- {
- super(context, LogService.class.getName(), null);
- log = new SystemLogService(context);
- open();
- }
-
- @Override
- public Object addingService(ServiceReference reference)
- {
- log = (LogService)super.addingService(reference);
- return log;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- super.removedService(reference, service);
- log = new SystemLogService(context);
- }
-
- public void log(int level, String message)
- {
- log.log(level, message);
- }
-
- public void log(int level, String message, Throwable exception)
- {
- log.log(level, message, exception);
- }
-
- public void log(ServiceReference sr, int level, String message)
- {
- log.log(sr, level, message);
- }
-
- public void log(ServiceReference sr, int level, String message, Throwable exception)
- {
- log.log(sr, level, message, exception);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java 2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -1,115 +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.husky.internal;
-
-//$Id$
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * A basic LogService that writes to System.out
- *
- * @author thomas.diesler(a)jboss.com
- * @since 11-Apr-2009
- */
-public class SystemLogService implements LogService
-{
- private BundleContext context;
-
- public SystemLogService(BundleContext context)
- {
- this.context = context;
- }
-
- public void log(int level, String message)
- {
- logInternal(null, level, message, null);
- }
-
- public void log(int level, String message, Throwable exception)
- {
- logInternal(null, level, message, exception);
- }
-
- public void log(ServiceReference sr, int level, String message)
- {
- logInternal(sr, level, message, null);
- }
-
- public void log(ServiceReference sr, int level, String message, Throwable exception)
- {
- logInternal(sr, level, message, exception);
- }
-
- private void logInternal(ServiceReference sref, int level, String message, Throwable exception)
- {
- long time = System.currentTimeMillis();
- Bundle bundle = context.getBundle();
-
- String bndStr = bundle.getSymbolicName();
-
- String srefStr = null;
- if (sref != null && sref.getBundle() != null)
- srefStr = sref.getBundle().getSymbolicName();
-
- String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
- String l = " " + logLevel(level);
- String s = srefStr != null ? ",sref=" + srefStr : "";
- String b = ",bnd=" + bndStr;
- String m = ",msg=" + message;
- String e = exception != null ? ",ex=" + exception : "";
-
- System.out.println("[" + t + l + b + s + m + e + "]");
-
- if (exception != null)
- exception.printStackTrace(System.out);
- }
-
- private String logLevel(int level)
- {
- String logLevel;
- switch (level)
- {
- case LogService.LOG_DEBUG:
- logLevel = "DEBUG";
- break;
- case LogService.LOG_INFO:
- logLevel = "INFO";
- break;
- case LogService.LOG_WARNING:
- logLevel = "WARN";
- break;
- case LogService.LOG_ERROR:
- logLevel = "ERROR";
- break;
- default:
- logLevel = "Level=" + level;
- }
- return logLevel;
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java 2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -27,7 +27,7 @@
import java.util.Arrays;
import java.util.List;
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
import org.jboss.osgi.husky.runtime.Connector;
import org.jboss.osgi.husky.runtime.PackageListener;
import org.jboss.osgi.husky.runtime.junit.JUnitPackageListener;
@@ -56,7 +56,7 @@
public HuskyExtender(BundleContext context)
{
- this.log = new LogServiceTracker(context);
+ this.log = new HuskyLogService(context);
this.context = context;
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java 2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -31,7 +31,7 @@
import javax.management.ObjectName;
import org.jboss.osgi.husky.internal.AbstractConnector;
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
import org.jboss.osgi.husky.runtime.Connector;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -68,7 +68,7 @@
public JMXConnector(BundleContext context)
{
- this.log = new LogServiceTracker(context);
+ this.log = new HuskyLogService(context);
this.context = context;
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java 2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java 2009-07-21 19:30:45 UTC (rev 91507)
@@ -31,7 +31,7 @@
import java.util.Properties;
import org.jboss.osgi.husky.internal.AbstractConnector;
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
import org.jboss.osgi.husky.internal.Util;
import org.jboss.osgi.husky.runtime.Connector;
import org.osgi.framework.BundleContext;
@@ -63,7 +63,7 @@
public SocketConnector(BundleContext context)
{
- this.log = new LogServiceTracker(context);
+ this.log = new HuskyLogService(context);
this.context = context;
}
14 years, 10 months
JBoss-OSGI SVN: r91501 - projects/jboss-osgi/trunk/reactor.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 12:48:34 -0400 (Tue, 21 Jul 2009)
New Revision: 91501
Removed:
projects/jboss-osgi/trunk/reactor/bundles/
projects/jboss-osgi/trunk/reactor/runtime/
Log:
Move done reactor projects out again
14 years, 10 months
JBoss-OSGI SVN: r91498 - projects/jboss-osgi/projects/runtime/jbossas/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 12:24:12 -0400 (Tue, 21 Jul 2009)
New Revision: 91498
Modified:
projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
Log:
Fix typo
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 16:15:43 UTC (rev 91497)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 16:24:12 UTC (rev 91498)
@@ -102,7 +102,7 @@
org/jboss/osgi/jmx/*.class,
org/jboss/osgi/jndi/*.class,
org/jboss/osgi/microcontainer/*.class,
- org/jboss/osgi/microcontainer/internal/AbstractMicrocontainerService.class,
+ org/jboss/osgi/microcontainer/integration/*.class,
org/jboss/osgi/xml/*.class
</includes>
</configuration>
14 years, 10 months
JBoss-OSGI SVN: r91497 - in projects/jboss-osgi: projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi and 6 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)jboss.com $
-
-/**
- * A DocumentBuilderFactory that gets loaded from this bundle.
- *
- * @author thomas.diesler(a)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(a)jboss.com $
-
-/**
- * A SAXParserFactory that gets loaded from this bundle.
- *
- * @author thomas.diesler(a)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(a)jboss.com $
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * A DocumentBuilderFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler(a)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(a)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(a)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(a)jboss.com $
+
+/**
+ * A SAXParserFactory that gets loaded from this bundle.
+ *
+ * @author thomas.diesler(a)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()
14 years, 10 months
JBoss-OSGI SVN: r91496 - in projects/jboss-osgi: projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache and 10 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-21 10:48:51 -0400 (Tue, 21 Jul 2009)
New Revision: 91496
Added:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/
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/XMLParserActivator.java
Removed:
projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/apache/xerces/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointService.java
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/runtime/jbossas/trunk/.classpath
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
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/resources/jboss-beans-felix.xml
projects/jboss-osgi/trunk/reactor/
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/reactor/pom.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jaxb/example-xml-jaxb.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/parser/example-xml-parser.bnd
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 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
@@ -89,10 +89,10 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.xml.XMLParserActivatorExt</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.xml.internal.LoggingXMLParserActivator</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<Private-Package>
- org.jboss.osgi.apache.xerces.internal
+ org.jboss.osgi.xml.internal
</Private-Package>
<Export-Package>
org.jboss.osgi.xml;version=${version}
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 13:54:45 UTC (rev 91495)
+++ 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)
@@ -28,11 +28,7 @@
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;
+import org.jboss.osgi.xml.internal.XMLParserActivator;
/**
* Activate the XML parser using {@link XMLParserActivatorExt}
@@ -42,23 +38,12 @@
*/
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)
@@ -169,45 +154,4 @@
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
Added: 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 (rev 0)
+++ 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)
@@ -0,0 +1,95 @@
+/*
+ * 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(a)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(a)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
Added: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java 2009-07-21 14:48:51 UTC (rev 91496)
@@ -0,0 +1,527 @@
+/*
+ * $Header: /cvshome/build/org.osgi.util.xml/src/org/osgi/util/xml/XMLParserActivator.java,v 1.11 2006/10/27 18:17:06 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2002, 2006). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.osgi.xml.internal;
+
+import java.io.*;
+import java.net.URL;
+import java.util.*;
+
+import javax.xml.parsers.*;
+
+import org.osgi.framework.*;
+
+/**
+ * A BundleActivator class that allows any JAXP compliant XML Parser to register
+ * itself as an OSGi parser service.
+ *
+ * Multiple JAXP compliant parsers can concurrently register by using this
+ * BundleActivator class. Bundles who wish to use an XML parser can then use the
+ * framework's service registry to locate available XML Parsers with the desired
+ * characteristics such as validating and namespace-aware.
+ *
+ * <p>
+ * The services that this bundle activator enables a bundle to provide are:
+ * <ul>
+ * <li><code>javax.xml.parsers.SAXParserFactory</code>({@link #SAXFACTORYNAME})
+ * <li><code>javax.xml.parsers.DocumentBuilderFactory</code>(
+ * {@link #DOMFACTORYNAME})
+ * </ul>
+ *
+ * <p>
+ * The algorithm to find the implementations of the abstract parsers is derived
+ * from the JAR file specifications, specifically the Services API.
+ * <p>
+ * An XMLParserActivator assumes that it can find the class file names of the
+ * factory classes in the following files:
+ * <ul>
+ * <li><code>/META-INF/services/javax.xml.parsers.SAXParserFactory</code> is
+ * a file contained in a jar available to the runtime which contains the
+ * implementation class name(s) of the SAXParserFactory.
+ * <li><code>/META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
+ * is a file contained in a jar available to the runtime which contains the
+ * implementation class name(s) of the <code>DocumentBuilderFactory</code>
+ * </ul>
+ * <p>
+ * If either of the files does not exist, <code>XMLParserActivator</code>
+ * assumes that the parser does not support that parser type.
+ *
+ * <p>
+ * <code>XMLParserActivator</code> attempts to instantiate both the
+ * <code>SAXParserFactory</code> and the <code>DocumentBuilderFactory</code>.
+ * It registers each factory with the framework along with service properties:
+ * <ul>
+ * <li>{@link #PARSER_VALIDATING}- indicates if this factory supports
+ * validating parsers. It's value is a <code>Boolean</code>.
+ * <li>{@link #PARSER_NAMESPACEAWARE}- indicates if this factory supports
+ * namespace aware parsers It's value is a <code>Boolean</code>.
+ * </ul>
+ * <p>
+ * Individual parser implementations may have additional features, properties,
+ * or attributes which could be used to select a parser with a filter. These can
+ * be added by extending this class and overriding the
+ * <code>setSAXProperties</code> and <code>setDOMProperties</code> methods.
+ */
+public class XMLParserActivator implements BundleActivator, ServiceFactory {
+ /** Context of this bundle */
+ private BundleContext context;
+ /**
+ * Filename containing the SAX Parser Factory Class name. Also used as the
+ * basis for the <code>SERVICE_PID<code> registration property.
+ */
+ public static final String SAXFACTORYNAME = "javax.xml.parsers.SAXParserFactory";
+ /**
+ * Filename containing the DOM Parser Factory Class name. Also used as the
+ * basis for the <code>SERVICE_PID</code> registration property.
+ */
+ public static final String DOMFACTORYNAME = "javax.xml.parsers.DocumentBuilderFactory";
+ /** Path to the factory class name files */
+ private static final String PARSERCLASSFILEPATH = "/META-INF/services/";
+ /** Fully qualified path name of SAX Parser Factory Class Name file */
+ public static final String SAXCLASSFILE = PARSERCLASSFILEPATH
+ + SAXFACTORYNAME;
+ /** Fully qualified path name of DOM Parser Factory Class Name file */
+ public static final String DOMCLASSFILE = PARSERCLASSFILEPATH
+ + DOMFACTORYNAME;
+ /** SAX Factory Service Description */
+ private static final String SAXFACTORYDESCRIPTION = "A JAXP Compliant SAX Parser";
+ /** DOM Factory Service Description */
+ private static final String DOMFACTORYDESCRIPTION = "A JAXP Compliant DOM Parser";
+ /**
+ * Service property specifying if factory is configured to support
+ * validating parsers. The value is of type <code>Boolean</code>.
+ */
+ public static final String PARSER_VALIDATING = "parser.validating";
+ /**
+ * Service property specifying if factory is configured to support namespace
+ * aware parsers. The value is of type <code>Boolean</code>.
+ */
+ public static final String PARSER_NAMESPACEAWARE = "parser.namespaceAware";
+ /**
+ * Key for parser factory name property - this must be saved in the parsers
+ * properties hashtable so that the parser factory can be instantiated from
+ * a ServiceReference
+ */
+ private static final String FACTORYNAMEKEY = "parser.factoryname";
+
+ /**
+ * Called when this bundle is started so the Framework can perform the
+ * bundle-specific activities necessary to start this bundle. This method
+ * can be used to register services or to allocate any resources that this
+ * bundle needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * <p>
+ * This method attempts to register a SAX and DOM parser with the
+ * Framework's service registry.
+ *
+ * @param context The execution context of the bundle being started.
+ * @throws java.lang.Exception If this method throws an exception, this
+ * bundle is marked as stopped and the Framework will remove this
+ * bundle's listeners, unregister all services registered by this
+ * bundle, and release all services used by this bundle.
+ */
+ public void start(BundleContext context) throws Exception {
+ this.context = context;
+ Bundle parserBundle = context.getBundle();
+ try {
+ // check for sax parsers
+ registerSAXParsers(getParserFactoryClassNames(parserBundle
+ .getResource(SAXCLASSFILE)));
+ // check for dom parsers
+ registerDOMParsers(getParserFactoryClassNames(parserBundle
+ .getResource(DOMCLASSFILE)));
+ }
+ catch (IOException ioe) {
+ // if there were any IO errors accessing the resource files
+ // containing the class names
+ ioe.printStackTrace();
+ throw new FactoryConfigurationError(ioe);
+ }
+ }
+
+ /**
+ * This method has nothing to do as all active service registrations will
+ * automatically get unregistered when the bundle stops.
+ *
+ * @param context The execution context of the bundle being stopped.
+ * @throws java.lang.Exception If this method throws an exception, the
+ * bundle is still marked as stopped, and the Framework will remove
+ * the bundle's listeners, unregister all services registered by the
+ * bundle, and release all services used by the bundle.
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+ /**
+ * Given the URL for a file, reads and returns the parser class names. There
+ * may be multiple classes specified in this file, one per line. There may
+ * also be comment lines in the file, which begin with "#".
+ *
+ * @param parserUrl The URL of the service file containing the parser class
+ * names
+ * @return A vector of strings containing the parser class names or null if
+ * parserUrl is null
+ * @throws IOException if there is a problem reading the URL input stream
+ */
+ private Vector getParserFactoryClassNames(URL parserUrl) throws IOException {
+ Vector v = new Vector(1);
+ if (parserUrl != null) {
+ String parserFactoryClassName = null;
+ InputStream is = parserUrl.openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ while (true) {
+ parserFactoryClassName = br.readLine();
+ if (parserFactoryClassName == null) {
+ break; // end of file reached
+ }
+ String pfcName = parserFactoryClassName.trim();
+ if (pfcName.length() == 0) {
+ continue; // blank line
+ }
+ int commentIdx = pfcName.indexOf("#");
+ if (commentIdx == 0) { // comment line
+ continue;
+ }
+ else
+ if (commentIdx < 0) { // no comment on this line
+ v.addElement(pfcName);
+ }
+ else {
+ v.addElement(pfcName.substring(0, commentIdx).trim());
+ }
+ }
+ return v;
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Register SAX Parser Factory Services with the framework.
+ *
+ * @param parserFactoryClassNames - a <code>Vector</code> of
+ * <code>String</code> objects containing the names of the parser
+ * Factory Classes
+ * @throws FactoryConfigurationError if thrown from <code>getFactory</code>
+ */
+ private void registerSAXParsers(Vector parserFactoryClassNames)
+ throws FactoryConfigurationError {
+ if (parserFactoryClassNames != null) {
+ Enumeration e = parserFactoryClassNames.elements();
+ int index = 0;
+ while (e.hasMoreElements()) {
+ String parserFactoryClassName = (String) e.nextElement();
+ // create a sax parser factory just to get it's default
+ // properties. It will never be used since
+ // this class will operate as a service factory and give each
+ // service requestor it's own SaxParserFactory
+ SAXParserFactory factory = (SAXParserFactory) getFactory(parserFactoryClassName);
+ Hashtable properties = new Hashtable(7);
+ // figure out the default properties of the parser
+ setDefaultSAXProperties(factory, properties, index);
+ // store the parser factory class name in the properties so that
+ // it can be retrieved when getService is called
+ // to return a parser factory
+ properties.put(FACTORYNAMEKEY, parserFactoryClassName);
+ // release the factory
+ factory = null;
+ // register the factory as a service
+ context.registerService(SAXFACTORYNAME, this, properties);
+ index++;
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Set the SAX Parser Service Properties. By default, the following
+ * properties are set:
+ * <ul>
+ * <li><code>SERVICE_DESCRIPTION</code>
+ * <li><code>SERVICE_PID</code>
+ * <li><code>PARSER_VALIDATING</code>- instantiates a parser and queries
+ * it to find out whether it is validating or not
+ * <li><code>PARSER_NAMESPACEAWARE</code>- instantiates a parser and
+ * queries it to find out whether it is namespace aware or not
+ * <ul>
+ *
+ * @param factory The <code>SAXParserFactory</code> object
+ * @param props <code>Hashtable</code> of service properties.
+ */
+ private void setDefaultSAXProperties(SAXParserFactory factory,
+ Hashtable props, int index) {
+ props.put(Constants.SERVICE_DESCRIPTION, SAXFACTORYDESCRIPTION);
+ props.put(Constants.SERVICE_PID, SAXFACTORYNAME + "."
+ + context.getBundle().getBundleId() + "." + index);
+ setSAXProperties(factory, props);
+ }
+
+ /**
+ * <p>
+ * Set the customizable SAX Parser Service Properties.
+ *
+ * <p>
+ * This method attempts to instantiate a validating parser and a
+ * namespaceaware parser to determine if the parser can support those
+ * features. The appropriate properties are then set in the specified
+ * properties object.
+ *
+ * <p>
+ * This method can be overridden to add additional SAX2 features and
+ * properties. If you want to be able to filter searches of the OSGi service
+ * registry, this method must put a key, value pair into the properties
+ * object for each feature or property. For example,
+ *
+ * properties.put("http://www.acme.com/features/foo", Boolean.TRUE);
+ *
+ * @param factory - the SAXParserFactory object
+ * @param properties - the properties object for the service
+ */
+ public void setSAXProperties(SAXParserFactory factory, Hashtable properties) {
+ // 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;
+ }
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ // set the OSGi service properties
+ properties.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ properties.put(PARSER_VALIDATING, new Boolean(validating));
+ }
+
+ /**
+ * Register DOM Parser Factory Services with the framework.
+ *
+ * @param parserFactoryClassNames - a <code>Vector</code> of
+ * <code>String</code> objects containing the names of the parser
+ * Factory Classes
+ * @throws FactoryConfigurationError if thrown from <code>getFactory</code>
+ */
+ private void registerDOMParsers(Vector parserFactoryClassNames)
+ throws FactoryConfigurationError {
+ if (parserFactoryClassNames != null) {
+ Enumeration e = parserFactoryClassNames.elements();
+ int index = 0;
+ while (e.hasMoreElements()) {
+ String parserFactoryClassName = (String) e.nextElement();
+ // create a dom parser factory just to get it's default
+ // properties. It will never be used since
+ // this class will operate as a service factory and give each
+ // service requestor it's own DocumentBuilderFactory
+ DocumentBuilderFactory factory = (DocumentBuilderFactory) getFactory(parserFactoryClassName);
+ Hashtable properties = new Hashtable(7);
+ // figure out the default properties of the parser
+ setDefaultDOMProperties(factory, properties, index);
+ // store the parser factory class name in the properties so that
+ // it can be retrieved when getService is called
+ // to return a parser factory
+ properties.put(FACTORYNAMEKEY, parserFactoryClassName);
+ // release the factory
+ factory = null;
+ // register the factory as a service
+ context.registerService(DOMFACTORYNAME, this, properties);
+ index++;
+ }
+ }
+ }
+
+ /**
+ * Set the DOM parser service properties.
+ *
+ * By default, the following properties are set:
+ * <ul>
+ * <li><code>SERVICE_DESCRIPTION</code>
+ * <li><code>SERVICE_PID</code>
+ * <li><code>PARSER_VALIDATING</code>
+ * <li><code>PARSER_NAMESPACEAWARE</code>
+ * <ul>
+ *
+ * @param factory The <code>DocumentBuilderFactory</code> object
+ * @param props <code>Hashtable</code> of service properties.
+ */
+ private void setDefaultDOMProperties(DocumentBuilderFactory factory,
+ Hashtable props, int index) {
+ props.put(Constants.SERVICE_DESCRIPTION, DOMFACTORYDESCRIPTION);
+ props.put(Constants.SERVICE_PID, DOMFACTORYNAME + "."
+ + context.getBundle().getBundleId() + "." + index);
+ setDOMProperties(factory, props);
+ }
+
+ /**
+ * <p>
+ * Set the customizable DOM Parser Service Properties.
+ *
+ * <p>
+ * This method attempts to instantiate a validating parser and a
+ * namespaceaware parser to determine if the parser can support those
+ * features. The appropriate properties are then set in the specified props
+ * object.
+ *
+ * <p>
+ * This method can be overridden to add additional DOM2 features and
+ * properties. If you want to be able to filter searches of the OSGi service
+ * registry, this method must put a key, value pair into the properties
+ * object for each feature or property. For example,
+ *
+ * properties.put("http://www.acme.com/features/foo", Boolean.TRUE);
+ *
+ * @param factory - the DocumentBuilderFactory object
+ * @param props - Hashtable of service properties.
+ */
+ 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;
+ }
+ // set the factory values
+ factory.setValidating(validating);
+ factory.setNamespaceAware(namespaceaware);
+ // set the OSGi service properties
+ props.put(PARSER_VALIDATING, new Boolean(validating));
+ props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
+ }
+
+ /**
+ * Given a parser factory class name, instantiate that class.
+ *
+ * @param parserFactoryClassName A <code>String</code> object containing
+ * the name of the parser factory class
+ * @return a parserFactoryClass Object
+ * @pre parserFactoryClassName!=null
+ */
+ private Object getFactory(String parserFactoryClassName)
+ throws FactoryConfigurationError {
+ Exception e = null;
+ try {
+ return Class.forName(parserFactoryClassName).newInstance();
+ }
+ catch (ClassNotFoundException cnfe) {
+ e = cnfe;
+ }
+ catch (InstantiationException ie) {
+ e = ie;
+ }
+ catch (IllegalAccessException iae) {
+ e = iae;
+ }
+ throw new FactoryConfigurationError(e);
+ }
+
+ /**
+ * Creates a new XML Parser Factory object.
+ *
+ * <p>
+ * A unique XML Parser Factory object is returned for each call to this
+ * method.
+ *
+ * <p>
+ * The returned XML Parser Factory object will be configured for validating
+ * and namespace aware support as specified in the service properties of the
+ * specified ServiceRegistration object.
+ *
+ * This method can be overridden to configure additional features in the
+ * returned XML Parser Factory object.
+ *
+ * @param bundle The bundle using the service.
+ * @param registration The <code>ServiceRegistration</code> object for the
+ * service.
+ * @return A new, configured XML Parser Factory object or null if a
+ * configuration error was encountered
+ */
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ ServiceReference sref = registration.getReference();
+ String parserFactoryClassName = (String) sref
+ .getProperty(FACTORYNAMEKEY);
+ try {
+ // need to set factory properties
+ Object factory = getFactory(parserFactoryClassName);
+ if (factory instanceof SAXParserFactory) {
+ ((SAXParserFactory) factory).setValidating(((Boolean) sref
+ .getProperty(PARSER_VALIDATING)).booleanValue());
+ ((SAXParserFactory) factory).setNamespaceAware(((Boolean) sref
+ .getProperty(PARSER_NAMESPACEAWARE)).booleanValue());
+ }
+ else
+ if (factory instanceof DocumentBuilderFactory) {
+ ((DocumentBuilderFactory) factory)
+ .setValidating(((Boolean) sref
+ .getProperty(PARSER_VALIDATING))
+ .booleanValue());
+ ((DocumentBuilderFactory) factory)
+ .setNamespaceAware(((Boolean) sref
+ .getProperty(PARSER_NAMESPACEAWARE))
+ .booleanValue());
+ }
+ return factory;
+ }
+ catch (FactoryConfigurationError fce) {
+ fce.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Releases a XML Parser Factory object.
+ *
+ * @param bundle The bundle releasing the service.
+ * @param registration The <code>ServiceRegistration</code> object for the
+ * service.
+ * @param service The XML Parser Factory object returned by a previous call
+ * to the <code>getService</code> method.
+ */
+ public void ungetService(Bundle bundle, ServiceRegistration registration,
+ Object service) {
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/.classpath 2009-07-21 14:48:51 UTC (rev 91496)
@@ -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 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
@@ -103,6 +103,7 @@
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/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 13:54:45 UTC (rev 91495)
+++ 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)
@@ -122,8 +122,8 @@
log.debug("MicrocontainerServiceMBean registered");
// Register the DOM/SAX factories
- XMLParserActivatorExt parserActivator = new XMLParserActivatorExt();
- parserActivator.start(context);
+ //XMLParserActivatorExt parserActivator = new XMLParserActivatorExt();
+ //parserActivator.start(context);
}
void stop()
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/resources/jboss-beans-felix.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/resources/jboss-beans-felix.xml 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/resources/jboss-beans-felix.xml 2009-07-21 14:48:51 UTC (rev 91496)
@@ -39,6 +39,7 @@
org.jboss.osgi.spi.service;version=1.0,
org.jboss.osgi.spi.testing;version=1.0,
org.jboss.osgi.spi.util;version=1.0,
+ org.jboss.osgi.xml;version=1.0,
<!-- jboss -->
org.jboss.beans.metadata.plugins;version=2.0,
Property changes on: projects/jboss-osgi/trunk/reactor
___________________________________________________________________
Name: svn:externals
- #spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
#bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
+ #spi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk
bundles/apache-xerces https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/common https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/hotdeploy https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/husky https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jaxb https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jmx https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jndi https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-common-core https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/jboss-xml-binding https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
bundles/microcontainer https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/remotelog https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#bundles/webconsole https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/bundles/...
#runtime/deployers https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/equinox https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/felix https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
runtime/jbossas https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
#runtime/knopflerfish https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/...
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
@@ -79,6 +79,13 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<!-- Build -->
Modified: projects/jboss-osgi/trunk/reactor/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/reactor/pom.xml 2009-07-21 14:48:51 UTC (rev 91496)
@@ -27,6 +27,9 @@
</parent>
<modules>
+ <module>bundles/apache-xerces</module>
+ <module>bundles/microcontainer</module>
+ <module>runtime/jbossas</module>
<module>blueprint</module>
</modules>
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointService.java 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointService.java 2009-07-21 14:48:51 UTC (rev 91496)
@@ -1,102 +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.test.osgi.example.http.bundle;
-
-//$Id: EndpointService.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
-
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.service.http.HttpService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A service that creates an Http context through the HttpService
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public class EndpointService implements ServiceListener
-{
- private BundleContext context;
-
- public EndpointService(BundleContext context)
- {
- this.context = context;
- context.addServiceListener(this);
- }
-
- private void registerService()
- {
- try
- {
- HttpService httpService = getHttpService();
-
- Properties initParams = new Properties();
- initParams.setProperty("initProp", "SomeValue");
- httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
- httpService.registerResources("/file", "/res", null);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot register context", ex);
- }
- }
-
- private void unregisterService()
- {
- HttpService httpService = getHttpService();
- httpService.unregister("/servlet");
- httpService.unregister("/file");
- context.removeServiceListener(this);
- }
-
- private HttpService getHttpService()
- {
- ServiceTracker tracker = new ServiceTracker(context, HttpService.class.getName(), null);
- tracker.open();
-
- HttpService service = (HttpService)tracker.getService();
- if (service == null)
- throw new IllegalStateException("HttpService not registered");
-
- return service;
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- Object service = context.getService(event.getServiceReference());
- if (service == this)
- {
- if (event.getType() == ServiceEvent.REGISTERED)
- {
- registerService();
- }
- else if (event.getType() == ServiceEvent.UNREGISTERING)
- {
- unregisterService();
- }
- }
- }
-}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java 2009-07-21 14:48:51 UTC (rev 91496)
@@ -23,8 +23,13 @@
//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
+import java.util.Properties;
+
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpService;
+import org.osgi.util.tracker.ServiceTracker;
/**
* A Service Activator
@@ -34,20 +39,57 @@
*/
public class HttpExampleActivator implements BundleActivator
{
- /*
- * Implements BundleActivator.start().
- * Registers an instance of a HttpEndpoint Service using the bundle context.
- */
- public void start(BundleContext context)
- {
- EndpointService service = new EndpointService(context);
- context.registerService(EndpointService.class.getName(), service, null);
- }
+ private ServiceTracker tracker;
+
+ public void start(BundleContext context)
+ {
+ tracker = new ServiceTracker(context, HttpService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ HttpService httpService = (HttpService)super.addingService(reference);
+ registerService(context, httpService);
+ return httpService;
+ }
- /*
- * Implements BundleActivator.stop().
- */
- public void stop(BundleContext context)
- {
- }
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ HttpService httpService = (HttpService)service;
+ unregisterService(context, httpService);
+ super.removedService(reference, service);
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ HttpService httpService = (HttpService)tracker.getService();
+ if (httpService != null)
+ unregisterService(context, httpService);
+ }
+
+ private void registerService(BundleContext context, HttpService httpService)
+ {
+ try
+ {
+ Properties initParams = new Properties();
+ initParams.setProperty("initProp", "SomeValue");
+ httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
+ httpService.registerResources("/file", "/res", null);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot register context", ex);
+ }
+ }
+
+ private void unregisterService(BundleContext context, HttpService httpService)
+ {
+ httpService.unregister("/servlet");
+ httpService.unregister("/file");
+ }
+
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jaxb/example-xml-jaxb.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jaxb/example-xml-jaxb.bnd 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jaxb/example-xml-jaxb.bnd 2009-07-21 14:48:51 UTC (rev 91496)
@@ -6,7 +6,7 @@
Export-Package: org.jboss.test.osgi.example.xml.jaxb
Import-Package: com.sun.xml.bind.v2, javax.xml.bind*, javax.xml.datatype, javax.xml.namespace, \
- org.jboss.osgi.husky*, org.jboss.osgi.jaxb, org.jboss.osgi.spi*, org.junit, org.osgi.framework
+ org.jboss.osgi.husky*, org.jboss.osgi.jaxb, org.jboss.osgi.spi.*, org.junit, org.osgi.framework
Include-Resource: booking.xml, booking.xsd
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/parser/example-xml-parser.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/parser/example-xml-parser.bnd 2009-07-21 13:54:45 UTC (rev 91495)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/parser/example-xml-parser.bnd 2009-07-21 14:48:51 UTC (rev 91496)
@@ -4,6 +4,11 @@
# Export the package that contains the test case
Export-Package: org.jboss.test.osgi.example.xml.parser
+
+Import-Package: javax.xml.parsers, org.jboss.osgi.*, org.jboss.osgi.spi.*, org.jboss.osgi.xml, \
+ org.junit, org.osgi.framework, org.w3c.dom*, org.xml.sax*
+
+
Include-Resource: example-xml-parser.xml
# Tell Husky that there are test cases in this package
14 years, 10 months