当前页面:
在线文档首页 >
Spring Framework 2.1.0 API 文档英文版
ClassPathScanningCandidateComponentProvider (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版
org.springframework.context.annotation
Class ClassPathScanningCandidateComponentProvider
java.lang.Object
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
- All Implemented Interfaces:
- CandidateComponentProvider, ResourceLoaderAware
public class ClassPathScanningCandidateComponentProvider
- extends Object
- implements CandidateComponentProvider, ResourceLoaderAware
A component provider that scans the classpath from a base package (default is empty).
It then applies exclude and include filters to the resulting classes to find candidates.
This implementation is based on the ASM ClassReader
.
- Since:
- 2.1
- Author:
- Costin Leau, Rod Johnson, Mark Fisher, Ramnivas Laddad, Juergen Hoeller
- See Also:
ClassReader
,
ClassNameAndTypesReadingVisitor
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected final Log logger
ClassPathScanningCandidateComponentProvider
public ClassPathScanningCandidateComponentProvider(String basePackage)
ClassPathScanningCandidateComponentProvider
public ClassPathScanningCandidateComponentProvider(String basePackage,
boolean useDefaultFilters)
ClassPathScanningCandidateComponentProvider
public ClassPathScanningCandidateComponentProvider(String[] basePackages,
boolean useDefaultFilters)
setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
- Description copied from interface:
ResourceLoaderAware
- Set the ResourceLoader that this object runs in.
This might be a ResourcePatternResolver, which can be checked
through instanceof ResourcePatternResolver
. See also the
ResourcePatternUtils.getResourcePatternResolver
method.
Invoked after population of normal bean properties but before an init callback
like InitializingBean's afterPropertiesSet
or a custom init-method.
Invoked before ApplicationContextAware's setApplicationContext
.
- Specified by:
setResourceLoader
in interface ResourceLoaderAware
- Parameters:
resourceLoader
- ResourceLoader object to be used by this object- See Also:
ResourcePatternResolver
,
ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
addExcludeFilter
public void addExcludeFilter(TypeFilter excludeFilter)
addIncludeFilter
public void addIncludeFilter(TypeFilter includeFilter)
findCandidateComponents
public Set<Class> findCandidateComponents()
- Specified by:
findCandidateComponents
in interface CandidateComponentProvider
isCandidateComponent
protected boolean isCandidateComponent(org.objectweb.asm.ClassReader classReader)
- Parameters:
classReader
- ASM ClassReader for the class
- Returns:
- true if this class does not match any exclude filter
and does match at least one include filter
loadClass
protected Class loadClass(String className)
- Utility method which loads a class without initializing it.
Translates any ClassNotFoundException into BeanDefinitionStoreException.
- Parameters:
className
- the name of the class
- Returns:
- the loaded class
Copyright © 2002-2007 The Spring Framework.