Search in sources :

Example 1 with BeanDefinitionParserDelegate

use of org.springframework.beans.factory.xml.BeanDefinitionParserDelegate in project grails-core by grails.

the class BeanBuilder method createDynamicElementReader.

protected DynamicElementReader createDynamicElementReader(String namespace, final boolean decorator) {
    NamespaceHandler handler = namespaceHandlers.get(namespace);
    ParserContext parserContext = new ParserContext(readerContext, new BeanDefinitionParserDelegate(readerContext));
    final DynamicElementReader dynamicElementReader = new DynamicElementReader(namespace, namespaces, handler, parserContext) {

        @Override
        protected void afterInvocation() {
            if (!decorator) {
                currentBeanConfig = null;
            }
        }
    };
    dynamicElementReader.setClassLoader(classLoader);
    if (currentBeanConfig != null) {
        dynamicElementReader.setBeanConfiguration(currentBeanConfig);
    } else if (!decorator) {
        currentBeanConfig = new DefaultBeanConfiguration(namespace);
        dynamicElementReader.setBeanConfiguration(currentBeanConfig);
    }
    dynamicElementReader.setBeanDecorator(decorator);
    return dynamicElementReader;
}
Also used : DefaultBeanConfiguration(org.grails.spring.DefaultBeanConfiguration) BeanDefinitionParserDelegate(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate) NamespaceHandler(org.springframework.beans.factory.xml.NamespaceHandler) ParserContext(org.springframework.beans.factory.xml.ParserContext)

Example 2 with BeanDefinitionParserDelegate

use of org.springframework.beans.factory.xml.BeanDefinitionParserDelegate in project aries by apache.

the class BlueprintNamespaceHandler method createSpringParserContext.

private org.springframework.beans.factory.xml.ParserContext createSpringParserContext(ParserContext parserContext, DefaultListableBeanFactory registry) {
    try {
        XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(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);
        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);
    }
}
Also used : EmptyReaderEventListener(org.springframework.beans.factory.parsing.EmptyReaderEventListener) ProblemReporter(org.springframework.beans.factory.parsing.ProblemReporter) FailFastProblemReporter(org.springframework.beans.factory.parsing.FailFastProblemReporter) NamespaceHandlerResolver(org.springframework.beans.factory.xml.NamespaceHandlerResolver) BeanDefinitionParserDelegate(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) UrlResource(org.springframework.core.io.UrlResource) Resource(org.springframework.core.io.Resource) ReaderEventListener(org.springframework.beans.factory.parsing.ReaderEventListener) EmptyReaderEventListener(org.springframework.beans.factory.parsing.EmptyReaderEventListener) XmlReaderContext(org.springframework.beans.factory.xml.XmlReaderContext) FailFastProblemReporter(org.springframework.beans.factory.parsing.FailFastProblemReporter) UrlResource(org.springframework.core.io.UrlResource) ParserContext(org.apache.aries.blueprint.ParserContext) NullSourceExtractor(org.springframework.beans.factory.parsing.NullSourceExtractor) SourceExtractor(org.springframework.beans.factory.parsing.SourceExtractor) NullSourceExtractor(org.springframework.beans.factory.parsing.NullSourceExtractor)

Example 3 with BeanDefinitionParserDelegate

use of org.springframework.beans.factory.xml.BeanDefinitionParserDelegate in project spring-framework by spring-projects.

the class GroovyBeanDefinitionReader method createDynamicElementReader.

private GroovyDynamicElementReader createDynamicElementReader(String namespace) {
    XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource("Groovy"));
    BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext);
    boolean decorating = (this.currentBeanDefinition != null);
    if (!decorating) {
        this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace);
    }
    return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) {

        @Override
        protected void afterInvocation() {
            if (!this.decorating) {
                currentBeanDefinition = null;
            }
        }
    };
}
Also used : BeanDefinitionParserDelegate(org.springframework.beans.factory.xml.BeanDefinitionParserDelegate) XmlReaderContext(org.springframework.beans.factory.xml.XmlReaderContext) DescriptiveResource(org.springframework.core.io.DescriptiveResource)

Aggregations

BeanDefinitionParserDelegate (org.springframework.beans.factory.xml.BeanDefinitionParserDelegate)3 XmlReaderContext (org.springframework.beans.factory.xml.XmlReaderContext)2 ParserContext (org.apache.aries.blueprint.ParserContext)1 DefaultBeanConfiguration (org.grails.spring.DefaultBeanConfiguration)1 EmptyReaderEventListener (org.springframework.beans.factory.parsing.EmptyReaderEventListener)1 FailFastProblemReporter (org.springframework.beans.factory.parsing.FailFastProblemReporter)1 NullSourceExtractor (org.springframework.beans.factory.parsing.NullSourceExtractor)1 ProblemReporter (org.springframework.beans.factory.parsing.ProblemReporter)1 ReaderEventListener (org.springframework.beans.factory.parsing.ReaderEventListener)1 SourceExtractor (org.springframework.beans.factory.parsing.SourceExtractor)1 NamespaceHandler (org.springframework.beans.factory.xml.NamespaceHandler)1 NamespaceHandlerResolver (org.springframework.beans.factory.xml.NamespaceHandlerResolver)1 ParserContext (org.springframework.beans.factory.xml.ParserContext)1 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)1 DescriptiveResource (org.springframework.core.io.DescriptiveResource)1 Resource (org.springframework.core.io.Resource)1 UrlResource (org.springframework.core.io.UrlResource)1