Class AutoConfigurationImportSelector
java.lang.Object
org.springframework.boot.autoconfigure.AutoConfigurationImportSelector
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
,DeferredImportSelector
,ImportSelector
,EnvironmentAware
,ResourceLoaderAware
,Ordered
public class AutoConfigurationImportSelector
extends Object
implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware, BeanFactoryAware, EnvironmentAware, Ordered
DeferredImportSelector
to handle auto-configuration
. This class can also be subclassed if a custom variant of
@EnableAutoConfiguration
is needed.- Since:
- 1.3.0
- Author:
- Phillip Webb, Andy Wilkinson, Stephane Nicoll, Madhura Bhave
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Nested classes/interfaces inherited from interface org.springframework.context.annotation.DeferredImportSelector
DeferredImportSelector.Group
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionasList
(AnnotationAttributes attributes, String name) protected Class<?>
Return the source annotation class used by the selector.protected AnnotationAttributes
getAttributes
(AnnotationMetadata metadata) Return the appropriateAnnotationAttributes
from theAnnotationMetadata
.getAutoConfigurationEntry
(AnnotationMetadata annotationMetadata) Return theAutoConfigurationImportSelector.AutoConfigurationEntry
based on theAnnotationMetadata
of the importing@Configuration
class.protected List<AutoConfigurationImportFilter>
protected List<AutoConfigurationImportListener>
protected ClassLoader
protected final ConfigurableListableBeanFactory
getCandidateConfigurations
(AnnotationMetadata metadata, AnnotationAttributes attributes) Return the auto-configuration class names that should be considered.protected final Environment
Returns the auto-configurations excluded by thespring.autoconfigure.exclude
property.getExclusions
(AnnotationMetadata metadata, AnnotationAttributes attributes) Return any exclusions that limit the candidate configurations.Class<? extends DeferredImportSelector.Group>
int
getOrder()
protected final ResourceLoader
protected Class<?>
Return the class used bySpringFactoriesLoader
to load configuration candidates.protected void
handleInvalidExcludes
(List<String> invalidExcludes) Handle any invalid excludes that have been specified.protected boolean
isEnabled
(AnnotationMetadata metadata) protected final <T> List<T>
removeDuplicates
(List<T> list) String[]
selectImports
(AnnotationMetadata annotationMetadata) void
setBeanClassLoader
(ClassLoader classLoader) void
setBeanFactory
(BeanFactory beanFactory) void
setEnvironment
(Environment environment) void
setResourceLoader
(ResourceLoader resourceLoader)
-
Constructor Details
-
AutoConfigurationImportSelector
public AutoConfigurationImportSelector()
-
-
Method Details
-
selectImports
- Specified by:
selectImports
in interfaceImportSelector
-
getExclusionFilter
- Specified by:
getExclusionFilter
in interfaceImportSelector
-
getAutoConfigurationEntry
protected AutoConfigurationImportSelector.AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata) Return theAutoConfigurationImportSelector.AutoConfigurationEntry
based on theAnnotationMetadata
of the importing@Configuration
class.- Parameters:
annotationMetadata
- the annotation metadata of the configuration class- Returns:
- the auto-configurations that should be imported
-
getImportGroup
- Specified by:
getImportGroup
in interfaceDeferredImportSelector
-
isEnabled
-
getAttributes
Return the appropriateAnnotationAttributes
from theAnnotationMetadata
. By default this method will return attributes forgetAnnotationClass()
.- Parameters:
metadata
- the annotation metadata- Returns:
- annotation attributes
-
getAnnotationClass
Return the source annotation class used by the selector.- Returns:
- the annotation class
-
getCandidateConfigurations
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) Return the auto-configuration class names that should be considered. By default this method will load candidates usingSpringFactoriesLoader
withgetSpringFactoriesLoaderFactoryClass()
.- Parameters:
metadata
- the source metadataattributes
- theannotation attributes
- Returns:
- a list of candidate configurations
-
getSpringFactoriesLoaderFactoryClass
Return the class used bySpringFactoriesLoader
to load configuration candidates.- Returns:
- the factory class
-
handleInvalidExcludes
Handle any invalid excludes that have been specified.- Parameters:
invalidExcludes
- the list of invalid excludes (will always have at least one element)
-
getExclusions
Return any exclusions that limit the candidate configurations.- Parameters:
metadata
- the source metadataattributes
- theannotation attributes
- Returns:
- exclusions or an empty set
-
getExcludeAutoConfigurationsProperty
Returns the auto-configurations excluded by thespring.autoconfigure.exclude
property.- Returns:
- excluded auto-configurations
- Since:
- 2.3.2
-
getAutoConfigurationImportFilters
-
removeDuplicates
-
asList
-
getAutoConfigurationImportListeners
-
setBeanFactory
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
getBeanFactory
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
getBeanClassLoader
-
setEnvironment
- Specified by:
setEnvironment
in interfaceEnvironmentAware
-
getEnvironment
-
setResourceLoader
- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
-
getResourceLoader
-
getOrder
public int getOrder()
-