Knopflerfish OSGi 3.0.0

org.osgi.util.xml
Class XMLTransformerActivator

java.lang.Object
  extended by org.osgi.util.xml.XMLTransformerActivator
All Implemented Interfaces:
BundleActivator, ServiceFactory

public class XMLTransformerActivator
extends java.lang.Object
implements BundleActivator, ServiceFactory

A BundleActivator class that allows any JAXP compliant XML Transformer to register itself as an OSGi parser service. Multiple JAXP compliant transformers can concurrently register by using this BundleActivator class. Bundles who wish to use an XML transformer can then use the framework's service registry to locate available XML transformers with the desired characteristics.

The services that this bundle activator enables a bundle to provide are:

The algorithm to find the implementations of the abstract transformer is derived from the JAR file specifications, specifically the Services API.

A TransformerFactory creator assumes that it can find the class file names of available factory classes in the file:

An XPathFactory creator assumes that it can find the class file names of available factory classes in the file:

XMLTransformerActivator attempts to instantiate both the TransformerFactory and the XPathFactory. It registers each factory with the framework.


Field Summary
static java.lang.String TRANSFORMERCLASSFILE
          Fully qualified path name of TransofrmerFactory Class Name file
static java.lang.String TRANSFORMERFACOTRYDESCR
           
static java.lang.String TRANSFORMERFACTORYNAME
          Filename containing the TransformerFactory class name.
static java.lang.String XPATHCLASSFILE
          Fully qualified path name of the XPath Factory Class Name file
static java.lang.String XPATHFACOTRYDESCR
           
static java.lang.String XPATHFACTORYNAME
          Filename containing the XPathFactory class name.
 
Constructor Summary
XMLTransformerActivator()
           
 
Method Summary
 java.lang.Object getService(Bundle bundle, ServiceRegistration registration)
          Creates a new Transformer / XPath Factory object.
 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, java.lang.Object service)
          Releases a Factory object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSFORMERFACTORYNAME

public static final java.lang.String TRANSFORMERFACTORYNAME
Filename containing the TransformerFactory class name. Also used as the basis for the SERVICE_PID registration property.

See Also:
Constant Field Values

TRANSFORMERFACOTRYDESCR

public static final java.lang.String TRANSFORMERFACOTRYDESCR
See Also:
Constant Field Values

XPATHFACTORYNAME

public static final java.lang.String XPATHFACTORYNAME
Filename containing the XPathFactory class name. Also used as the basis for the SERVICE_PID registration property.

See Also:
Constant Field Values

XPATHFACOTRYDESCR

public static final java.lang.String XPATHFACOTRYDESCR
See Also:
Constant Field Values

TRANSFORMERCLASSFILE

public static final java.lang.String TRANSFORMERCLASSFILE
Fully qualified path name of TransofrmerFactory Class Name file

See Also:
Constant Field Values

XPATHCLASSFILE

public static final java.lang.String XPATHCLASSFILE
Fully qualified path name of the XPath Factory Class Name file

See Also:
Constant Field Values
Constructor Detail

XMLTransformerActivator

public XMLTransformerActivator()
Method Detail

start

public void start(BundleContext context)
           throws java.lang.Exception
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.

This method must complete and return to its caller in a timely manner.

This method attempts to register a SAX and DOM parser with the Framework's service registry.

Specified by:
start in interface BundleActivator
Parameters:
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.
See Also:
Bundle.start(int)

stop

public void stop(BundleContext context)
          throws java.lang.Exception

This method has nothing to do as all active service registrations will automatically get unregistered when the bundle stops.

Specified by:
stop in interface BundleActivator
Parameters:
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.
See Also:
Bundle.stop(int)

getService

public java.lang.Object getService(Bundle bundle,
                                   ServiceRegistration registration)
Creates a new Transformer / XPath Factory object.

A unique Factory object is returned for each call to this method.

Specified by:
getService in interface ServiceFactory
Parameters:
bundle - The bundle using the service.
registration - The ServiceRegistration object for the service.
Returns:
A new, Factory object or null if a configuration error was encountered.
See Also:
BundleContext.getService(org.osgi.framework.ServiceReference)

ungetService

public void ungetService(Bundle bundle,
                         ServiceRegistration registration,
                         java.lang.Object service)
Releases a Factory object.

Specified by:
ungetService in interface ServiceFactory
Parameters:
bundle - The bundle releasing the service.
registration - The ServiceRegistration object for the service.
service - The Factory object returned by a previous call to the getService method.
See Also:
BundleContext.ungetService(org.osgi.framework.ServiceReference)

Knopflerfish OSGi 3.0.0