Candidate components are identified by applying exclude and include filters.
AnnotationTypeFilter and AssignableTypeFilter include filters
for an annotation/target-type that is annotated with Indexed are
supported: if any other include filter is specified, the index is ignored and
classpath scanning is used instead.
This implementation is based on Spring's
MetadataReader
facility, backed by an ASM ClassReader.
org.springframework.core.type.classreading.MetadataReaderFactory , org.springframework.core.type.AnnotationMetadata , ScannedGenericBeanDefinition, CandidateComponentsIndex
| Modifier and Type | Field and Description |
|---|---|
| private CandidateComponentsIndex | componentsIndex
Deprecated
as a consequence of
CandidateComponentsIndex being deprecated.
|
| private ConditionEvaluator | |
| pack-priv static final String | |
| private Environment | |
| private final List | |
| public static final String | IGNORE_CLASSFORMAT_PROPERTY_NAME
System property that instructs Spring to ignore class format exceptions during classpath scanning, in particular for unsupported class file versions. |
| private final List | |
| protected final Log | |
| private MetadataReaderFactory | |
| private String | |
| private ResourcePatternResolver | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| protected | ClassPathScanningCandidateComponentProvider()
Protected constructor for flexible subclass initialization. |
| public | ClassPathScanningCandidateComponentProvider(boolean
whether to register the default filters for the
useDefaultFilters)@Component, @Repository,
@Service, and @Controller
stereotype annotationsCreate a ClassPathScanningCandidateComponentProvider with a |
| public | ClassPathScanningCandidateComponentProvider(boolean
whether to register the default filters for the
useDefaultFilters, Environment @Component, @Repository,
@Service, and @Controller
stereotype annotationsthe Environment to use environment)Create a ClassPathScanningCandidateComponentProvider with the given |
| Modifier and Type | Method and Description |
|---|---|
| private Set | addCandidateComponentsFromIndex(CandidateComponentsIndex index, String basePackage)
Deprecated
as a consequence of
CandidateComponentsIndex being deprecated.
|
| public void | addExcludeFilter(TypeFilter excludeFilter)
Add an exclude type filter to the front of the exclusion list. |
| public void | addIncludeFilter(TypeFilter includeFilter)
Add an include type filter to the end of the inclusion list. |
| public void | |
| private String | Returns: the stereotype in the index matching this filterthe filter to handle filter)Extract the stereotype to use for the specified compatible filter. |
| public Set | Returns: a corresponding Set of autodetected bean definitionsthe package to check for annotated classes basePackage)Scan the component index or class path for candidate components. |
| public final Environment | getEnvironment()
Implements org. Environment associated with this component.
|
| public final MetadataReaderFactory | |
| protected BeanDefinitionRegistry | |
| public final ResourceLoader | |
| private ResourcePatternResolver | |
| private boolean | Returns: whether the index supports this include filterthe filter to check filter)Determine if the specified include |
| private boolean | Returns: true if the index is available and the configuration of this
instance is supported by it, false otherwiseDetermine if the component index can be used by this instance. |
| protected boolean | Returns: whether the class qualifies as a candidate componentthe ASM ClassReader for the class metadataReader)Determine whether the given class does not match any exclude filter and does match at least one include filter. |
| protected boolean | Returns: whether the bean definition qualifies as a candidate componentthe bean definition to check beanDefinition)Determine whether the given bean definition qualifies as candidate. |
| private boolean | Returns: whether the class qualifies as a candidate componentthe ASM ClassReader for the class metadataReader)Determine whether the given class is a candidate component based on any
|
| protected void | |
| public void | resetFilters(boolean
whether to re-register the default filters for
the useDefaultFilters)@Component, @Repository,
@Service, and @Controller
stereotype annotationsReset the configured type filters. |
| protected String | Returns: the pattern specification to be used for package searchingthe base package as specified by the user basePackage)Resolve the specified base package into a pattern specification for the package search path. |
| private Set | |
| public void | setEnvironment(Environment
the Environment to use environment)Set the Environment to use when resolving placeholders and evaluating
|
| public void | setMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory)
Set the |
| public void | setResourceLoader(ResourceLoader
the ResourceLoader object to be used by this object resourceLoader)Implements org. ResourceLoader to use for resource locations.
|
| public void | setResourcePattern(String resourcePattern)
Set the resource pattern to use when scanning the classpath. |
| componentsIndex | back to summary |
|---|---|
| private CandidateComponentsIndex componentsIndex
Deprecated as a consequence of | |
| conditionEvaluator | back to summary |
|---|---|
| private ConditionEvaluator conditionEvaluator
| |
| DEFAULT_RESOURCE_PATTERN | back to summary |
|---|---|
| pack-priv static final String DEFAULT_RESOURCE_PATTERN | |
| environment | back to summary |
|---|---|
| private Environment environment
| |
| excludeFilters | back to summary |
|---|---|
| private final List<TypeFilter> excludeFilters | |
| IGNORE_CLASSFORMAT_PROPERTY_NAME | back to summary |
|---|---|
| public static final String IGNORE_CLASSFORMAT_PROPERTY_NAME System property that instructs Spring to ignore class format exceptions during classpath scanning, in particular for unsupported class file versions. By default, such a class format mismatch leads to a classpath scanning failure.
| |
| includeFilters | back to summary |
|---|---|
| private final List<TypeFilter> includeFilters | |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| metadataReaderFactory | back to summary |
|---|---|
| private MetadataReaderFactory metadataReaderFactory
| |
| resourcePattern | back to summary |
|---|---|
| private String resourcePattern | |
| resourcePatternResolver | back to summary |
|---|---|
| private ResourcePatternResolver resourcePatternResolver
| |
| shouldIgnoreClassFormatException | back to summary |
|---|---|
| private static final boolean shouldIgnoreClassFormatException | |
| ClassPathScanningCandidateComponentProvider | back to summary |
|---|---|
| protected ClassPathScanningCandidateComponentProvider() Protected constructor for flexible subclass initialization.
| |
| ClassPathScanningCandidateComponentProvider | back to summary |
|---|---|
| public ClassPathScanningCandidateComponentProvider(boolean useDefaultFilters) Create a ClassPathScanningCandidateComponentProvider with a
| |
| ClassPathScanningCandidateComponentProvider | back to summary |
|---|---|
| public ClassPathScanningCandidateComponentProvider(boolean useDefaultFilters, Environment environment) Create a ClassPathScanningCandidateComponentProvider with the given
| |
| addCandidateComponentsFromIndex | back to summary |
|---|---|
| private Set Deprecated as a consequence of | |
| addExcludeFilter | back to summary |
|---|---|
| public void addExcludeFilter(TypeFilter excludeFilter) Add an exclude type filter to the front of the exclusion list. | |
| addIncludeFilter | back to summary |
|---|---|
| public void addIncludeFilter(TypeFilter includeFilter) Add an include type filter to the end of the inclusion list. | |
| clearCache | back to summary |
|---|---|
| public void clearCache() Clear the local metadata cache, if any, removing all cached class metadata. | |
| extractStereotype | back to summary |
|---|---|
| private String extractStereotype(TypeFilter filter) Extract the stereotype to use for the specified compatible filter.
| |
| findCandidateComponents | back to summary |
|---|---|
| public Set Scan the component index or class path for candidate components.
| |
| getEnvironment | back to summary |
|---|---|
| public final Environment getEnvironment() Implements org. Doc from org. Return the
| |
| getMetadataReaderFactory | back to summary |
|---|---|
| public final MetadataReaderFactory getMetadataReaderFactory() Return the MetadataReaderFactory used by this component provider. | |
| getRegistry | back to summary |
|---|---|
| protected BeanDefinitionRegistry getRegistry() Return the
| |
| getResourceLoader | back to summary |
|---|---|
| public final ResourceLoader getResourceLoader() Return the ResourceLoader that this component provider uses. | |
| getResourcePatternResolver | back to summary |
|---|---|
| private ResourcePatternResolver getResourcePatternResolver() | |
| indexSupportsIncludeFilter | back to summary |
|---|---|
| private boolean indexSupportsIncludeFilter(TypeFilter filter) Determine if the specified include
| |
| indexSupportsIncludeFilters | back to summary |
|---|---|
| private boolean indexSupportsIncludeFilters() Determine if the component index can be used by this instance.
| |
| isCandidateComponent | back to summary |
|---|---|
| protected boolean isCandidateComponent(MetadataReader metadataReader) throws IOException Determine whether the given class does not match any exclude filter and does match at least one include filter.
| |
| isCandidateComponent | back to summary |
|---|---|
| protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) Determine whether the given bean definition qualifies as candidate. The default implementation checks whether the class is not an interface and not dependent on an enclosing class. Can be overridden in subclasses.
| |
| isConditionMatch | back to summary |
|---|---|
| private boolean isConditionMatch(MetadataReader metadataReader) Determine whether the given class is a candidate component based on any
| |
| registerDefaultFilters | back to summary |
|---|---|
| protected void registerDefaultFilters() Register the default filter for This will implicitly register all annotations that have the
Also supports Jakarta EE's
| |
| resetFilters | back to summary |
|---|---|
| public void resetFilters(boolean useDefaultFilters) Reset the configured type filters.
| |
| resolveBasePackage | back to summary |
|---|---|
| protected String resolveBasePackage(String basePackage) Resolve the specified base package into a pattern specification for the package search path. The default implementation resolves placeholders against system properties, and converts a "."-based package path to a "/"-based resource path. | |
| scanCandidateComponents | back to summary |
|---|---|
| private Set | |
| setEnvironment | back to summary |
|---|---|
| public void setEnvironment(Environment environment) Set the Environment to use when resolving placeholders and evaluating
The default is a
| |
| setMetadataReaderFactory | back to summary |
|---|---|
| public void setMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory) Set the Default is a Call this setter method after | |
| setResourceLoader | back to summary |
|---|---|
| public void setResourceLoader(ResourceLoader resourceLoader) Implements org. Set the Default is a
| |
| setResourcePattern | back to summary |
|---|---|
| public void setResourcePattern(String resourcePattern) Set the resource pattern to use when scanning the classpath. This value will be appended to each base package name. | |