Rename ConfigurationClassMethod => BeanMethod
This commit is contained in:
parent
f683f781c5
commit
0a790c143f
|
|
@ -31,14 +31,14 @@ import org.springframework.core.type.MethodMetadata;
|
||||||
* @see ConfigurationClassParser
|
* @see ConfigurationClassParser
|
||||||
* @see ConfigurationClassBeanDefinitionReader
|
* @see ConfigurationClassBeanDefinitionReader
|
||||||
*/
|
*/
|
||||||
final class ConfigurationClassMethod {
|
final class BeanMethod {
|
||||||
|
|
||||||
private final MethodMetadata metadata;
|
private final MethodMetadata metadata;
|
||||||
|
|
||||||
private final ConfigurationClass configurationClass;
|
private final ConfigurationClass configurationClass;
|
||||||
|
|
||||||
|
|
||||||
public ConfigurationClassMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {
|
public BeanMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.configurationClass = configurationClass;
|
this.configurationClass = configurationClass;
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ import org.springframework.util.ClassUtils;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @see ConfigurationClassMethod
|
* @see BeanMethod
|
||||||
* @see ConfigurationClassParser
|
* @see ConfigurationClassParser
|
||||||
*/
|
*/
|
||||||
final class ConfigurationClass {
|
final class ConfigurationClass {
|
||||||
|
|
@ -51,7 +51,7 @@ final class ConfigurationClass {
|
||||||
|
|
||||||
private final Map<String, Class<?>> importedResources = new LinkedHashMap<String, Class<?>>();
|
private final Map<String, Class<?>> importedResources = new LinkedHashMap<String, Class<?>>();
|
||||||
|
|
||||||
private final Set<ConfigurationClassMethod> methods = new LinkedHashSet<ConfigurationClassMethod>();
|
private final Set<BeanMethod> beanMethods = new LinkedHashSet<BeanMethod>();
|
||||||
|
|
||||||
private String beanName;
|
private String beanName;
|
||||||
|
|
||||||
|
|
@ -89,12 +89,12 @@ final class ConfigurationClass {
|
||||||
return this.beanName;
|
return this.beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMethod(ConfigurationClassMethod method) {
|
public void addBeanMethod(BeanMethod method) {
|
||||||
this.methods.add(method);
|
this.beanMethods.add(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ConfigurationClassMethod> getMethods() {
|
public Set<BeanMethod> getBeanMethods() {
|
||||||
return this.methods;
|
return this.beanMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addImportedResource(String importedResource, Class<?> readerClass) {
|
public void addImportedResource(String importedResource, Class<?> readerClass) {
|
||||||
|
|
@ -110,9 +110,9 @@ final class ConfigurationClass {
|
||||||
// @Configuration class may declare two @Bean methods with the same name.
|
// @Configuration class may declare two @Bean methods with the same name.
|
||||||
final char hashDelim = '#';
|
final char hashDelim = '#';
|
||||||
Map<String, Integer> methodNameCounts = new HashMap<String, Integer>();
|
Map<String, Integer> methodNameCounts = new HashMap<String, Integer>();
|
||||||
for (ConfigurationClassMethod method : methods) {
|
for (BeanMethod beanMethod : beanMethods) {
|
||||||
String dClassName = method.getMetadata().getDeclaringClassName();
|
String dClassName = beanMethod.getMetadata().getDeclaringClassName();
|
||||||
String methodName = method.getMetadata().getMethodName();
|
String methodName = beanMethod.getMetadata().getMethodName();
|
||||||
String fqMethodName = dClassName + hashDelim + methodName;
|
String fqMethodName = dClassName + hashDelim + methodName;
|
||||||
Integer currentCount = methodNameCounts.get(fqMethodName);
|
Integer currentCount = methodNameCounts.get(fqMethodName);
|
||||||
int newCount = currentCount != null ? currentCount + 1 : 1;
|
int newCount = currentCount != null ? currentCount + 1 : 1;
|
||||||
|
|
@ -134,8 +134,8 @@ final class ConfigurationClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ConfigurationClassMethod method : this.methods) {
|
for (BeanMethod beanMethod : this.beanMethods) {
|
||||||
method.validate(problemReporter);
|
beanMethod.validate(problemReporter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ public class ConfigurationClassBeanDefinitionReader {
|
||||||
AnnotationMetadata metadata = configClass.getMetadata();
|
AnnotationMetadata metadata = configClass.getMetadata();
|
||||||
processFeatureAnnotations(metadata);
|
processFeatureAnnotations(metadata);
|
||||||
doLoadBeanDefinitionForConfigurationClassIfNecessary(configClass);
|
doLoadBeanDefinitionForConfigurationClassIfNecessary(configClass);
|
||||||
for (ConfigurationClassMethod beanMethod : configClass.getMethods()) {
|
for (BeanMethod beanMethod : configClass.getBeanMethods()) {
|
||||||
loadBeanDefinitionsForBeanMethod(beanMethod);
|
loadBeanDefinitionsForBeanMethod(beanMethod);
|
||||||
}
|
}
|
||||||
loadBeanDefinitionsFromImportedResources(configClass.getImportedResources());
|
loadBeanDefinitionsFromImportedResources(configClass.getImportedResources());
|
||||||
|
|
@ -200,10 +200,10 @@ public class ConfigurationClassBeanDefinitionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a particular {@link ConfigurationClassMethod}, registering bean definitions
|
* Read a particular {@link BeanMethod}, registering bean definitions
|
||||||
* with the BeanDefinitionRegistry based on its contents.
|
* with the BeanDefinitionRegistry based on its contents.
|
||||||
*/
|
*/
|
||||||
private void loadBeanDefinitionsForBeanMethod(ConfigurationClassMethod beanMethod) {
|
private void loadBeanDefinitionsForBeanMethod(BeanMethod beanMethod) {
|
||||||
ConfigurationClass configClass = beanMethod.getConfigurationClass();
|
ConfigurationClass configClass = beanMethod.getConfigurationClass();
|
||||||
MethodMetadata metadata = beanMethod.getMetadata();
|
MethodMetadata metadata = beanMethod.getMetadata();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ class ConfigurationClassParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<MethodMetadata> beanMethods = metadata.getAnnotatedMethods(Bean.class.getName());
|
Set<MethodMetadata> beanMethods = metadata.getAnnotatedMethods(Bean.class.getName());
|
||||||
for (MethodMetadata beanMethod : beanMethods) {
|
for (MethodMetadata methodMetadata : beanMethods) {
|
||||||
configClass.addMethod(new ConfigurationClassMethod(beanMethod, configClass));
|
configClass.addBeanMethod(new BeanMethod(methodMetadata, configClass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue