Package org.mybatis.spring.mapper
Class ClassPathMapperScanner
- java.lang.Object
-
- org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
-
- org.springframework.context.annotation.ClassPathBeanDefinitionScanner
-
- org.mybatis.spring.mapper.ClassPathMapperScanner
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ResourceLoaderAware,org.springframework.core.env.EnvironmentCapable
public class ClassPathMapperScanner extends org.springframework.context.annotation.ClassPathBeanDefinitionScannerAClassPathBeanDefinitionScannerthat registers Mappers bybasePackage,annotationClass, ormarkerInterface. If anannotationClassand/ormarkerInterfaceis specified, only the specified types will be searched (searching for all interfaces will be disabled).This functionality was previously a private class of
MapperScannerConfigurer, but was broken out in version 1.2.0.- Since:
- 1.2.0
- Author:
- Hunter Presnall, Eduardo Macarron
- See Also:
MapperFactoryBean
-
-
Constructor Summary
Constructors Constructor Description ClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
-
Method Summary
Modifier and Type Method Description protected booleancheckCandidate(java.lang.String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)java.util.Set<org.springframework.beans.factory.config.BeanDefinitionHolder>doScan(java.lang.String... basePackages)Calls the parent search that will search and register all the candidates.protected booleanisCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition beanDefinition)voidregisterFilters()Configures parent scanner to search for the right interfaces.voidsetAddToConfig(boolean addToConfig)voidsetAnnotationClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)voidsetLazyInitialization(boolean lazyInitialization)Set whether enable lazy initialization for mapper bean.voidsetMapperFactoryBean(MapperFactoryBean<?> mapperFactoryBean)Deprecated.Since 2.0.1, Please use thesetMapperFactoryBeanClass(Class).voidsetMapperFactoryBeanClass(java.lang.Class<? extends MapperFactoryBean> mapperFactoryBeanClass)Set theMapperFactoryBeanclass.voidsetMarkerInterface(java.lang.Class<?> markerInterface)voidsetSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)voidsetSqlSessionFactoryBeanName(java.lang.String sqlSessionFactoryBeanName)voidsetSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)voidsetSqlSessionTemplateBeanName(java.lang.String sqlSessionTemplateBeanName)-
Methods inherited from class org.springframework.context.annotation.ClassPathBeanDefinitionScanner
getBeanDefinitionDefaults, getRegistry, isCompatible, postProcessBeanDefinition, registerBeanDefinition, scan, setAutowireCandidatePatterns, setBeanDefinitionDefaults, setBeanNameGenerator, setIncludeAnnotationConfig, setScopedProxyMode, setScopeMetadataResolver
-
Methods inherited from class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
addExcludeFilter, addIncludeFilter, clearCache, findCandidateComponents, getEnvironment, getMetadataReaderFactory, getResourceLoader, isCandidateComponent, registerDefaultFilters, resetFilters, resolveBasePackage, setEnvironment, setMetadataReaderFactory, setResourceLoader, setResourcePattern
-
-
-
-
Method Detail
-
setAddToConfig
public void setAddToConfig(boolean addToConfig)
-
setAnnotationClass
public void setAnnotationClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
-
setLazyInitialization
public void setLazyInitialization(boolean lazyInitialization)
Set whether enable lazy initialization for mapper bean.Default is
false.- Parameters:
lazyInitialization- Set the @{code true} to enable- Since:
- 2.0.2
-
setMarkerInterface
public void setMarkerInterface(java.lang.Class<?> markerInterface)
-
setSqlSessionFactory
public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
-
setSqlSessionTemplate
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
-
setSqlSessionTemplateBeanName
public void setSqlSessionTemplateBeanName(java.lang.String sqlSessionTemplateBeanName)
-
setSqlSessionFactoryBeanName
public void setSqlSessionFactoryBeanName(java.lang.String sqlSessionFactoryBeanName)
-
setMapperFactoryBean
@Deprecated public void setMapperFactoryBean(MapperFactoryBean<?> mapperFactoryBean)
Deprecated.Since 2.0.1, Please use thesetMapperFactoryBeanClass(Class).
-
setMapperFactoryBeanClass
public void setMapperFactoryBeanClass(java.lang.Class<? extends MapperFactoryBean> mapperFactoryBeanClass)
Set theMapperFactoryBeanclass.- Parameters:
mapperFactoryBeanClass- theMapperFactoryBeanclass- Since:
- 2.0.1
-
registerFilters
public void registerFilters()
Configures parent scanner to search for the right interfaces. It can search for all interfaces or just for those that extends a markerInterface or/and those annotated with the annotationClass
-
doScan
public java.util.Set<org.springframework.beans.factory.config.BeanDefinitionHolder> doScan(java.lang.String... basePackages)
Calls the parent search that will search and register all the candidates. Then the registered objects are post processed to set them as MapperFactoryBeans- Overrides:
doScanin classorg.springframework.context.annotation.ClassPathBeanDefinitionScanner
-
isCandidateComponent
protected boolean isCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition beanDefinition)
- Overrides:
isCandidateComponentin classorg.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
-
checkCandidate
protected boolean checkCandidate(java.lang.String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)- Overrides:
checkCandidatein classorg.springframework.context.annotation.ClassPathBeanDefinitionScanner
-
-