Search in sources :

Example 1 with XmlReaderContext

use of cn.taketoday.beans.factory.xml.XmlReaderContext in project today-infrastructure by TAKETODAY.

the class AspectJNamespaceHandlerTests method setUp.

@BeforeEach
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);
}
Also used : PassThroughSourceExtractor(cn.taketoday.beans.factory.parsing.PassThroughSourceExtractor) XmlBeanDefinitionReader(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader) XmlReaderContext(cn.taketoday.beans.factory.xml.XmlReaderContext) ParserContext(cn.taketoday.beans.factory.xml.ParserContext) PassThroughSourceExtractor(cn.taketoday.beans.factory.parsing.PassThroughSourceExtractor) SourceExtractor(cn.taketoday.beans.factory.parsing.SourceExtractor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with XmlReaderContext

use of cn.taketoday.beans.factory.xml.XmlReaderContext in project today-infrastructure by TAKETODAY.

the class MapperScannerBeanDefinitionParser method parseInternal.

/**
 * {@inheritDoc}
 */
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
    builder.addPropertyValue("processPropertyPlaceHolders", true);
    try {
        String annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION);
        if (StringUtils.hasText(annotationClassName)) {
            Class<? extends Annotation> annotationClass = ClassUtils.forName(annotationClassName);
            builder.addPropertyValue("annotationClass", annotationClass);
        }
        String markerInterfaceClassName = element.getAttribute(ATTRIBUTE_MARKER_INTERFACE);
        if (StringUtils.hasText(markerInterfaceClassName)) {
            Class<?> markerInterface = ClassUtils.forName(markerInterfaceClassName);
            builder.addPropertyValue("markerInterface", markerInterface);
        }
        String nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR);
        if (StringUtils.hasText(nameGeneratorClassName)) {
            Class<BeanNameGenerator> nameGeneratorClass = ClassUtils.forName(nameGeneratorClassName);
            BeanNameGenerator nameGenerator = BeanUtils.newInstance(nameGeneratorClass);
            builder.addPropertyValue("nameGenerator", nameGenerator);
        }
        String mapperFactoryBeanClassName = element.getAttribute(ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS);
        if (StringUtils.hasText(mapperFactoryBeanClassName)) {
            Class<? extends MapperFactoryBean> mapperFactoryBeanClass = ClassUtils.forName(mapperFactoryBeanClassName);
            builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass);
        }
    } catch (Exception ex) {
        XmlReaderContext readerContext = parserContext.getReaderContext();
        readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause());
    }
    builder.addPropertyValue("basePackage", element.getAttribute(ATTRIBUTE_BASE_PACKAGE));
    builder.addPropertyValue("defaultScope", element.getAttribute(ATTRIBUTE_DEFAULT_SCOPE));
    builder.addPropertyValue("sqlSessionFactoryBeanName", element.getAttribute(ATTRIBUTE_FACTORY_REF));
    builder.addPropertyValue("lazyInitialization", element.getAttribute(ATTRIBUTE_LAZY_INITIALIZATION));
    builder.addPropertyValue("sqlSessionTemplateBeanName", element.getAttribute(ATTRIBUTE_TEMPLATE_REF));
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    return builder.getBeanDefinition();
}
Also used : BeanNameGenerator(cn.taketoday.beans.factory.support.BeanNameGenerator) BeanDefinitionBuilder(cn.taketoday.beans.factory.support.BeanDefinitionBuilder) XmlReaderContext(cn.taketoday.beans.factory.xml.XmlReaderContext)

Example 3 with XmlReaderContext

use of cn.taketoday.beans.factory.xml.XmlReaderContext in project today-framework by TAKETODAY.

the class AspectJNamespaceHandlerTests method setUp.

@BeforeEach
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);
}
Also used : PassThroughSourceExtractor(cn.taketoday.beans.factory.parsing.PassThroughSourceExtractor) XmlBeanDefinitionReader(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader) XmlReaderContext(cn.taketoday.beans.factory.xml.XmlReaderContext) ParserContext(cn.taketoday.beans.factory.xml.ParserContext) PassThroughSourceExtractor(cn.taketoday.beans.factory.parsing.PassThroughSourceExtractor) SourceExtractor(cn.taketoday.beans.factory.parsing.SourceExtractor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with XmlReaderContext

use of cn.taketoday.beans.factory.xml.XmlReaderContext in project today-framework by TAKETODAY.

the class MapperScannerBeanDefinitionParser method parseInternal.

/**
 * {@inheritDoc}
 */
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
    builder.addPropertyValue("processPropertyPlaceHolders", true);
    try {
        String annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION);
        if (StringUtils.hasText(annotationClassName)) {
            Class<? extends Annotation> annotationClass = ClassUtils.forName(annotationClassName);
            builder.addPropertyValue("annotationClass", annotationClass);
        }
        String markerInterfaceClassName = element.getAttribute(ATTRIBUTE_MARKER_INTERFACE);
        if (StringUtils.hasText(markerInterfaceClassName)) {
            Class<?> markerInterface = ClassUtils.forName(markerInterfaceClassName);
            builder.addPropertyValue("markerInterface", markerInterface);
        }
        String nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR);
        if (StringUtils.hasText(nameGeneratorClassName)) {
            Class<BeanNameGenerator> nameGeneratorClass = ClassUtils.forName(nameGeneratorClassName);
            BeanNameGenerator nameGenerator = BeanUtils.newInstance(nameGeneratorClass);
            builder.addPropertyValue("nameGenerator", nameGenerator);
        }
        String mapperFactoryBeanClassName = element.getAttribute(ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS);
        if (StringUtils.hasText(mapperFactoryBeanClassName)) {
            Class<? extends MapperFactoryBean> mapperFactoryBeanClass = ClassUtils.forName(mapperFactoryBeanClassName);
            builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass);
        }
    } catch (Exception ex) {
        XmlReaderContext readerContext = parserContext.getReaderContext();
        readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause());
    }
    builder.addPropertyValue("basePackage", element.getAttribute(ATTRIBUTE_BASE_PACKAGE));
    builder.addPropertyValue("defaultScope", element.getAttribute(ATTRIBUTE_DEFAULT_SCOPE));
    builder.addPropertyValue("sqlSessionFactoryBeanName", element.getAttribute(ATTRIBUTE_FACTORY_REF));
    builder.addPropertyValue("lazyInitialization", element.getAttribute(ATTRIBUTE_LAZY_INITIALIZATION));
    builder.addPropertyValue("sqlSessionTemplateBeanName", element.getAttribute(ATTRIBUTE_TEMPLATE_REF));
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    return builder.getBeanDefinition();
}
Also used : BeanNameGenerator(cn.taketoday.beans.factory.support.BeanNameGenerator) BeanDefinitionBuilder(cn.taketoday.beans.factory.support.BeanDefinitionBuilder) XmlReaderContext(cn.taketoday.beans.factory.xml.XmlReaderContext)

Aggregations

XmlReaderContext (cn.taketoday.beans.factory.xml.XmlReaderContext)4 PassThroughSourceExtractor (cn.taketoday.beans.factory.parsing.PassThroughSourceExtractor)2 SourceExtractor (cn.taketoday.beans.factory.parsing.SourceExtractor)2 BeanDefinitionBuilder (cn.taketoday.beans.factory.support.BeanDefinitionBuilder)2 BeanNameGenerator (cn.taketoday.beans.factory.support.BeanNameGenerator)2 ParserContext (cn.taketoday.beans.factory.xml.ParserContext)2 XmlBeanDefinitionReader (cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2