That's bad practice, since it forces the whole JVM hosting this code to use a particular XML component. This has already happened to conflict with web servers, both Jetty and Tomcat.
I'm already working on fixing the problem, by adopting this other approach:
newFactory( propName, loader ) takes the class to be used as factory from the property name parameter. By using an Ondex-specific property name for that, which is not the name that methods like newFactory() or newInstance() lookup by default, we can avoid to interfere with the rest of the JVM.
Note that direct instantiation of WstxInputFactory doesn't always work in a straightforward way, since some plugins/modules instantiate factories like this dynamically, without having a declared dependency on, in this case, the Woodstox library (they get it indirectly, from containers like OVTK2 or the workflow engine).
Possible improvement
Due to issues with dependency management in Ondex, I'm changing the existing code by duplicating lines like the ones above. Ideally, they should be factorised into a component provider, which would set the ondex.* properties once (upon class loading) and would return components like XMLInputFactory2, XMLOutputFactory2 etc.
A lot of Ondex code behaves like this:
That's bad practice, since it forces the whole JVM hosting this code to use a particular XML component. This has already happened to conflict with web servers, both Jetty and Tomcat.
I'm already working on fixing the problem, by adopting this other approach:
newFactory( propName, loader )
takes the class to be used as factory from the property name parameter. By using an Ondex-specific property name for that, which is not the name that methods likenewFactory()
ornewInstance()
lookup by default, we can avoid to interfere with the rest of the JVM.Note that direct instantiation of
WstxInputFactory
doesn't always work in a straightforward way, since some plugins/modules instantiate factories like this dynamically, without having a declared dependency on, in this case, the Woodstox library (they get it indirectly, from containers like OVTK2 or the workflow engine).Possible improvement
Due to issues with dependency management in Ondex, I'm changing the existing code by duplicating lines like the ones above. Ideally, they should be factorised into a component provider, which would set the
ondex.*
properties once (upon class loading) and would return components likeXMLInputFactory2
,XMLOutputFactory2
etc.