|
60 | 60 | import org.springframework.core.type.AnnotationMetadata;
|
61 | 61 | import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
62 | 62 | import org.springframework.core.type.classreading.MetadataReaderFactory;
|
63 |
| -import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; |
64 | 63 | import org.springframework.util.Assert;
|
65 | 64 | import org.springframework.util.ClassUtils;
|
66 | 65 |
|
@@ -236,8 +235,8 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
|
236 | 235 | throw new IllegalStateException(
|
237 | 236 | "postProcessBeanFactory already called for this post-processor against " + beanFactory);
|
238 | 237 | }
|
239 |
| - this.factoriesPostProcessed.add((factoryId)); |
240 |
| - if (!this.registriesPostProcessed.contains((factoryId))) { |
| 238 | + this.factoriesPostProcessed.add(factoryId); |
| 239 | + if (!this.registriesPostProcessed.contains(factoryId)) { |
241 | 240 | // BeanDefinitionRegistryPostProcessor hook apparently not supported...
|
242 | 241 | // Simply call processConfigurationClasses lazily at this point then.
|
243 | 242 | processConfigBeanDefinitions((BeanDefinitionRegistry) beanFactory);
|
@@ -372,36 +371,25 @@ public void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFact
|
372 | 371 | }
|
373 | 372 |
|
374 | 373 |
|
375 |
| - private static class ImportAwareBeanPostProcessor implements BeanPostProcessor, PriorityOrdered, BeanFactoryAware { |
| 374 | + private static class ImportAwareBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware, PriorityOrdered { |
376 | 375 |
|
377 | 376 | private BeanFactory beanFactory;
|
378 | 377 |
|
| 378 | + public void setBeanFactory(BeanFactory beanFactory) { |
| 379 | + this.beanFactory = beanFactory; |
| 380 | + } |
| 381 | + |
379 | 382 | public int getOrder() {
|
380 | 383 | return Ordered.HIGHEST_PRECEDENCE;
|
381 | 384 | }
|
382 | 385 |
|
383 | 386 | @Override
|
384 |
| - public void setBeanFactory(BeanFactory beanFactory) { |
385 |
| - this.beanFactory = beanFactory; |
386 |
| - } |
387 |
| - |
388 | 387 | public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
389 | 388 | if (bean instanceof ImportAware) {
|
390 | 389 | ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
|
391 |
| - String importingClass = importRegistry.getImportingClassFor(bean.getClass().getSuperclass().getName()); |
| 390 | + AnnotationMetadata importingClass = importRegistry.getImportingClassFor(bean.getClass().getSuperclass().getName()); |
392 | 391 | if (importingClass != null) {
|
393 |
| - try { |
394 |
| - AnnotationMetadata metadata = |
395 |
| - new SimpleMetadataReaderFactory().getMetadataReader(importingClass).getAnnotationMetadata(); |
396 |
| - ((ImportAware) bean).setImportMetadata(metadata); |
397 |
| - } |
398 |
| - catch (IOException ex) { |
399 |
| - // should never occur -> at this point we know the class is present anyway |
400 |
| - throw new IllegalStateException(ex); |
401 |
| - } |
402 |
| - } |
403 |
| - else { |
404 |
| - // no importing class was found |
| 392 | + ((ImportAware) bean).setImportMetadata(importingClass); |
405 | 393 | }
|
406 | 394 | }
|
407 | 395 | return bean;
|
|
0 commit comments