Skip to content

Commit eed1a32

Browse files
committed
Polishing (along with SPR-10992)
1 parent 935bd25 commit eed1a32

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder defini
5454
// Create a scoped proxy definition for the original bean name,
5555
// "hiding" the target bean in an internal target definition.
5656
RootBeanDefinition proxyDefinition = new RootBeanDefinition(ScopedProxyFactoryBean.class);
57-
proxyDefinition.setOriginatingBeanDefinition(definition.getBeanDefinition());
57+
proxyDefinition.setOriginatingBeanDefinition(targetDefinition);
5858
proxyDefinition.setSource(definition.getSource());
5959
proxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
6060

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import org.apache.commons.logging.Log;
2929
import org.apache.commons.logging.LogFactory;
30-
import org.springframework.beans.BeansException;
30+
3131
import org.springframework.beans.PropertyValues;
3232
import org.springframework.beans.factory.BeanClassLoaderAware;
3333
import org.springframework.beans.factory.BeanDefinitionStoreException;
@@ -90,7 +90,7 @@
9090
* @since 3.0
9191
*/
9292
public 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

Comments
 (0)