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.
The services that this bundle activator enables a bundle to provide are:
- {@code javax.xml.parsers.SAXParserFactory}( {@link #SAXFACTORYNAME})
- {@code javax.xml.parsers.DocumentBuilderFactory}( {@link #DOMFACTORYNAME})
The algorithm to find the implementations of the abstract parsers is derived from the JAR file specifications, specifically the Services API.
An XMLParserActivator assumes that it can find the class file names of the factory classes in the following files:
- {@code /META-INF/services/javax.xml.parsers.SAXParserFactory} is a filecontained in a jar available to the runtime which contains the implementation class name(s) of the SAXParserFactory.
- {@code /META-INF/services/javax.xml.parsers.DocumentBuilderFactory} is afile contained in a jar available to the runtime which contains the implementation class name(s) of the {@code DocumentBuilderFactory}
If either of the files does not exist, {@code XMLParserActivator} assumesthat the parser does not support that parser type.
{@code XMLParserActivator} attempts to instantiate both the{@code SAXParserFactory} and the {@code DocumentBuilderFactory}. It registers each factory with the framework along with service properties:
- {@link #PARSER_VALIDATING}- indicates if this factory supports validating parsers. It's value is a {@code Boolean}.
- {@link #PARSER_NAMESPACEAWARE}- indicates if this factory supports namespace aware parsers It's value is a {@code Boolean}.
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}and {@code setDOMProperties} methods.
@ThreadSafe
@author $Id: c73b3c06188fd8154bea38524e1ee7a15c5ac836 $