类 ClassPathScanningComponentProvider
java.lang.Object
cn.taketoday.context.loader.ClassPathScanningComponentProvider
- 所有已实现的接口:
Aware,ResourceLoaderAware
A component provider that provides components from a base package. Can
use
the index if it is available of scans the
classpath otherwise.
This implementation is based on framework 's MetadataReader
facility, backed by an ASM ClassReader.
- 从以下版本开始:
- 4.0 2021/12/18 13:50
- 作者:
- Harry Yang
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidClear the local metadata cache, if any, removing all cached class metadata.final cn.taketoday.core.type.classreading.MetadataReaderFactoryReturn the MetadataReaderFactory used by this component provider.protected StringgetPatternLocation(String input) final cn.taketoday.core.io.PatternResourceLoaderReturn the ResourceLoader that this component provider uses.protected StringresolveBasePackage(String basePackage) Resolve the specified base package into a pattern specification for the package search path.voidscan(String basePackage, MetadataReaderConsumer metadataReaderConsumer) Scan the class path for candidate components.voidsetMetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory metadataReaderFactory) Set theMetadataReaderFactoryto use.voidsetResourceLoader(cn.taketoday.core.io.ResourceLoader resourceLoader) Set theResourceLoaderto use for resource locations.voidsetResourcePattern(String resourcePattern) Set the resource pattern to use when scanning the classpath.voidsetResourcePrefix(String resourcePrefix) Set the resource prefix to use when scanning the resources.
-
字段详细资料
-
DEFAULT_RESOURCE_PATTERN
- 另请参阅:
-
resourcePatternResolver
@Nullable protected cn.taketoday.core.io.PatternResourceLoader resourcePatternResolver
-
-
构造器详细资料
-
ClassPathScanningComponentProvider
public ClassPathScanningComponentProvider()
-
-
方法详细资料
-
setResourcePattern
Set the resource pattern to use when scanning the classpath. This value will be appended to each base package name.- 另请参阅:
-
setResourcePrefix
Set the resource prefix to use when scanning the resources. This value will be appended to each base package name.- 另请参阅:
-
PatternResourceLoader.CLASSPATH_ALL_URL_PREFIX
-
getResourcePrefix
-
setResourceLoader
public void setResourceLoader(@Nullable cn.taketoday.core.io.ResourceLoader resourceLoader) Set theResourceLoaderto use for resource locations. This will typically be aPatternResourceLoaderimplementation.Default is a
PathMatchingResourcePatternResolver, also capable of resource pattern resolving through theResourcePatternResolverinterface.- 指定者:
setResourceLoader在接口中ResourceLoaderAware- 参数:
resourceLoader- the ResourceLoader object to be used by this object- 另请参阅:
-
PatternResourceLoaderPathMatchingPatternResourceLoader
-
getResourceLoader
public final cn.taketoday.core.io.PatternResourceLoader getResourceLoader()Return the ResourceLoader that this component provider uses. -
setMetadataReaderFactory
public void setMetadataReaderFactory(@Nullable cn.taketoday.core.type.classreading.MetadataReaderFactory metadataReaderFactory) Set theMetadataReaderFactoryto use.Default is a
CachingMetadataReaderFactoryfor the specified resource loader.Call this setter method after
setResourceLoader(cn.taketoday.core.io.ResourceLoader)in order for the given MetadataReaderFactory to override the default factory. -
getMetadataReaderFactory
public final cn.taketoday.core.type.classreading.MetadataReaderFactory getMetadataReaderFactory()Return the MetadataReaderFactory used by this component provider. -
scan
public void scan(String basePackage, MetadataReaderConsumer metadataReaderConsumer) throws IOException Scan the class path for candidate components.- 参数:
basePackage- the package to check for annotated classes- 抛出:
IOException- sneaky throw fromPatternResourceLoader.getResources(String)
-
getPatternLocation
-
resolveBasePackage
Resolve the specified base package into a pattern specification for the package search path.converts a "."-based package path to a "/"-based resource path.
- 参数:
basePackage- the base package as specified by the user- 返回:
- the pattern specification to be used for package searching
-
clearCache
public void clearCache()Clear the local metadata cache, if any, removing all cached class metadata.
-