@@ -379,6 +379,7 @@ private void processImport(ConfigurationClass configClass, Collection<?> classes
379
379
// the candidate class is an ImportSelector -> delegate to it to determine imports
380
380
Class <?> candidateClass = (candidate instanceof Class ? (Class ) candidate : this .resourceLoader .getClassLoader ().loadClass ((String ) candidate ));
381
381
ImportSelector selector = BeanUtils .instantiateClass (candidateClass , ImportSelector .class );
382
+ invokeAwareMethods (selector );
382
383
processImport (configClass , Arrays .asList (selector .selectImports (importingClassMetadata )), false );
383
384
}
384
385
else if (checkAssignability (ImportBeanDefinitionRegistrar .class , candidateToCheck )) {
@@ -416,21 +417,21 @@ private boolean checkAssignability(Class<?> clazz, Object candidate) throws IOEx
416
417
417
418
/**
418
419
* Invoke {@link ResourceLoaderAware}, {@link BeanClassLoaderAware} and
419
- * {@link BeanFactoryAware} contracts if implemented by the given {@code registrar }.
420
+ * {@link BeanFactoryAware} contracts if implemented by the given {@code bean }.
420
421
*/
421
- private void invokeAwareMethods (ImportBeanDefinitionRegistrar registrar ) {
422
- if (registrar instanceof Aware ) {
423
- if (registrar instanceof ResourceLoaderAware ) {
424
- ((ResourceLoaderAware ) registrar ).setResourceLoader (this .resourceLoader );
422
+ private void invokeAwareMethods (Object importStrategyBean ) {
423
+ if (importStrategyBean instanceof Aware ) {
424
+ if (importStrategyBean instanceof ResourceLoaderAware ) {
425
+ ((ResourceLoaderAware ) importStrategyBean ).setResourceLoader (this .resourceLoader );
425
426
}
426
- if (registrar instanceof BeanClassLoaderAware ) {
427
+ if (importStrategyBean instanceof BeanClassLoaderAware ) {
427
428
ClassLoader classLoader = (this .registry instanceof ConfigurableBeanFactory ?
428
429
((ConfigurableBeanFactory ) this .registry ).getBeanClassLoader () :
429
430
this .resourceLoader .getClassLoader ());
430
- ((BeanClassLoaderAware ) registrar ).setBeanClassLoader (classLoader );
431
+ ((BeanClassLoaderAware ) importStrategyBean ).setBeanClassLoader (classLoader );
431
432
}
432
- if (registrar instanceof BeanFactoryAware && this .registry instanceof BeanFactory ) {
433
- ((BeanFactoryAware ) registrar ).setBeanFactory ((BeanFactory ) this .registry );
433
+ if (importStrategyBean instanceof BeanFactoryAware && this .registry instanceof BeanFactory ) {
434
+ ((BeanFactoryAware ) importStrategyBean ).setBeanFactory ((BeanFactory ) this .registry );
434
435
}
435
436
}
436
437
}
0 commit comments