use of org.springframework.beans.factory.parsing.NullSourceExtractor in project aries by apache.
the class BlueprintNamespaceHandler method createSpringParserContext.
private org.springframework.beans.factory.xml.ParserContext createSpringParserContext(final ParserContext parserContext, DefaultListableBeanFactory registry) {
try {
SpringVersionBridgeXmlBeanDefinitionReader xbdr = new SpringVersionBridgeXmlBeanDefinitionReader(registry);
Resource resource = new UrlResource(parserContext.getSourceNode().getOwnerDocument().getDocumentURI());
ProblemReporter problemReporter = new FailFastProblemReporter();
ReaderEventListener listener = new EmptyReaderEventListener();
SourceExtractor extractor = new NullSourceExtractor();
NamespaceHandlerResolver resolver = new SpringNamespaceHandlerResolver(parserContext);
xbdr.setProblemReporter(problemReporter);
xbdr.setEventListener(listener);
xbdr.setSourceExtractor(extractor);
xbdr.setNamespaceHandlerResolver(resolver);
xbdr.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws IOException {
for (URI ns : parserContext.getNamespaces()) {
NamespaceHandler nh = parserContext.getNamespaceHandler(ns);
URL url = null;
if (publicId != null) {
url = nh.getSchemaLocation(publicId);
}
if (url == null && systemId != null) {
url = nh.getSchemaLocation(systemId);
}
if (url != null) {
InputSource is = new InputSource();
is.setPublicId(publicId);
is.setSystemId(systemId);
is.setByteStream(url.openStream());
return is;
}
}
return null;
}
});
XmlReaderContext xmlReaderContext = xbdr.createReaderContext(resource);
BeanDefinitionParserDelegate bdpd = new BeanDefinitionParserDelegate(xmlReaderContext);
return new org.springframework.beans.factory.xml.ParserContext(xmlReaderContext, bdpd);
} catch (Exception e) {
throw new RuntimeException("Error creating spring parser context", e);
}
}
use of org.springframework.beans.factory.parsing.NullSourceExtractor in project grails-core by grails.
the class BeanBuilder method initializeBeanBuilderForClassLoader.
protected void initializeBeanBuilderForClassLoader(ClassLoader classLoader) {
xmlBeanDefinitionReader.setBeanClassLoader(classLoader);
namespaceHandlerResolver = new DefaultNamespaceHandlerResolver(this.classLoader);
readerContext = new XmlReaderContext(beanBuildResource, new FailFastProblemReporter(), new EmptyReaderEventListener(), new NullSourceExtractor(), xmlBeanDefinitionReader, namespaceHandlerResolver);
}
Aggregations