RESOLVED - issue SPR-5600: Make naming of @Configuration class processing-related artifacts consistent
This commit is contained in:
parent
24e8dccd44
commit
cc713ad524
|
|
@ -29,7 +29,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
* <p>Provides template method {@link #processConfigBeanDefinitions()} that orchestrates calling each
|
* <p>Provides template method {@link #processConfigBeanDefinitions()} that orchestrates calling each
|
||||||
* of several abstract methods to be overriden by concrete implementations that allow for
|
* of several abstract methods to be overriden by concrete implementations that allow for
|
||||||
* customizing how {@link Configuration} classes are found ({@link #getConfigurationBeanDefinitions}),
|
* customizing how {@link Configuration} classes are found ({@link #getConfigurationBeanDefinitions}),
|
||||||
* customizing the creation of a {@link ConfigurationParser} ({@link #createConfigurationParser}),
|
* customizing the creation of a {@link ConfigurationClassParser} ({@link #createConfigurationParser}),
|
||||||
* and customizing {@link ConfigurationModel} validation logic ({@link #validateModel}).
|
* and customizing {@link ConfigurationModel} validation logic ({@link #validateModel}).
|
||||||
*
|
*
|
||||||
* <p>This class was expressly designed with tooling in mind. Spring IDE will maintain it's
|
* <p>This class was expressly designed with tooling in mind. Spring IDE will maintain it's
|
||||||
|
|
@ -63,12 +63,12 @@ public abstract class AbstractConfigurationClassProcessor {
|
||||||
protected abstract BeanDefinitionRegistry getConfigurationBeanDefinitions(boolean includeAbstractBeanDefs);
|
protected abstract BeanDefinitionRegistry getConfigurationBeanDefinitions(boolean includeAbstractBeanDefs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return a new {@link ConfigurationParser}, allowing for customization of
|
* Create and return a new {@link ConfigurationClassParser}, allowing for customization of
|
||||||
* type (ASM/JDT/Reflection) as well as providing specialized ClassLoader during
|
* type (ASM/JDT/Reflection) as well as providing specialized ClassLoader during
|
||||||
* construction.
|
* construction.
|
||||||
* @see #processConfigBeanDefinitions()
|
* @see #processConfigBeanDefinitions()
|
||||||
*/
|
*/
|
||||||
protected abstract ConfigurationParser createConfigurationParser();
|
protected abstract ConfigurationClassParser createConfigurationParser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default {@link ProblemReporter}.
|
* Override the default {@link ProblemReporter}.
|
||||||
|
|
@ -102,7 +102,7 @@ public abstract class AbstractConfigurationClassProcessor {
|
||||||
return configBeanDefs;
|
return configBeanDefs;
|
||||||
|
|
||||||
// populate a new ConfigurationModel by parsing each @Configuration classes
|
// populate a new ConfigurationModel by parsing each @Configuration classes
|
||||||
ConfigurationParser parser = createConfigurationParser();
|
ConfigurationClassParser parser = createConfigurationParser();
|
||||||
|
|
||||||
for(String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
for(String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
||||||
BeanDefinition beanDef = configBeanDefs.getBeanDefinition(beanName);
|
BeanDefinition beanDef = configBeanDefs.getBeanDefinition(beanName);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import org.springframework.asm.MethodVisitor;
|
||||||
/**
|
/**
|
||||||
* Transforms a class by adding bytecode for a class-level annotation. Checks to ensure that
|
* Transforms a class by adding bytecode for a class-level annotation. Checks to ensure that
|
||||||
* the desired annotation is not already present before adding. Used by
|
* the desired annotation is not already present before adding. Used by
|
||||||
* {@link ConfigurationEnhancer} to dynamically add an {@link org.aspectj.lang.Aspect}
|
* {@link ConfigurationClassEnhancer} to dynamically add an {@link org.aspectj.lang.Aspect}
|
||||||
* annotation to an enhanced Configuration subclass.
|
* annotation to an enhanced Configuration subclass.
|
||||||
*
|
*
|
||||||
* <p>This class was originally adapted from examples the ASM 3.0 documentation.
|
* <p>This class was originally adapted from examples the ASM 3.0 documentation.
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import org.springframework.util.Assert;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationClass
|
* @see ConfigurationClass
|
||||||
* @see ConfigurationModel
|
* @see ConfigurationModel
|
||||||
* @see ConfigurationParser
|
* @see ConfigurationClassParser
|
||||||
* @see ConfigurationModelBeanDefinitionReader
|
* @see ConfigurationModelBeanDefinitionReader
|
||||||
*/
|
*/
|
||||||
final class BeanMethod implements BeanMetadataElement {
|
final class BeanMethod implements BeanMetadataElement {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see Bean
|
* @see Bean
|
||||||
* @see ConfigurationEnhancer
|
* @see ConfigurationClassEnhancer
|
||||||
*/
|
*/
|
||||||
class BeanMethodInterceptor implements MethodInterceptor {
|
class BeanMethodInterceptor implements MethodInterceptor {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import org.springframework.util.Assert;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationModel
|
* @see ConfigurationModel
|
||||||
* @see BeanMethod
|
* @see BeanMethod
|
||||||
* @see ConfigurationParser
|
* @see ConfigurationClassParser
|
||||||
*/
|
*/
|
||||||
final class ConfigurationClass extends ModelClass {
|
final class ConfigurationClass extends ModelClass {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ import org.springframework.util.Assert;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationClassPostProcessor
|
* @see ConfigurationClassPostProcessor
|
||||||
*/
|
*/
|
||||||
class ConfigurationEnhancer {
|
class ConfigurationClassEnhancer {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ConfigurationEnhancer.class);
|
private static final Log log = LogFactory.getLog(ConfigurationClassEnhancer.class);
|
||||||
|
|
||||||
private final ArrayList<Callback> callbackInstances = new ArrayList<Callback>();
|
private final ArrayList<Callback> callbackInstances = new ArrayList<Callback>();
|
||||||
private final ArrayList<Class<? extends Callback>> callbackTypes = new ArrayList<Class<? extends Callback>>();
|
private final ArrayList<Class<? extends Callback>> callbackTypes = new ArrayList<Class<? extends Callback>>();
|
||||||
|
|
@ -58,9 +58,9 @@ class ConfigurationEnhancer {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ConfigurationEnhancer} instance.
|
* Creates a new {@link ConfigurationClassEnhancer} instance.
|
||||||
*/
|
*/
|
||||||
public ConfigurationEnhancer(DefaultListableBeanFactory beanFactory) {
|
public ConfigurationClassEnhancer(DefaultListableBeanFactory beanFactory) {
|
||||||
Assert.notNull(beanFactory, "beanFactory must be non-null");
|
Assert.notNull(beanFactory, "beanFactory must be non-null");
|
||||||
|
|
||||||
callbackInstances.add(new BeanMethodInterceptor(beanFactory));
|
callbackInstances.add(new BeanMethodInterceptor(beanFactory));
|
||||||
|
|
@ -34,11 +34,10 @@ import org.springframework.util.ClassUtils;
|
||||||
* that model.
|
* that model.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @since 3.0
|
|
||||||
* @see ConfigurationModel
|
* @see ConfigurationModel
|
||||||
* @see ConfigurationModelBeanDefinitionReader
|
* @see ConfigurationModelBeanDefinitionReader
|
||||||
*/
|
*/
|
||||||
class ConfigurationParser {
|
class ConfigurationClassParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model to be populated during calls to {@link #parse(Object, String)}
|
* Model to be populated during calls to {@link #parse(Object, String)}
|
||||||
|
|
@ -48,13 +47,13 @@ class ConfigurationParser {
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ConfigurationParser} instance that will be used to populate a
|
* Creates a new {@link ConfigurationClassParser} instance that will be used to populate a
|
||||||
* {@link ConfigurationModel}.
|
* {@link ConfigurationModel}.
|
||||||
*
|
*
|
||||||
* @param model model to be populated by each successive call to {@link #parse}
|
* @param model model to be populated by each successive call to {@link #parse}
|
||||||
* @see #getConfigurationModel()
|
* @see #getConfigurationModel()
|
||||||
*/
|
*/
|
||||||
public ConfigurationParser(ProblemReporter problemReporter, ClassLoader classLoader) {
|
public ConfigurationClassParser(ProblemReporter problemReporter, ClassLoader classLoader) {
|
||||||
this.model = new ConfigurationModel();
|
this.model = new ConfigurationModel();
|
||||||
this.problemReporter = problemReporter;
|
this.problemReporter = problemReporter;
|
||||||
this.classLoader = classLoader;
|
this.classLoader = classLoader;
|
||||||
|
|
@ -103,8 +103,8 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
|
||||||
* ClassLoader to load all Configuration class artifacts.
|
* ClassLoader to load all Configuration class artifacts.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ConfigurationParser createConfigurationParser() {
|
protected ConfigurationClassParser createConfigurationParser() {
|
||||||
return new ConfigurationParser(this.getProblemReporter(), beanFactory.getBeanClassLoader());
|
return new ConfigurationClassParser(this.getProblemReporter(), beanFactory.getBeanClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,10 +131,10 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any
|
* Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any
|
||||||
* candidates are then enhanced by a {@link ConfigurationEnhancer}. Candidate status is
|
* candidates are then enhanced by a {@link ConfigurationClassEnhancer}. Candidate status is
|
||||||
* determined by BeanDefinition attribute metadata.
|
* determined by BeanDefinition attribute metadata.
|
||||||
*
|
*
|
||||||
* @see ConfigurationEnhancer
|
* @see ConfigurationClassEnhancer
|
||||||
* @see BeanFactoryPostProcessor
|
* @see BeanFactoryPostProcessor
|
||||||
*/
|
*/
|
||||||
private void enhanceConfigurationClasses() {
|
private void enhanceConfigurationClasses() {
|
||||||
|
|
@ -147,7 +147,7 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
|
||||||
|
|
||||||
assertCglibIsPresent(configBeanDefs);
|
assertCglibIsPresent(configBeanDefs);
|
||||||
|
|
||||||
ConfigurationEnhancer enhancer = new ConfigurationEnhancer(beanFactory);
|
ConfigurationClassEnhancer enhancer = new ConfigurationClassEnhancer(beanFactory);
|
||||||
|
|
||||||
for (String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
for (String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
||||||
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
|
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||||
* {@link ConfigurationClass} instance with information gleaned along the way.
|
* {@link ConfigurationClass} instance with information gleaned along the way.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationParser
|
* @see ConfigurationClassParser
|
||||||
* @see ConfigurationClass
|
* @see ConfigurationClass
|
||||||
*/
|
*/
|
||||||
class ConfigurationClassVisitor extends ClassAdapter {
|
class ConfigurationClassVisitor extends ClassAdapter {
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ import org.springframework.beans.factory.parsing.ProblemReporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the set of all user-defined {@link Configuration} classes. Once this model
|
* Represents the set of all user-defined {@link Configuration} classes. Once this model
|
||||||
* is populated using a {@link ConfigurationParser}, it can be rendered out to a set of
|
* is populated using a {@link ConfigurationClassParser}, it can be rendered out to a set of
|
||||||
* {@link BeanDefinition} objects. This model provides an important layer of indirection
|
* {@link BeanDefinition} objects. This model provides an important layer of indirection
|
||||||
* between the complexity of parsing a set of classes and the complexity of representing
|
* between the complexity of parsing a set of classes and the complexity of representing
|
||||||
* the contents of those classes as BeanDefinitions.
|
* the contents of those classes as BeanDefinitions.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationClass
|
* @see ConfigurationClass
|
||||||
* @see ConfigurationParser
|
* @see ConfigurationClassParser
|
||||||
* @see ConfigurationModelBeanDefinitionReader
|
* @see ConfigurationModelBeanDefinitionReader
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,12 @@ import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a class, free from java reflection,
|
* Represents a class, free from java reflection,
|
||||||
* populated by {@link ConfigurationParser}.
|
* populated by {@link ConfigurationClassParser}.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @see ConfigurationModel
|
* @see ConfigurationModel
|
||||||
* @see ConfigurationClass
|
* @see ConfigurationClass
|
||||||
* @see ConfigurationParser
|
* @see ConfigurationClassParser
|
||||||
*/
|
*/
|
||||||
class ModelClass implements BeanMetadataElement {
|
class ModelClass implements BeanMetadataElement {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ConfigurationParser;
|
import org.springframework.context.annotation.ConfigurationClassParser;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
import test.beans.TestBean;
|
import test.beans.TestBean;
|
||||||
|
|
@ -34,7 +34,7 @@ import test.beans.TestBean;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCircularImportDetectionTests {
|
public abstract class AbstractCircularImportDetectionTests {
|
||||||
|
|
||||||
protected abstract ConfigurationParser newParser();
|
protected abstract ConfigurationClassParser newParser();
|
||||||
|
|
||||||
protected abstract String loadAsConfigurationSource(Class<?> clazz) throws Exception;
|
protected abstract String loadAsConfigurationSource(Class<?> clazz) throws Exception;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.annotation;
|
||||||
|
|
||||||
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
|
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
|
||||||
import org.springframework.context.annotation.ConfigurationParser;
|
import org.springframework.context.annotation.ConfigurationClassParser;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test proving that ASM-based {@link ConfigurationParser} correctly detects circular use of
|
* Unit test proving that ASM-based {@link ConfigurationClassParser} correctly detects circular use of
|
||||||
* the {@link Import @Import} annotation.
|
* the {@link Import @Import} annotation.
|
||||||
*
|
*
|
||||||
* <p>While this test is the only subclass of {@link AbstractCircularImportDetectionTests}, the
|
* <p>While this test is the only subclass of {@link AbstractCircularImportDetectionTests}, the
|
||||||
|
|
@ -33,8 +33,8 @@ import org.springframework.util.ClassUtils;
|
||||||
*/
|
*/
|
||||||
public class AsmCircularImportDetectionTests extends AbstractCircularImportDetectionTests {
|
public class AsmCircularImportDetectionTests extends AbstractCircularImportDetectionTests {
|
||||||
@Override
|
@Override
|
||||||
protected ConfigurationParser newParser() {
|
protected ConfigurationClassParser newParser() {
|
||||||
return new ConfigurationParser(new FailFastProblemReporter(), ClassUtils.getDefaultClassLoader());
|
return new ConfigurationClassParser(new FailFastProblemReporter(), ClassUtils.getDefaultClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue