Class AutoConfigurationImportSelector

java.lang.Object
org.springframework.boot.autoconfigure.AutoConfigurationImportSelector
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.annotation.DeferredImportSelector, org.springframework.context.annotation.ImportSelector, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware, org.springframework.core.Ordered

public class AutoConfigurationImportSelector extends Object implements org.springframework.context.annotation.DeferredImportSelector, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.EnvironmentAware, org.springframework.core.Ordered
DeferredImportSelector to handle auto-configuration. This class can also be subclassed if a custom variant of @EnableAutoConfiguration is needed.
Since:
1.3.0
See Also:
  • Constructor Details

    • AutoConfigurationImportSelector

      public AutoConfigurationImportSelector()
  • Method Details

    • selectImports

      public String[] selectImports(org.springframework.core.type.AnnotationMetadata annotationMetadata)
      Specified by:
      selectImports in interface org.springframework.context.annotation.ImportSelector
    • getExclusionFilter

      public Predicate<String> getExclusionFilter()
      Specified by:
      getExclusionFilter in interface org.springframework.context.annotation.ImportSelector
    • getAutoConfigurationEntry

      protected AutoConfigurationImportSelector.AutoConfigurationEntry getAutoConfigurationEntry(org.springframework.core.type.AnnotationMetadata annotationMetadata)
      Return the AutoConfigurationImportSelector.AutoConfigurationEntry based on the AnnotationMetadata of the importing @Configuration class.
      Parameters:
      annotationMetadata - the annotation metadata of the configuration class
      Returns:
      the auto-configurations that should be imported
    • getImportGroup

      public Class<? extends org.springframework.context.annotation.DeferredImportSelector.Group> getImportGroup()
      Specified by:
      getImportGroup in interface org.springframework.context.annotation.DeferredImportSelector
    • isEnabled

      protected boolean isEnabled(org.springframework.core.type.AnnotationMetadata metadata)
    • getAttributes

      protected org.springframework.core.annotation.AnnotationAttributes getAttributes(org.springframework.core.type.AnnotationMetadata metadata)
      Return the appropriate AnnotationAttributes from the AnnotationMetadata. By default this method will return attributes for getAnnotationClass().
      Parameters:
      metadata - the annotation metadata
      Returns:
      annotation attributes
    • getAnnotationClass

      protected Class<?> getAnnotationClass()
      Return the source annotation class used by the selector.
      Returns:
      the annotation class
    • getCandidateConfigurations

      protected List<String> getCandidateConfigurations(org.springframework.core.type.AnnotationMetadata metadata, org.springframework.core.annotation.AnnotationAttributes attributes)
      Return the auto-configuration class names that should be considered. By default, this method will load candidates using ImportCandidates.
      Parameters:
      metadata - the source metadata
      attributes - the annotation attributes
      Returns:
      a list of candidate configurations
    • handleInvalidExcludes

      protected void handleInvalidExcludes(List<String> invalidExcludes)
      Handle any invalid excludes that have been specified.
      Parameters:
      invalidExcludes - the list of invalid excludes (will always have at least one element)
    • getExclusions

      protected Set<String> getExclusions(org.springframework.core.type.AnnotationMetadata metadata, org.springframework.core.annotation.AnnotationAttributes attributes)
      Return any exclusions that limit the candidate configurations.
      Parameters:
      metadata - the source metadata
      attributes - the annotation attributes
      Returns:
      exclusions or an empty set
    • getExcludeAutoConfigurationsProperty

      protected List<String> getExcludeAutoConfigurationsProperty()
      Returns the auto-configurations excluded by the spring.autoconfigure.exclude property.
      Returns:
      excluded auto-configurations
      Since:
      2.3.2
    • getAutoConfigurationImportFilters

      protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters()
    • removeDuplicates

      protected final <T> List<T> removeDuplicates(List<T> list)
    • asList

      protected final List<String> asList(org.springframework.core.annotation.AnnotationAttributes attributes, String name)
    • getAutoConfigurationImportListeners

      protected List<AutoConfigurationImportListener> getAutoConfigurationImportListeners()
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • getBeanFactory

      protected final org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory()
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • getBeanClassLoader

      protected ClassLoader getBeanClassLoader()
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware
    • getEnvironment

      protected final org.springframework.core.env.Environment getEnvironment()
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • getResourceLoader

      protected final org.springframework.core.io.ResourceLoader getResourceLoader()
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered