use of org.springframework.beans.factory.xml.DelegatingEntityResolver in project mule by mulesoft.
the class XmlConfigurationDocumentLoader method loadDocument.
/**
* Creates a {@link Document} from an {@link InputStream} with the required configuration of a mule configuration file parsing.
*
* @param extensions if the current {@code inputStream} relies in other schemas pending to be loaded from an
* {@link ExtensionModel}, it will be picked up from {@code extensions} set
* @param filename name of the file to display a better error messages (if there are any). Non null.
* @param inputStream the input stream with the XML configuration content.
* @return a new {@link Document} object with the provided content.
* @throws MuleRuntimeException if an error occurs in {@link org.springframework.beans.factory.xml.DocumentLoader} factory, or
* if the current {@code filename} contains 1 or more errors.
* @see {@link DefaultXmlLoggerErrorHandler#getErrors()}
*/
public Document loadDocument(Set<ExtensionModel> extensions, String filename, InputStream inputStream) {
final XmlGathererErrorHandler errorHandler = createXmlGathererErrorHandler();
Document document;
try {
document = new MuleDocumentLoader().loadDocument(new InputSource(inputStream), validationMode == VALIDATION_XSD ? new ModuleDelegatingEntityResolver(extensions) : new DelegatingEntityResolver(currentThread().getContextClassLoader()), errorHandler == null ? new DefaultHandler() : errorHandler, validationMode, true);
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage(format("Error loading: %s, %s", filename, e.getMessage())), e);
}
if (validationMode == VALIDATION_XSD) {
throwExceptionIfErrorsWereFound(errorHandler, filename);
}
return document;
}
Aggregations