> * if it is safe to use "SAXParserFactory.newInstance();" static method call > or are there any reasons not to use it
This method will use reflection to try to find and load an instance of SAXParserFactory. If you have one built into your Java runtime then this will be found because the classes are visible to everyone. If you want to add an implementation into your OSGi framework then it won’t work because the bundle class loader is not visible to the SAX API. This is a general issue in a modular environment, where the implementation packages are supposed to be hidden. OSGi solves it with Services, JPMS uses the “provides with” stanza in the module-info. Best Regards, Tim > On 18 Sep 2018, at 22:22, Markus Rathgeb <maggu2...@gmail.com> wrote: > > Hi Tim, hi JB, > > sorry for not being clear enough... > > As written in my initial post / mail the call to > "SAXParserFactory.newInstance();" works for me as expected. > > After reading > https://osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html > <https://osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html> I > just want to know > > * if anyone knows about a bundle that provides a SAXParserFactory OSGi > service (as the specification exist for a long time my assumption has been > that there exist already bundles that expose the SAXParserFactory as an OSGi > service) and could point me to > > * if it is safe to use "SAXParserFactory.newInstance();" static method call > or are there any reasons not to use it > > * if "SAXParserFactory.newInstance();" works as expected in all the cases why > that specification at all > > > The last point "why that specification exist" leads me to the assumption that > it is perhaps better to rely on an OSGi service instead of that static method. > > If I had not read the document, I would not have questioned that static > method. > > Regards, > Markus