titan.lightbatis.scan.ClassPathMapperScanner Maven / Gradle / Ivy
package titan.lightbatis.scan;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.env.Environment;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.TypeFilter;
import org.springframework.util.StringUtils;
import titan.lightbatis.configuration.MapperConfig;
import titan.lightbatis.exception.LightbatisException;
import titan.lightbatis.mapper.SpringBootBindUtil;
import titan.lightbatis.mybatis.LightbatisFactoryBean;
import titan.lightbatis.mybatis.MapperBuilder;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Properties;
import java.util.Set;
/**
* A {@link ClassPathBeanDefinitionScanner} that registers Mappers by
* {@code basePackage}, {@code annotationClass}, or {@code markerInterface}. If
* an {@code annotationClass} and/or {@code markerInterface} is specified, only
* the specified types will be searched (searching for all interfaces will be
* disabled).
*
* This functionality was previously a private class of
* {@link MapperScannerConfigurer}, but was broken out in version 1.2.0.
*
* @author Hunter Presnall
* @author Eduardo Macarron
* @since 1.2.0
*/
public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {
private boolean addToConfig = true;
private SqlSessionFactory sqlSessionFactory;
private SqlSessionTemplate sqlSessionTemplate;
private String sqlSessionTemplateBeanName;
private String sqlSessionFactoryBeanName;
private Class extends Annotation> annotationClass;
private Class> markerInterface;
private MapperBuilder mapperBuilder;
private String mapperHelperBeanName;
private LightbatisFactoryBean> mapperFactoryBean = new LightbatisFactoryBean