2727
2828import org .apache .commons .logging .Log ;
2929import org .apache .commons .logging .LogFactory ;
30- import org . springframework . beans . BeansException ;
30+
3131import org .springframework .beans .PropertyValues ;
3232import org .springframework .beans .factory .BeanClassLoaderAware ;
3333import org .springframework .beans .factory .BeanDefinitionStoreException ;
9090 * @since 3.0
9191 */
9292public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor ,
93- ResourceLoaderAware , BeanClassLoaderAware , EnvironmentAware , PriorityOrdered {
93+ PriorityOrdered , ResourceLoaderAware , BeanClassLoaderAware , EnvironmentAware {
9494
9595 private static final String IMPORT_AWARE_PROCESSOR_BEAN_NAME =
9696 ConfigurationClassPostProcessor .class .getName () + ".importAwareProcessor" ;
@@ -138,6 +138,10 @@ protected String buildDefaultBeanName(BeanDefinition definition) {
138138 };
139139
140140
141+ @ Override
142+ public int getOrder () {
143+ return Ordered .LOWEST_PRECEDENCE ; // within PriorityOrdered
144+ }
141145
142146 /**
143147 * Set the {@link SourceExtractor} to use for generated bean definitions
@@ -318,7 +322,7 @@ public void processConfigBeanDefinitions(BeanDefinitionRegistry registry) {
318322 this .importBeanNameGenerator );
319323 }
320324
321- reader .loadBeanDefinitions (parser .getConfigurationClasses ());
325+ this . reader .loadBeanDefinitions (parser .getConfigurationClasses ());
322326
323327 // Register the ImportRegistry as a bean in order to support ImportAware @Configuration classes
324328 if (singletonRegistry != null ) {
@@ -374,23 +378,23 @@ public void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFact
374378 }
375379 }
376380
377- @ Override
378- public int getOrder () {
379- return Ordered .LOWEST_PRECEDENCE ; // within PriorityOrdered
380- }
381-
382381
383- private static class ImportAwareBeanPostProcessor implements PriorityOrdered , BeanFactoryAware , BeanPostProcessor {
382+ private static class ImportAwareBeanPostProcessor implements BeanPostProcessor , PriorityOrdered , BeanFactoryAware {
384383
385384 private BeanFactory beanFactory ;
386385
387386 @ Override
388- public void setBeanFactory (BeanFactory beanFactory ) throws BeansException {
387+ public int getOrder () {
388+ return Ordered .HIGHEST_PRECEDENCE ;
389+ }
390+
391+ @ Override
392+ public void setBeanFactory (BeanFactory beanFactory ) {
389393 this .beanFactory = beanFactory ;
390394 }
391395
392396 @ Override
393- public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
397+ public Object postProcessBeforeInitialization (Object bean , String beanName ) {
394398 if (bean instanceof ImportAware ) {
395399 ImportRegistry importRegistry = this .beanFactory .getBean (IMPORT_REGISTRY_BEAN_NAME , ImportRegistry .class );
396400 String importingClass = importRegistry .getImportingClassFor (bean .getClass ().getSuperclass ().getName ());
@@ -413,14 +417,9 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
413417 }
414418
415419 @ Override
416- public Object postProcessAfterInitialization (Object bean , String beanName ) throws BeansException {
420+ public Object postProcessAfterInitialization (Object bean , String beanName ) {
417421 return bean ;
418422 }
419-
420- @ Override
421- public int getOrder () {
422- return Ordered .HIGHEST_PRECEDENCE ;
423- }
424423 }
425424
426425
@@ -429,9 +428,8 @@ public int getOrder() {
429428 * {@link EnhancedConfiguration} beans are injected with the {@link BeanFactory}
430429 * before the {@link AutowiredAnnotationBeanPostProcessor} runs (SPR-10668).
431430 */
432- private static class EnhancedConfigurationBeanPostProcessor extends
433- InstantiationAwareBeanPostProcessorAdapter implements PriorityOrdered ,
434- BeanFactoryAware {
431+ private static class EnhancedConfigurationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
432+ implements PriorityOrdered , BeanFactoryAware {
435433
436434 private BeanFactory beanFactory ;
437435
@@ -441,22 +439,19 @@ public int getOrder() {
441439 }
442440
443441 @ Override
444- public PropertyValues postProcessPropertyValues (PropertyValues pvs ,
445- PropertyDescriptor [] pds , Object bean , String beanName )
446- throws BeansException {
442+ public void setBeanFactory (BeanFactory beanFactory ) {
443+ this .beanFactory = beanFactory ;
444+ }
445+
446+ @ Override
447+ public PropertyValues postProcessPropertyValues (PropertyValues pvs , PropertyDescriptor [] pds , Object bean , String beanName ) {
447448 // Inject the BeanFactory before AutowiredAnnotationBeanPostProcessor's
448- // postProcessPropertyValues method attempts to auto-wire other configuration
449- // beans.
449+ // postProcessPropertyValues method attempts to auto-wire other configuration beans.
450450 if (bean instanceof EnhancedConfiguration ) {
451451 ((EnhancedConfiguration ) bean ).setBeanFactory (this .beanFactory );
452452 }
453453 return pvs ;
454454 }
455455
456- @ Override
457- public void setBeanFactory (BeanFactory beanFactory ) throws BeansException {
458- this .beanFactory = beanFactory ;
459- }
460-
461456 }
462457}
0 commit comments