Rename ExecutorContext => SpecificationContext

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3961 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Chris Beams 2011-02-08 19:08:41 +00:00
parent df4edc1c73
commit f8a4dfa5da
23 changed files with 133 additions and 131 deletions

View File

@ -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 {
.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;
}
}

View File

@ -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
* 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
}
}
executorContext.getRegistrar().registerComponent(compositeDef);
specificationContext.getRegistrar().registerComponent(compositeDef);
}
}

View File

@ -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 {
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 {
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 {
// 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) {

View File

@ -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
}
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
* @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
((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) {

View File

@ -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);
}
}

View File

@ -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
* 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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 {
private Environment environment;
private ProblemReporter problemReporter;
public ExecutorContext() { }
public SpecificationContext() { }
public void setRegistry(BeanDefinitionRegistry registry) {
this.registry = registry;

View File

@ -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;
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);
}
}

View File

@ -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 {
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;
}

View File

@ -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 {
class StubSpecificationExecutor implements FeatureSpecificationExecutor {
public void execute(FeatureSpecification spec, ExecutorContext executorContext) {
public void execute(FeatureSpecification spec, SpecificationContext specificationContext) {
}
}

View File

@ -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 {
.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;
}
}

View File

@ -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
@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);

View File

@ -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 {
*/
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 {
}
/**
* 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());

View File

@ -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
*/
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
}
/**
* 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;
}
}

View File

@ -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.
*/

View File

@ -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
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);

View File

@ -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
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)) {

View File

@ -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
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)) {

View File

@ -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
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)) {

View File

@ -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 {
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 {
}
/**
* 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;
}
}

View File

@ -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 {
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;
}
}