package org.hibernate.internal.util.xml;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.dom4j.DocumentFactory;
import org.dom4j.io.SAXReader;
import org.xml.sax.EntityResolver;
@Deprecated
public final class XMLHelper {
private final DocumentFactory documentFactory;
public XMLHelper(ClassLoaderService classLoaderService) {
this.documentFactory = classLoaderService.workWithClassLoader(
new ClassLoaderService.Work<DocumentFactory>() {
@Override
public DocumentFactory doWork(ClassLoader classLoader) {
final ClassLoader originalTccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader( classLoader );
return DocumentFactory.getInstance();
}
finally {
Thread.currentThread().setContextClassLoader( originalTccl );
}
}
}
);
}
public DocumentFactory getDocumentFactory() {
return documentFactory;
}
public SAXReader createSAXReader(ErrorLogger errorLogger, EntityResolver entityResolver) {
SAXReader saxReader = new SAXReader();
saxReader.setMergeAdjacentText( true );
saxReader.setValidation( true );
saxReader.setErrorHandler( errorLogger );
saxReader.setEntityResolver( entityResolver );
return saxReader;
}
}