Browse Source

Rename ExecutorContext => SpecificationContext

pull/7/head
Chris Beams 14 years ago
parent
commit
2d76dde611
  1. 24
      org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java
  2. 12
      org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScanExecutor.java
  3. 18
      org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
  4. 28
      org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
  5. 4
      org.springframework.context/src/main/java/org/springframework/context/config/AbstractFeatureSpecification.java
  6. 10
      org.springframework.context/src/main/java/org/springframework/context/config/AbstractSpecificationExecutor.java
  7. 2
      org.springframework.context/src/main/java/org/springframework/context/config/FeatureSpecification.java
  8. 2
      org.springframework.context/src/main/java/org/springframework/context/config/FeatureSpecificationExecutor.java
  9. 4
      org.springframework.context/src/main/java/org/springframework/context/config/SpecificationContext.java
  10. 20
      org.springframework.context/src/test/java/org/springframework/context/annotation/ComponentScanExecutorTests.java
  11. 4
      org.springframework.context/src/test/java/org/springframework/context/annotation/SimpleFeatureMethodProcessingTests.java
  12. 4
      org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/StubSpecification.java
  13. 20
      org.springframework.transaction/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java
  14. 8
      org.springframework.transaction/src/main/java/org/springframework/transaction/config/TxAnnotationDrivenExecutor.java
  15. 12
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
  16. 20
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java
  17. 2
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcAnnotationDriven.java
  18. 6
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcAnnotationDrivenExecutor.java
  19. 8
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcDefaultServletHandlerExecutor.java
  20. 8
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcResourcesExecutor.java
  21. 8
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcViewControllersExecutor.java
  22. 20
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java
  23. 20
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java

24
org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java

@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition; @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.xml.XmlReaderContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@ -74,22 +74,22 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser { @@ -74,22 +74,22 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
.autowireCandidatePatterns(parserContext.getDelegate().getAutowireCandidatePatterns())
.source(readerContext.extractSource(element))
.sourceName(element.getTagName())
.execute(createExecutorContext(parserContext));
.execute(createSpecificationContext(parserContext));
return null;
}
// Adapt the given ParserContext instance into an ExecutorContext.
// TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter utility
// Adapt the given ParserContext instance into an SpecificationContext.
// TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter utility
// or otherwise unify these two types
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
executorContext.setEnvironment(parserContext.getDelegate().getEnvironment());
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return executorContext;
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext specificationContext = new SpecificationContext();
specificationContext.setRegistry(parserContext.getRegistry());
specificationContext.setRegistrar(parserContext);
specificationContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
specificationContext.setEnvironment(parserContext.getDelegate().getEnvironment());
specificationContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return specificationContext;
}
}

12
org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScanExecutor.java

@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition; @@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.filter.TypeFilter;
@ -44,10 +44,10 @@ final class ComponentScanExecutor extends AbstractSpecificationExecutor<Componen @@ -44,10 +44,10 @@ final class ComponentScanExecutor extends AbstractSpecificationExecutor<Componen
* the given specification and perform actual scanning and bean definition
* registration.
*/
protected void doExecute(ComponentScanSpec spec, ExecutorContext executorContext) {
BeanDefinitionRegistry registry = executorContext.getRegistry();
ResourceLoader resourceLoader = executorContext.getResourceLoader();
Environment environment = executorContext.getEnvironment();
protected void doExecute(ComponentScanSpec spec, SpecificationContext specificationContext) {
BeanDefinitionRegistry registry = specificationContext.getRegistry();
ResourceLoader resourceLoader = specificationContext.getResourceLoader();
Environment environment = specificationContext.getEnvironment();
ClassPathBeanDefinitionScanner scanner = spec.useDefaultFilters() == null ?
new ClassPathBeanDefinitionScanner(registry) :
@ -104,7 +104,7 @@ final class ComponentScanExecutor extends AbstractSpecificationExecutor<Componen @@ -104,7 +104,7 @@ final class ComponentScanExecutor extends AbstractSpecificationExecutor<Componen
}
}
executorContext.getRegistrar().registerComponent(compositeDef);
specificationContext.getRegistrar().registerComponent(compositeDef);
}
}

18
org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java

@ -44,7 +44,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; @@ -44,7 +44,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.context.config.FeatureSpecification;
import org.springframework.core.Conventions;
import org.springframework.core.env.Environment;
@ -91,7 +91,7 @@ class ConfigurationClassBeanDefinitionReader { @@ -91,7 +91,7 @@ class ConfigurationClassBeanDefinitionReader {
private final MetadataReaderFactory metadataReaderFactory;
private ExecutorContext executorContext;
private SpecificationContext specificationContext;
/**
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used
@ -107,12 +107,12 @@ class ConfigurationClassBeanDefinitionReader { @@ -107,12 +107,12 @@ class ConfigurationClassBeanDefinitionReader {
this.sourceExtractor = sourceExtractor;
this.problemReporter = problemReporter;
this.metadataReaderFactory = metadataReaderFactory;
this.executorContext = new ExecutorContext();
this.executorContext.setRegistry(this.registry);
this.executorContext.setRegistrar(new SimpleComponentRegistrar(this.registry));
this.executorContext.setResourceLoader(resourceLoader);
this.executorContext.setEnvironment(environment);
this.executorContext.setProblemReporter(problemReporter);
this.specificationContext = new SpecificationContext();
this.specificationContext.setRegistry(this.registry);
this.specificationContext.setRegistrar(new SimpleComponentRegistrar(this.registry));
this.specificationContext.setResourceLoader(resourceLoader);
this.specificationContext.setEnvironment(environment);
this.specificationContext.setProblemReporter(problemReporter);
}
@ -149,7 +149,7 @@ class ConfigurationClassBeanDefinitionReader { @@ -149,7 +149,7 @@ class ConfigurationClassBeanDefinitionReader {
// TODO SPR-7420: this is where we can catch user-defined types and avoid instantiating them for STS purposes
FeatureAnnotationParser processor = (FeatureAnnotationParser) BeanUtils.instantiateClass(Class.forName((String)annotationAttributes.get("parser")));
FeatureSpecification spec = processor.process(metadata);
spec.execute(this.executorContext);
spec.execute(this.specificationContext);
}
}
} catch (BeanDefinitionParsingException ex) {

28
org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java

@ -47,7 +47,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -47,7 +47,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.context.config.FeatureSpecification;
import org.springframework.context.config.SourceAwareSpecification;
import org.springframework.core.MethodParameter;
@ -224,13 +224,13 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo @@ -224,13 +224,13 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
}
final EarlyBeanReferenceProxyCreator proxyCreator = new EarlyBeanReferenceProxyCreator(beanFactory);
final ExecutorContext executorContext = createExecutorContext(beanFactory);
final SpecificationContext specificationContext = createSpecificationContext(beanFactory);
for (final Object featureConfigBean : featureConfigBeans.values()) {
ReflectionUtils.doWithMethods(featureConfigBean.getClass(),
new ReflectionUtils.MethodCallback() {
public void doWith(Method featureMethod) throws IllegalArgumentException, IllegalAccessException {
processFeatureMethod(featureMethod, featureConfigBean, executorContext, proxyCreator);
processFeatureMethod(featureMethod, featureConfigBean, specificationContext, proxyCreator);
} },
new ReflectionUtils.MethodFilter() {
public boolean matches(Method candidateMethod) {
@ -316,7 +316,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo @@ -316,7 +316,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
* @throws SecurityException
*/
private void processFeatureMethod(final Method featureMethod, Object configInstance,
ExecutorContext executorContext, EarlyBeanReferenceProxyCreator proxyCreator) {
SpecificationContext specificationContext, EarlyBeanReferenceProxyCreator proxyCreator) {
try {
// get the return type
if (!(FeatureSpecification.class.isAssignableFrom(featureMethod.getReturnType()))) {
@ -347,22 +347,24 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo @@ -347,22 +347,24 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
((SourceAwareSpecification)spec).source(featureMethod);
((SourceAwareSpecification)spec).sourceName(featureMethod.getName());
}
spec.execute(executorContext);
spec.execute(specificationContext);
} catch (Exception ex) {
throw new FeatureMethodExecutionException(ex);
}
}
private ExecutorContext createExecutorContext(ConfigurableListableBeanFactory beanFactory) {
// TODO SPR-7420: consider unifying the two through a superinterface.
// TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
private SpecificationContext createSpecificationContext(ConfigurableListableBeanFactory beanFactory) {
final BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
ExecutorContext executorContext = new ExecutorContext();
executorContext.setEnvironment(this.environment);
executorContext.setResourceLoader(this.resourceLoader);
executorContext.setRegistry(registry);
executorContext.setRegistrar(new SimpleComponentRegistrar(registry));
SpecificationContext specificationContext = new SpecificationContext();
specificationContext.setEnvironment(this.environment);
specificationContext.setResourceLoader(this.resourceLoader);
specificationContext.setRegistry(registry);
specificationContext.setRegistrar(new SimpleComponentRegistrar(registry));
// TODO SPR-7420: how to get hold of the current problem reporter here?
executorContext.setProblemReporter(new FailFastProblemReporter());
return executorContext;
specificationContext.setProblemReporter(new FailFastProblemReporter());
return specificationContext;
}
private ConfigurationClassBeanDefinitionReader getConfigurationClassBeanDefinitionReader(BeanDefinitionRegistry registry) {

4
org.springframework.context/src/main/java/org/springframework/context/config/AbstractFeatureSpecification.java

@ -69,10 +69,10 @@ public abstract class AbstractFeatureSpecification implements SourceAwareSpecifi @@ -69,10 +69,10 @@ public abstract class AbstractFeatureSpecification implements SourceAwareSpecifi
return this.sourceName;
}
public void execute(ExecutorContext executorContext) {
public void execute(SpecificationContext specificationContext) {
FeatureSpecificationExecutor executor =
BeanUtils.instantiateClass(this.executorType, FeatureSpecificationExecutor.class);
executor.execute(this, executorContext);
executor.execute(this, specificationContext);
}
}

10
org.springframework.context/src/main/java/org/springframework/context/config/AbstractSpecificationExecutor.java

@ -34,13 +34,13 @@ public abstract class AbstractSpecificationExecutor<S extends FeatureSpecificati @@ -34,13 +34,13 @@ public abstract class AbstractSpecificationExecutor<S extends FeatureSpecificati
* only if valid.
*/
@SuppressWarnings("unchecked")
public final void execute(FeatureSpecification spec, ExecutorContext executorContext) {
public final void execute(FeatureSpecification spec, SpecificationContext specificationContext) {
Assert.notNull(spec, "Specification must not be null");
Assert.notNull(spec, "ExecutorContext must not be null");
Assert.notNull(spec, "SpecificationContext must not be null");
Class<?> typeArg = GenericTypeResolver.resolveTypeArgument(this.getClass(), AbstractSpecificationExecutor.class);
Assert.isTrue(typeArg.equals(spec.getClass()), "Specification cannot be executed by this executor");
if (spec.validate(executorContext.getProblemReporter())) {
doExecute((S)spec, executorContext);
if (spec.validate(specificationContext.getProblemReporter())) {
doExecute((S)spec, specificationContext);
}
}
@ -49,6 +49,6 @@ public abstract class AbstractSpecificationExecutor<S extends FeatureSpecificati @@ -49,6 +49,6 @@ public abstract class AbstractSpecificationExecutor<S extends FeatureSpecificati
* against a bean factory.
* @param specification the {@linkplain FeatureSpecification#validate() validated} specification
*/
protected abstract void doExecute(S specification, ExecutorContext executorContext);
protected abstract void doExecute(S specification, SpecificationContext specificationContext);
}

2
org.springframework.context/src/main/java/org/springframework/context/config/FeatureSpecification.java

@ -122,6 +122,6 @@ public interface FeatureSpecification { @@ -122,6 +122,6 @@ public interface FeatureSpecification {
* specified within. Should work by delegating to an underlying
* {@link FeatureSpecificationExecutor} for proper separation of concerns.
*/
void execute(ExecutorContext executorContext);
void execute(SpecificationContext specificationContext);
}

2
org.springframework.context/src/main/java/org/springframework/context/config/FeatureSpecificationExecutor.java

@ -36,6 +36,6 @@ public interface FeatureSpecificationExecutor { @@ -36,6 +36,6 @@ public interface FeatureSpecificationExecutor {
* Execute the given specification, usually resulting in registration
* of bean definitions against a bean factory.
*/
void execute(FeatureSpecification spec, ExecutorContext executorContext);
void execute(FeatureSpecification spec, SpecificationContext specificationContext);
}

4
org.springframework.context/src/main/java/org/springframework/context/config/SpecificationContext.java

@ -28,7 +28,7 @@ import org.springframework.core.io.ResourceLoader; @@ -28,7 +28,7 @@ import org.springframework.core.io.ResourceLoader;
* @author Chris Beams
* @since 3.1
*/
public class ExecutorContext {
public class SpecificationContext {
private BeanDefinitionRegistry registry;
private ComponentRegistrar registrar;
@ -36,7 +36,7 @@ public class ExecutorContext { @@ -36,7 +36,7 @@ public class ExecutorContext {
private Environment environment;
private ProblemReporter problemReporter;
public ExecutorContext() { }
public SpecificationContext() { }
public void setRegistry(BeanDefinitionRegistry registry) {
this.registry = registry;

20
org.springframework.context/src/test/java/org/springframework/context/annotation/ComponentScanExecutorTests.java

@ -24,7 +24,7 @@ import org.junit.Test; @@ -24,7 +24,7 @@ import org.junit.Test;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.mock.env.MockEnvironment;
@ -37,31 +37,31 @@ import org.springframework.mock.env.MockEnvironment; @@ -37,31 +37,31 @@ import org.springframework.mock.env.MockEnvironment;
public class ComponentScanExecutorTests {
private ComponentScanExecutor executor;
private ExecutorContext executorContext;
private SpecificationContext specificationContext;
private DefaultListableBeanFactory bf;
@Before
public void setUp() {
this.bf = new DefaultListableBeanFactory();
this.executor = new ComponentScanExecutor();
this.executorContext = new ExecutorContext();
this.executorContext.setRegistry(bf);
this.executorContext.setResourceLoader(new DefaultResourceLoader());
this.executorContext.setEnvironment(new MockEnvironment());
this.executorContext.setRegistrar(new SimpleComponentRegistrar(bf));
this.executorContext.setProblemReporter(new FailFastProblemReporter());
this.specificationContext = new SpecificationContext();
this.specificationContext.setRegistry(bf);
this.specificationContext.setResourceLoader(new DefaultResourceLoader());
this.specificationContext.setEnvironment(new MockEnvironment());
this.specificationContext.setRegistrar(new SimpleComponentRegistrar(bf));
this.specificationContext.setProblemReporter(new FailFastProblemReporter());
}
@Test
public void validSpec() {
this.executor.execute(new ComponentScanSpec("example.scannable"), this.executorContext);
this.executor.execute(new ComponentScanSpec("example.scannable"), this.specificationContext);
assertThat(bf.containsBean("fooServiceImpl"), is(true));
}
@Test(expected=BeanDefinitionParsingException.class)
public void invalidSpec() {
// ff problem reporter should throw due to no packages specified
this.executor.execute(new ComponentScanSpec(), this.executorContext);
this.executor.execute(new ComponentScanSpec(), this.specificationContext);
}
}

4
org.springframework.context/src/test/java/org/springframework/context/annotation/SimpleFeatureMethodProcessingTests.java

@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat; @@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.context.annotation.configuration.StubSpecification;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.context.config.FeatureSpecification;
import org.springframework.context.config.FeatureSpecificationExecutor;
import org.springframework.util.Assert;
@ -55,7 +55,7 @@ public class SimpleFeatureMethodProcessingTests { @@ -55,7 +55,7 @@ public class SimpleFeatureMethodProcessingTests {
static class MySpecificationExecutor implements FeatureSpecificationExecutor {
static boolean executeMethodWasCalled = false;
public void execute(FeatureSpecification spec, ExecutorContext executorContext) {
public void execute(FeatureSpecification spec, SpecificationContext specificationContext) {
Assert.state(executeMethodWasCalled == false);
executeMethodWasCalled = true;
}

4
org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/StubSpecification.java

@ -18,9 +18,9 @@ package org.springframework.context.annotation.configuration; @@ -18,9 +18,9 @@ package org.springframework.context.annotation.configuration;
import org.springframework.beans.factory.parsing.ProblemCollector;
import org.springframework.context.config.AbstractFeatureSpecification;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.FeatureSpecification;
import org.springframework.context.config.FeatureSpecificationExecutor;
import org.springframework.context.config.SpecificationContext;
public class StubSpecification extends AbstractFeatureSpecification {
@ -40,7 +40,7 @@ public class StubSpecification extends AbstractFeatureSpecification { @@ -40,7 +40,7 @@ public class StubSpecification extends AbstractFeatureSpecification {
class StubSpecificationExecutor implements FeatureSpecificationExecutor {
public void execute(FeatureSpecification spec, ExecutorContext executorContext) {
public void execute(FeatureSpecification spec, SpecificationContext specificationContext) {
}
}

20
org.springframework.transaction/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java

@ -20,7 +20,7 @@ import org.springframework.aop.config.AopNamespaceUtils; @@ -20,7 +20,7 @@ import org.springframework.aop.config.AopNamespaceUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.w3c.dom.Element;
/**
@ -68,22 +68,22 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { @@ -68,22 +68,22 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
.proxyTargetClass(Boolean.valueOf(element.getAttribute("proxy-target-class")))
.source(parserContext.extractSource(element))
.sourceName(element.getTagName())
.execute(createExecutorContext(parserContext));
.execute(createSpecificationContext(parserContext));
return null;
}
/**
* Adapt the given ParserContext instance into an ExecutorContext.
* Adapt the given ParserContext instance into an SpecificationContext.
*
* TODO SPR-7420: consider unifying the two through a superinterface.
* TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter util
* TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
*/
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return executorContext;
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext specificationContext = new SpecificationContext();
specificationContext.setRegistry(parserContext.getRegistry());
specificationContext.setRegistrar(parserContext);
specificationContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return specificationContext;
}
}

8
org.springframework.transaction/src/main/java/org/springframework/transaction/config/TxAnnotationDrivenExecutor.java

@ -25,7 +25,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition; @@ -25,7 +25,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;
import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor;
import org.springframework.transaction.interceptor.TransactionInterceptor;
@ -56,9 +56,9 @@ final class TxAnnotationDrivenExecutor extends AbstractSpecificationExecutor<TxA @@ -56,9 +56,9 @@ final class TxAnnotationDrivenExecutor extends AbstractSpecificationExecutor<TxA
@Override
protected void doExecute(TxAnnotationDriven txSpec, ExecutorContext executorContext) {
BeanDefinitionRegistry registry = executorContext.getRegistry();
ComponentRegistrar registrar = executorContext.getRegistrar();
protected void doExecute(TxAnnotationDriven txSpec, SpecificationContext specificationContext) {
BeanDefinitionRegistry registry = specificationContext.getRegistry();
ComponentRegistrar registrar = specificationContext.getRegistrar();
switch (txSpec.mode()) {
case ASPECTJ:
registerTransactionAspect(txSpec, registry, registrar);

12
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java

@ -21,7 +21,7 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder; @@ -21,7 +21,7 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
@ -41,7 +41,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { @@ -41,7 +41,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
*/
public BeanDefinition parse(Element element, ParserContext parserContext) {
MvcAnnotationDriven spec = createSpecification(element, parserContext);
spec.execute(createExecutorContext(parserContext));
spec.execute(createSpecificationContext(parserContext));
return null;
}
@ -87,13 +87,13 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { @@ -87,13 +87,13 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
}
/**
* Adapt the given ParserContext instance into an ExecutorContext.
* Adapt the given ParserContext instance into an SpecificationContext.
*
* TODO SPR-7420: consider unifying the two through a superinterface.
* TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter util
* TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
*/
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext executorContext = new SpecificationContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());

20
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java

@ -19,7 +19,7 @@ package org.springframework.web.servlet.config; @@ -19,7 +19,7 @@ package org.springframework.web.servlet.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
@ -42,7 +42,7 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser @@ -42,7 +42,7 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser
*/
public BeanDefinition parse(Element element, ParserContext parserContext) {
MvcDefaultServletHandler spec = createSpecification(element, parserContext);
spec.execute(createExecutorContext(parserContext));
spec.execute(createSpecificationContext(parserContext));
return null;
}
@ -54,17 +54,17 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser @@ -54,17 +54,17 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser
}
/**
* Adapt the given ParserContext instance into an ExecutorContext.
* Adapt the given ParserContext instance into an SpecificationContext.
*
* TODO SPR-7420: consider unifying the two through a superinterface.
* TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter util
* TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
*/
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return executorContext;
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext context = new SpecificationContext();
context.setRegistry(parserContext.getRegistry());
context.setRegistrar(parserContext);
context.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return context;
}
}

2
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcAnnotationDriven.java

@ -154,7 +154,7 @@ public final class MvcAnnotationDriven extends AbstractFeatureSpecification { @@ -154,7 +154,7 @@ public final class MvcAnnotationDriven extends AbstractFeatureSpecification {
/**
* Indicates whether or not default HttpMessageConverter registrations should
* be added in addition to the ones provided via
* {@link #messageConverters(HttpMessageConverter...).
* {@link #messageConverters(HttpMessageConverter...)}
*
* @param shouldRegister true will result in registration of defaults.
*/

6
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcAnnotationDrivenExecutor.java

@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition; @@ -23,7 +23,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
@ -74,8 +74,8 @@ final class MvcAnnotationDrivenExecutor extends AbstractSpecificationExecutor<Mv @@ -74,8 +74,8 @@ final class MvcAnnotationDrivenExecutor extends AbstractSpecificationExecutor<Mv
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
@Override
public void doExecute(MvcAnnotationDriven spec, ExecutorContext executorContext) {
ComponentRegistrar registrar = executorContext.getRegistrar();
public void doExecute(MvcAnnotationDriven spec, SpecificationContext specContext) {
ComponentRegistrar registrar = specContext.getRegistrar();
Object source = spec.source();
RootBeanDefinition annMappingDef = new RootBeanDefinition(DefaultAnnotationHandlerMapping.class);

8
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcDefaultServletHandlerExecutor.java

@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
@ -45,9 +45,9 @@ final class MvcDefaultServletHandlerExecutor extends AbstractSpecificationExecut @@ -45,9 +45,9 @@ final class MvcDefaultServletHandlerExecutor extends AbstractSpecificationExecut
private static final String HANDLER_ADAPTER_BEAN_NAME = "org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter";
@Override
protected void doExecute(MvcDefaultServletHandler spec, ExecutorContext executorContext) {
BeanDefinitionRegistry registry = executorContext.getRegistry();
ComponentRegistrar registrar = executorContext.getRegistrar();
protected void doExecute(MvcDefaultServletHandler spec, SpecificationContext specContext) {
BeanDefinitionRegistry registry = specContext.getRegistry();
ComponentRegistrar registrar = specContext.getRegistrar();
Object source = spec.source();
if (!registry.containsBeanDefinition(HANDLER_ADAPTER_BEAN_NAME)) {

8
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcResourcesExecutor.java

@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
@ -44,9 +44,9 @@ final class MvcResourcesExecutor extends AbstractSpecificationExecutor<MvcResour @@ -44,9 +44,9 @@ final class MvcResourcesExecutor extends AbstractSpecificationExecutor<MvcResour
private static final String HANDLER_ADAPTER_BEAN_NAME = "org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter";
@Override
protected void doExecute(MvcResources spec, ExecutorContext executorContext) {
BeanDefinitionRegistry registry = executorContext.getRegistry();
ComponentRegistrar registrar = executorContext.getRegistrar();
protected void doExecute(MvcResources spec, SpecificationContext specContext) {
BeanDefinitionRegistry registry = specContext.getRegistry();
ComponentRegistrar registrar = specContext.getRegistrar();
Object source = spec.source();
if (!registry.containsBeanDefinition(HANDLER_ADAPTER_BEAN_NAME)) {

8
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/MvcViewControllersExecutor.java

@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.config.AbstractSpecificationExecutor;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
@ -44,9 +44,9 @@ final class MvcViewControllersExecutor extends AbstractSpecificationExecutor<Mvc @@ -44,9 +44,9 @@ final class MvcViewControllersExecutor extends AbstractSpecificationExecutor<Mvc
private static final String HANDLER_MAPPING_BEAN_NAME = "org.springframework.web.servlet.config.viewControllerHandlerMapping";
@Override
protected void doExecute(MvcViewControllers spec, ExecutorContext executorContext) {
BeanDefinitionRegistry registry = executorContext.getRegistry();
ComponentRegistrar registrar = executorContext.getRegistrar();
protected void doExecute(MvcViewControllers spec, SpecificationContext specContext) {
BeanDefinitionRegistry registry = specContext.getRegistry();
ComponentRegistrar registrar = specContext.getRegistrar();
Object source = spec.source();
if (!registry.containsBeanDefinition(HANDLER_ADAPTER_BEAN_NAME)) {

20
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java

@ -19,7 +19,7 @@ package org.springframework.web.servlet.config; @@ -19,7 +19,7 @@ package org.springframework.web.servlet.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
@ -40,7 +40,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { @@ -40,7 +40,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
public BeanDefinition parse(Element element, ParserContext parserContext) {
MvcResources spec = createSpecification(element, parserContext);
if (spec != null) {
spec.execute(createExecutorContext(parserContext));
spec.execute(createSpecificationContext(parserContext));
}
return null;
}
@ -71,17 +71,17 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { @@ -71,17 +71,17 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
}
/**
* Adapt the given ParserContext instance into an ExecutorContext.
* Adapt the given ParserContext instance into an SpecificationContext.
*
* TODO SPR-7420: consider unifying the two through a superinterface.
* TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter util
* TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
*/
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return executorContext;
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext context = new SpecificationContext();
context.setRegistry(parserContext.getRegistry());
context.setRegistrar(parserContext);
context.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return context;
}
}

20
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java

@ -19,7 +19,7 @@ package org.springframework.web.servlet.config; @@ -19,7 +19,7 @@ package org.springframework.web.servlet.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.config.ExecutorContext;
import org.springframework.context.config.SpecificationContext;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.w3c.dom.Element;
@ -43,22 +43,22 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser { @@ -43,22 +43,22 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser {
new MvcViewControllers(path, viewName.isEmpty() ? null : viewName)
.source(parserContext.extractSource(element))
.sourceName(element.getTagName())
.execute(createExecutorContext(parserContext));
.execute(createSpecificationContext(parserContext));
return null;
}
/**
* Adapt the given ParserContext instance into an ExecutorContext.
* Adapt the given ParserContext instance into an SpecificationContext.
*
* TODO SPR-7420: consider unifying the two through a superinterface.
* TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter util
* TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
*/
private ExecutorContext createExecutorContext(ParserContext parserContext) {
ExecutorContext executorContext = new ExecutorContext();
executorContext.setRegistry(parserContext.getRegistry());
executorContext.setRegistrar(parserContext);
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return executorContext;
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
SpecificationContext context = new SpecificationContext();
context.setRegistry(parserContext.getRegistry());
context.setRegistrar(parserContext);
context.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
return context;
}
}

Loading…
Cancel
Save