public ParsingService(boolean isSax) {
this.isSax = isSax;
}
public Object getService(Bundle bundle, ServiceRegistration<Object> registration) {
BundleHost host = (bundle instanceof BundleHost) ? (BundleHost) bundle : null;
if (!SET_TCCL_XMLFACTORY || bundle == null)
return createService();
/*
* Set the TCCL while creating jaxp factory instances to the
* requesting bundles class loader. This is needed to
* work around bug 285505. There are issues if multiple
* xerces implementations are available on the bundles class path
*
* The real issue is that the ContextFinder will only delegate
* to the framework class loader in this case. This class
* loader forces the requesting bundle to be delegated to for
* TCCL loads.
*/
final ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
try {
ClassLoader cl = host.getClassLoader();
if (cl != null)
Thread.currentThread().setContextClassLoader(cl);
return createService();
} finally {
Thread.currentThread().setContextClassLoader(savedClassLoader);