Java 类org.springframework.beans.factory.xml.XmlReaderContext 实例源码

项目:lams    文件:ScriptBeanDefinitionParser.java   
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
    boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
    if (hasScriptSource && !elements.isEmpty()) {
        readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
        return null;
    }
    else if (hasScriptSource) {
        return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    }
    else if (!elements.isEmpty()) {
        Element inlineElement = elements.get(0);
        return "inline:" + DomUtils.getTextValue(inlineElement);
    }
    else {
        readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
        return null;
    }
}
项目:lams    文件:ComponentScanBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    boolean annotationConfig = true;
    if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
        annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
    }
    if (annotationConfig) {
        Set<BeanDefinitionHolder> processorDefinitions =
                AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
        for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
            compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
        }
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:lams    文件:GroovyBeanDefinitionReader.java   
private GroovyDynamicElementReader createDynamicElementReader(String namespace) {
    XmlReaderContext readerContext = this.xmlBeanDefinitionReader.createReaderContext(new DescriptiveResource("Groovy"));
    BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext, getEnvironment());
    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;
            }
        }
    };
}
项目:spring4-understanding    文件:ScriptBeanDefinitionParser.java   
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
    boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
    if (hasScriptSource && !elements.isEmpty()) {
        readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
        return null;
    }
    else if (hasScriptSource) {
        return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    }
    else if (!elements.isEmpty()) {
        Element inlineElement = elements.get(0);
        return "inline:" + DomUtils.getTextValue(inlineElement);
    }
    else {
        readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
        return null;
    }
}
项目:spring4-understanding    文件:ComponentScanBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    boolean annotationConfig = true;
    if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
        annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
    }
    if (annotationConfig) {
        Set<BeanDefinitionHolder> processorDefinitions =
                AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
        for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
            compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
        }
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:spring4-understanding    文件:GroovyBeanDefinitionReader.java   
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;
            }
        }
    };
}
项目:my-spring-cache-redis    文件:ScriptBeanDefinitionParser.java   
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
    boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
    if (hasScriptSource && !elements.isEmpty()) {
        readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
        return null;
    }
    else if (hasScriptSource) {
        return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    }
    else if (!elements.isEmpty()) {
        Element inlineElement = elements.get(0);
        return "inline:" + DomUtils.getTextValue(inlineElement);
    }
    else {
        readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
        return null;
    }
}
项目:my-spring-cache-redis    文件:ComponentScanBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    boolean annotationConfig = true;
    if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
        annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
    }
    if (annotationConfig) {
        Set<BeanDefinitionHolder> processorDefinitions =
                AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
        for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
            compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
        }
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:spring    文件:ScriptBeanDefinitionParser.java   
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
    boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
    if (hasScriptSource && !elements.isEmpty()) {
        readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
        return null;
    }
    else if (hasScriptSource) {
        return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    }
    else if (!elements.isEmpty()) {
        Element inlineElement = elements.get(0);
        return "inline:" + DomUtils.getTextValue(inlineElement);
    }
    else {
        readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
        return null;
    }
}
项目:spring    文件:ComponentScanBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    boolean annotationConfig = true;
    if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
        annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
    }
    if (annotationConfig) {
        Set<BeanDefinitionHolder> processorDefinitions =
                AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
        for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
            compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
        }
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:spring    文件:GroovyBeanDefinitionReader.java   
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;
            }
        }
    };
}
项目:dubbo-lite    文件:AutoBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    Set<BeanDefinitionHolder> processorDefinitions =
            AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
    for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:class-guard    文件:ScriptBeanDefinitionParser.java   
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
    boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    List elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
    if (hasScriptSource && !elements.isEmpty()) {
        readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
        return null;
    }
    else if (hasScriptSource) {
        return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
    }
    else if (!elements.isEmpty()) {
        Element inlineElement = (Element) elements.get(0);
        return "inline:" + DomUtils.getTextValue(inlineElement);
    }
    else {
        readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
        return null;
    }
}
项目:class-guard    文件:ComponentScanBeanDefinitionParser.java   
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    boolean annotationConfig = true;
    if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
        annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
    }
    if (annotationConfig) {
        Set<BeanDefinitionHolder> processorDefinitions =
                AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
        for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
            compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
        }
    }

    readerContext.fireComponentRegistered(compositeDef);
}
项目:alfresco-data-model    文件:NoAutoStartClassPathXmlApplicationContext.java   
@Override
protected BeanDefinitionParserDelegate createHelper(
      XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
   BeanDefinitionParserDelegate delegate = new NoAutoStartBeanDefinitionParserDelegate(readerContext);
   delegate.initDefaults(root);
   return delegate;
}
项目:alfresco-data-model    文件:LazyClassPathXmlApplicationContext.java   
@Override
protected BeanDefinitionParserDelegate createHelper(
      XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
   BeanDefinitionParserDelegate helper = super.createHelper(readerContext, root, parentDelegate);
   helper.getDefaults().setLazyInit("true");
   return helper;
}
项目:spring4-understanding    文件:AspectJNamespaceHandlerTests.java   
@Before
public void setUp() throws Exception {
    SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
    XmlReaderContext readerContext =
            new XmlReaderContext(null, null, this.readerEventListener, sourceExtractor, reader, null);
    this.parserContext = new ParserContext(readerContext, null);
}
项目:leopard    文件:ComponentScanBeanDefinitionParser.java   
@Override
protected void registerComponents(XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {
    super.registerComponents(readerContext, beanDefinitions, element);
    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        String beanName = beanDefHolder.getBeanName();
        // TODO ahai 未规范实现
        if (beanName.endsWith("Timer")) {
            timerList.add(beanName);
        }
    }
}
项目:dubbo-lite    文件:DubboClassPathBeanDefinitionScanner.java   
public DubboClassPathBeanDefinitionScanner(ParserContext parserContext) {
    super(parserContext.getRegistry(), false);
    XmlReaderContext readerContext = parserContext.getReaderContext();
    setResourceLoader(readerContext.getResourceLoader());
    setEnvironment(parserContext.getDelegate().getEnvironment());
    setBeanDefinitionDefaults(parserContext.getDelegate().getBeanDefinitionDefaults());
    setAutowireCandidatePatterns(parserContext.getDelegate().getAutowireCandidatePatterns());
    addIncludeFilter(new AnnotationTypeFilter(Provider.class));
}
项目:community-edition-old    文件:NoAutoStartClassPathXmlApplicationContext.java   
@Override
protected BeanDefinitionParserDelegate createHelper(
      XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
   BeanDefinitionParserDelegate delegate = new NoAutoStartBeanDefinitionParserDelegate(readerContext);
   delegate.initDefaults(root);
   return delegate;
}
项目:community-edition-old    文件:LazyClassPathXmlApplicationContext.java   
@Override
protected BeanDefinitionParserDelegate createHelper(
      XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
   BeanDefinitionParserDelegate helper = super.createHelper(readerContext, root, parentDelegate);
   helper.getDefaults().setLazyInit("true");
   return helper;
}
项目:class-guard    文件:AspectJNamespaceHandlerTests.java   
@Before
public void setUp() throws Exception {
    SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
    XmlReaderContext readerContext =
            new XmlReaderContext(null, null, this.readerEventListener, sourceExtractor, reader, null);
    this.parserContext = new ParserContext(readerContext, null);
}
项目:jdal    文件:CustomBeanDefinitionParser.java   
/**
 * Parse bean like a real bean definition.
 * @param ele element
 * @param parserContext parserContext
 * @param builder builder
 */
