All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.developframework.kite.spring.KiteScanBeanDefinitionParser Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package com.github.developframework.kite.spring;

import com.github.developframework.kite.core.KiteConfiguration;
import com.github.developframework.kite.core.KiteFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;

/**
 * KiteScan的spring bean 解析器
 *
 * @author qiuzhenhao
 */
public class KiteScanBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {

    @Override
    protected Class getBeanClass(Element element) {
        return KiteFactory.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {
        final String locations = element.getAttribute("locations");
        final String objectMapperRef = element.getAttribute("object-mapper-ref");
        if (StringUtils.hasText(locations)) {
            KiteScanLoader loader = new KiteScanLoader(locations);
            KiteConfiguration kiteConfiguration = loader.createKiteConfiguration();
            builder.addConstructorArgValue(kiteConfiguration);
            if (StringUtils.hasText(objectMapperRef)) {
                builder.addConstructorArgReference(objectMapperRef);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy