@ -64,6 +64,8 @@ public class EnableAutoConfigurationImportSelector
implements DeferredImportSelector , BeanClassLoaderAware , ResourceLoaderAware ,
implements DeferredImportSelector , BeanClassLoaderAware , ResourceLoaderAware ,
BeanFactoryAware , EnvironmentAware , Ordered {
BeanFactoryAware , EnvironmentAware , Ordered {
private static final String [ ] NO_IMPORTS = { } ;
private ConfigurableListableBeanFactory beanFactory ;
private ConfigurableListableBeanFactory beanFactory ;
private Environment environment ;
private Environment environment ;
@ -74,6 +76,9 @@ public class EnableAutoConfigurationImportSelector
@Override
@Override
public String [ ] selectImports ( AnnotationMetadata metadata ) {
public String [ ] selectImports ( AnnotationMetadata metadata ) {
if ( ! isEnabled ( metadata ) ) {
return NO_IMPORTS ;
}
try {
try {
AnnotationAttributes attributes = getAttributes ( metadata ) ;
AnnotationAttributes attributes = getAttributes ( metadata ) ;
List < String > configurations = getCandidateConfigurations ( metadata ,
List < String > configurations = getCandidateConfigurations ( metadata ,
@ -90,6 +95,15 @@ public class EnableAutoConfigurationImportSelector
}
}
}
}
protected boolean isEnabled ( AnnotationMetadata metadata ) {
if ( getClass ( ) . equals ( EnableAutoConfigurationImportSelector . class ) ) {
return this . environment . getProperty (
EnableAutoConfiguration . ENABLED_OVERRIDE_PROPERTY , Boolean . class ,
true ) ;
}
return true ;
}
/ * *
/ * *
* Return the appropriate { @link AnnotationAttributes } from the
* Return the appropriate { @link AnnotationAttributes } from the
* { @link AnnotationMetadata } . By default this method will return attributes for
* { @link AnnotationMetadata } . By default this method will return attributes for