protected void parseBeanDefinition(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder) {   
    BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
    AbstractBeanDefinition bd = builder.getRawBeanDefinition();
    XmlReaderContext reader =  parserContext.getReaderContext();

    try {
        delegate.parseBeanDefinitionAttributes(ele, beanName, null , bd);
        bd.setDescription(DomUtils.getChildElementValueByTagName(ele, "description"));

        delegate.parseMetaElements(ele, bd);
        delegate.parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
        delegate.parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

        delegate.parseConstructorArgElements(ele, bd);
        delegate.parsePropertyElements(ele, bd);
        delegate.parseQualifierElements(ele, bd);

    }
    catch (NoClassDefFoundError err) {
        reader.error("Class that bean class [" + this.beanClass + "] depends on not found", ele, err);
    }
    catch (Throwable ex) {
        reader.error("Unexpected failure during bean definition parsing", ele, ex);
    }

}
项目:lams    文件:ComponentScanBeanDefinitionParser.java   
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    return new ClassPathBeanDefinitionScanner(readerContext.getRegistry(), useDefaultFilters);
}
项目:alfresco-data-model    文件:NoAutoStartClassPathXmlApplicationContext.java   
protected NoAutoStartBeanDefinitionParserDelegate(XmlReaderContext readerContext) {
   super(readerContext);
}
项目:spring4-understanding    文件:ComponentScanBeanDefinitionParser.java   
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    return new ClassPathBeanDefinitionScanner(readerContext.getRegistry(), useDefaultFilters);
}
项目:my-spring-cache-redis    文件:ComponentScanBeanDefinitionParser.java   
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    return new ClassPathBeanDefinitionScanner(readerContext.getRegistry(), useDefaultFilters);
}
项目:spring    文件:ComponentScanBeanDefinitionParser.java   
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    return new ClassPathBeanDefinitionScanner(readerContext.getRegistry(), useDefaultFilters);
}
项目:community-edition-old    文件:NoAutoStartClassPathXmlApplicationContext.java   
protected NoAutoStartBeanDefinitionParserDelegate(XmlReaderContext readerContext) {
   super(readerContext);
}
项目:class-guard    文件:ComponentScanBeanDefinitionParser.java   
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    return new ClassPathBeanDefinitionScanner(readerContext.getRegistry(), useDefaultFilters);
}