|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.osgi.util.xml.XMLParserActivator
public class XMLParserActivator
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:javax.xml.parsers.SAXParserFactory(SAXFACTORYNAME)
javax.xml.parsers.DocumentBuilderFactory(
DOMFACTORYNAME)
/META-INF/services/javax.xml.parsers.SAXParserFactory is a
file contained in a jar available to the runtime which contains the
implementation class name(s) of the SAXParserFactory.
/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
is a file contained in a jar available to the runtime which contains the
implementation class name(s) of the DocumentBuilderFactory
XMLParserActivator
assumes that the parser does not support that parser type.
XMLParserActivator attempts to instantiate both the
SAXParserFactory and the DocumentBuilderFactory. It
registers each factory with the framework along with service properties:
PARSER_VALIDATING- indicates if this factory supports validating
parsers. It's value is a Boolean.
PARSER_NAMESPACEAWARE- indicates if this factory supports
namespace aware parsers It's value is a Boolean.
setSAXProperties and setDOMProperties methods.
| Field Summary | |
|---|---|
static String |
DOMCLASSFILE
Fully qualified path name of DOM Parser Factory Class Name file |
static String |
DOMFACTORYNAME
Filename containing the DOM Parser Factory Class name. |
static String |
PARSER_NAMESPACEAWARE
Service property specifying if factory is configured to support namespace aware parsers. |
static String |
PARSER_VALIDATING
Service property specifying if factory is configured to support validating parsers. |
static String |
SAXCLASSFILE
Fully qualified path name of SAX Parser Factory Class Name file |
static String |
SAXFACTORYNAME
Filename containing the SAX Parser Factory Class name. |
| Constructor Summary | |
|---|---|
XMLParserActivator()
|
|
| Method Summary | |
|---|---|
protected URL |
getResourceURL(Bundle parserBundle,
String resname)
|
Object |
getService(Bundle bundle,
ServiceRegistration registration)
Creates a new XML Parser Factory object. |
void |
setDOMProperties(DocumentBuilderFactory factory,
Hashtable props)
Set the customizable DOM Parser Service Properties. |
void |
setSAXProperties(SAXParserFactory factory,
Hashtable properties)
Set the customizable SAX Parser Service Properties. |
void |
start(BundleContext context)
Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start this bundle. |
void |
stop(BundleContext context)
This method has nothing to do as all active service registrations will automatically get unregistered when the bundle stops. |
void |
ungetService(Bundle bundle,
ServiceRegistration registration,
Object service)
Releases a XML Parser Factory object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SAXFACTORYNAME
SERVICE_PID registration property.
- See Also:
- Constant Field Values
public static final String DOMFACTORYNAME
SERVICE_PID registration property.
public static final String SAXCLASSFILE
public static final String DOMCLASSFILE
public static final String PARSER_VALIDATING
Boolean.
public static final String PARSER_NAMESPACEAWARE
Boolean.
| Constructor Detail |
|---|
public XMLParserActivator()
| Method Detail |
|---|
public void start(BundleContext context)
throws Exception
start in interface BundleActivatorcontext - The execution context of the bundle being started.
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.
protected URL getResourceURL(Bundle parserBundle,
String resname)
public void stop(BundleContext context)
throws Exception
stop in interface BundleActivatorcontext - The execution context of the bundle being stopped.
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 setSAXProperties(SAXParserFactory factory,
Hashtable properties)
factory - - the SAXParserFactory objectproperties - - the properties object for the service
public void setDOMProperties(DocumentBuilderFactory factory,
Hashtable props)
factory - - the DocumentBuilderFactory objectprops - - Hashtable of service properties.
public Object getService(Bundle bundle,
ServiceRegistration registration)
getService in interface ServiceFactorybundle - The bundle using the service.registration - The ServiceRegistration object for the
service.
public void ungetService(Bundle bundle,
ServiceRegistration registration,
Object service)
ungetService in interface ServiceFactorybundle - The bundle releasing the service.registration - The ServiceRegistration object for the
service.service - The XML Parser Factory object returned by a previous call
to the getService method.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||