Hi,

One of my bundle needs to parse XML and I am using javax.xml.parsers.DocumentBuilderFactory to parse the XML. I would like to retrieve the DocumentBuilderFactory from the platform instead of instantiating my own instances. When I tried to retrieve the service as shown below I get null instance. if I remember correctly, I have used this service in the 2.2.x version of Karaf. However, I am not sure if I had installed some features specif to this service.

ServiceTracker serviceTracker = new ServiceTracker(context, DocumentBuilderFactory.class.getName(), null);
serviceTracker.open();
DocumentBuilderFactory factory = (DocumentBuilderFactory) serviceTracker.getService();

My question is is DocumentBuilderFactory service is provided by framework? If not what is the best way to parse/process XML in Karaf.

Regards,

Raj

Reply via email to