Polishing
This commit is contained in:
@@ -37,7 +37,6 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
@@ -91,12 +90,12 @@ import static org.springframework.context.annotation.AnnotationConfigUtils.*;
|
||||
public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor,
|
||||
PriorityOrdered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware {
|
||||
|
||||
private static final String IMPORT_AWARE_PROCESSOR_BEAN_NAME =
|
||||
ConfigurationClassPostProcessor.class.getName() + ".importAwareProcessor";
|
||||
|
||||
private static final String IMPORT_REGISTRY_BEAN_NAME =
|
||||
ConfigurationClassPostProcessor.class.getName() + ".importRegistry";
|
||||
|
||||
private static final String IMPORT_AWARE_PROCESSOR_BEAN_NAME =
|
||||
ConfigurationClassPostProcessor.class.getName() + ".importAwareProcessor";
|
||||
|
||||
private static final String ENHANCED_CONFIGURATION_PROCESSOR_BEAN_NAME =
|
||||
ConfigurationClassPostProcessor.class.getName() + ".enhancedConfigurationProcessor";
|
||||
|
||||
@@ -260,6 +259,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||
// Simply call processConfigurationClasses lazily at this point then.
|
||||
processConfigBeanDefinitions((BeanDefinitionRegistry) beanFactory);
|
||||
}
|
||||
|
||||
enhanceConfigurationClasses(beanFactory);
|
||||
}
|
||||
|
||||
@@ -455,10 +455,10 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||
/**
|
||||
* {@link InstantiationAwareBeanPostProcessorAdapter} that ensures
|
||||
* {@link EnhancedConfiguration} beans are injected with the {@link BeanFactory}
|
||||
* before the {@link AutowiredAnnotationBeanPostProcessor} runs (SPR-10668).
|
||||
* before the {@code AutowiredAnnotationBeanPostProcessor} runs (SPR-10668).
|
||||
*/
|
||||
private static class EnhancedConfigurationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
|
||||
implements PriorityOrdered, BeanFactoryAware {
|
||||
implements BeanFactoryAware, PriorityOrdered {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,29 +38,20 @@ public class Spr10668Tests {
|
||||
|
||||
@Test
|
||||
public void testSelfInjectHierarchy() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ChildConfig.class);
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ChildConfig.class);
|
||||
assertNotNull(context.getBean(MyComponent.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
public static class ParentConfig implements BeanFactoryAware {
|
||||
public static class ParentConfig {
|
||||
|
||||
@Autowired(required = false)
|
||||
MyComponent component;
|
||||
|
||||
public ParentConfig() {
|
||||
System.out.println("Parent " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
System.out.println("BFA " + getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
public static class ChildConfig extends ParentConfig {
|
||||
|
||||
@@ -68,12 +59,11 @@ public class Spr10668Tests {
|
||||
public MyComponentImpl myComponent() {
|
||||
return new MyComponentImpl();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static interface MyComponent {
|
||||
}
|
||||
|
||||
public static class MyComponentImpl implements MyComponent {
|
||||
}
|
||||
public interface MyComponent {}
|
||||
|
||||
public static class MyComponentImpl implements MyComponent {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user