Skip to content

Commit 2d76dde

Browse files
committed
Rename ExecutorContext => SpecificationContext
1 parent c506300 commit 2d76dde

23 files changed

+133
-131
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.springframework.beans.factory.xml.BeanDefinitionParser;
2121
import org.springframework.beans.factory.xml.ParserContext;
2222
import org.springframework.beans.factory.xml.XmlReaderContext;
23-
import org.springframework.context.config.ExecutorContext;
23+
import org.springframework.context.config.SpecificationContext;
2424
import org.w3c.dom.Element;
2525
import org.w3c.dom.Node;
2626
import org.w3c.dom.NodeList;
@@ -74,22 +74,22 @@ else if ("exclude-filter".equals(localName)) {
7474
.autowireCandidatePatterns(parserContext.getDelegate().getAutowireCandidatePatterns())
7575
.source(readerContext.extractSource(element))
7676
.sourceName(element.getTagName())
77-
.execute(createExecutorContext(parserContext));
77+
.execute(createSpecificationContext(parserContext));
7878
return null;
7979
}
8080

8181

82-
// Adapt the given ParserContext instance into an ExecutorContext.
83-
// TODO SPR-7420: create a common ParserContext-to-ExecutorContext adapter utility
82+
// Adapt the given ParserContext instance into an SpecificationContext.
83+
// TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter utility
8484
// or otherwise unify these two types
85-
private ExecutorContext createExecutorContext(ParserContext parserContext) {
86-
ExecutorContext executorContext = new ExecutorContext();
87-
executorContext.setRegistry(parserContext.getRegistry());
88-
executorContext.setRegistrar(parserContext);
89-
executorContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
90-
executorContext.setEnvironment(parserContext.getDelegate().getEnvironment());
91-
executorContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
92-
return executorContext;
85+
private SpecificationContext createSpecificationContext(ParserContext parserContext) {
86+
SpecificationContext specificationContext = new SpecificationContext();
87+
specificationContext.setRegistry(parserContext.getRegistry());
88+
specificationContext.setRegistrar(parserContext);
89+
specificationContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
90+
specificationContext.setEnvironment(parserContext.getDelegate().getEnvironment());
91+
specificationContext.setProblemReporter(parserContext.getReaderContext().getProblemReporter());
92+
return specificationContext;
9393
}
9494

9595
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
2424
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
2525
import org.springframework.context.config.AbstractSpecificationExecutor;
26-
import org.springframework.context.config.ExecutorContext;
26+
import org.springframework.context.config.SpecificationContext;
2727
import org.springframework.core.env.Environment;
2828
import org.springframework.core.io.ResourceLoader;
2929
import org.springframework.core.type.filter.TypeFilter;
@@ -44,10 +44,10 @@ final class ComponentScanExecutor extends AbstractSpecificationExecutor<Componen
4444
* the given specification and perform actual scanning and bean definition
4545
* registration.
4646
*/
47-
protected void doExecute(ComponentScanSpec spec, ExecutorContext executorContext) {
48-
BeanDefinitionRegistry registry = executorContext.getRegistry();
49-
ResourceLoader resourceLoader = executorContext.getResourceLoader();
50-
Environment environment = executorContext.getEnvironment();
47+
protected void doExecute(ComponentScanSpec spec, SpecificationContext specificationContext) {
48+
BeanDefinitionRegistry registry = specificationContext.getRegistry();
49+
ResourceLoader resourceLoader = specificationContext.getResourceLoader();
50+
Environment environment = specificationContext.getEnvironment();
5151

5252
ClassPathBeanDefinitionScanner scanner = spec.useDefaultFilters() == null ?
5353
new ClassPathBeanDefinitionScanner(registry) :
@@ -104,7 +104,7 @@ protected void doExecute(ComponentScanSpec spec, ExecutorContext executorContext
104104
}
105105
}
106106

107-
executorContext.getRegistrar().registerComponent(compositeDef);
107+
specificationContext.getRegistrar().registerComponent(compositeDef);
108108
}
109109

110110
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
4545
import org.springframework.beans.factory.support.GenericBeanDefinition;
4646
import org.springframework.beans.factory.support.RootBeanDefinition;
47-
import org.springframework.context.config.ExecutorContext;
47+
import org.springframework.context.config.SpecificationContext;
4848
import org.springframework.context.config.FeatureSpecification;
4949
import org.springframework.core.Conventions;
5050
import org.springframework.core.env.Environment;
@@ -91,7 +91,7 @@ class ConfigurationClassBeanDefinitionReader {
9191

9292
private final MetadataReaderFactory metadataReaderFactory;
9393

94-
private ExecutorContext executorContext;
94+
private SpecificationContext specificationContext;
9595

9696
/**
9797
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used
@@ -107,12 +107,12 @@ public ConfigurationClassBeanDefinitionReader(final BeanDefinitionRegistry regis
107107
this.sourceExtractor = sourceExtractor;
108108
this.problemReporter = problemReporter;
109109
this.metadataReaderFactory = metadataReaderFactory;
110-
this.executorContext = new ExecutorContext();
111-
this.executorContext.setRegistry(this.registry);
112-
this.executorContext.setRegistrar(new SimpleComponentRegistrar(this.registry));
113-
this.executorContext.setResourceLoader(resourceLoader);
114-
this.executorContext.setEnvironment(environment);
115-
this.executorContext.setProblemReporter(problemReporter);
110+
this.specificationContext = new SpecificationContext();
111+
this.specificationContext.setRegistry(this.registry);
112+
this.specificationContext.setRegistrar(new SimpleComponentRegistrar(this.registry));
113+
this.specificationContext.setResourceLoader(resourceLoader);
114+
this.specificationContext.setEnvironment(environment);
115+
this.specificationContext.setProblemReporter(problemReporter);
116116
}
117117

118118

@@ -149,7 +149,7 @@ private void processFeatureAnnotations(AnnotationMetadata metadata) {
149149
// TODO SPR-7420: this is where we can catch user-defined types and avoid instantiating them for STS purposes
150150
FeatureAnnotationParser processor = (FeatureAnnotationParser) BeanUtils.instantiateClass(Class.forName((String)annotationAttributes.get("parser")));
151151
FeatureSpecification spec = processor.process(metadata);
152-
spec.execute(this.executorContext);
152+
spec.execute(this.specificationContext);
153153
}
154154
}
155155
} catch (BeanDefinitionParsingException ex) {

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
4848
import org.springframework.context.EnvironmentAware;
4949
import org.springframework.context.ResourceLoaderAware;
50-
import org.springframework.context.config.ExecutorContext;
50+
import org.springframework.context.config.SpecificationContext;
5151
import org.springframework.context.config.FeatureSpecification;
5252
import org.springframework.context.config.SourceAwareSpecification;
5353
import org.springframework.core.MethodParameter;
@@ -224,13 +224,13 @@ private void processFeatureConfigurationClasses(final ConfigurableListableBeanFa
224224
}
225225

226226
final EarlyBeanReferenceProxyCreator proxyCreator = new EarlyBeanReferenceProxyCreator(beanFactory);
227-
final ExecutorContext executorContext = createExecutorContext(beanFactory);
227+
final SpecificationContext specificationContext = createSpecificationContext(beanFactory);
228228

229229
for (final Object featureConfigBean : featureConfigBeans.values()) {
230230
ReflectionUtils.doWithMethods(featureConfigBean.getClass(),
231231
new ReflectionUtils.MethodCallback() {
232232
public void doWith(Method featureMethod) throws IllegalArgumentException, IllegalAccessException {
233-
processFeatureMethod(featureMethod, featureConfigBean, executorContext, proxyCreator);
233+
processFeatureMethod(featureMethod, featureConfigBean, specificationContext, proxyCreator);
234234
} },
235235
new ReflectionUtils.MethodFilter() {
236236
public boolean matches(Method candidateMethod) {
@@ -316,7 +316,7 @@ public boolean matches(Method candidateMethod) {
316316
* @throws SecurityException
317317
*/
318318
private void processFeatureMethod(final Method featureMethod, Object configInstance,
319-
ExecutorContext executorContext, EarlyBeanReferenceProxyCreator proxyCreator) {
319+
SpecificationContext specificationContext, EarlyBeanReferenceProxyCreator proxyCreator) {
320320
try {
321321
// get the return type
322322
if (!(FeatureSpecification.class.isAssignableFrom(featureMethod.getReturnType()))) {
@@ -347,22 +347,24 @@ private void processFeatureMethod(final Method featureMethod, Object configInsta
347347
((SourceAwareSpecification)spec).source(featureMethod);
348348
((SourceAwareSpecification)spec).sourceName(featureMethod.getName());
349349
}
350-
spec.execute(executorContext);
350+
spec.execute(specificationContext);
351351
} catch (Exception ex) {
352352
throw new FeatureMethodExecutionException(ex);
353353
}
354354
}
355355

356-
private ExecutorContext createExecutorContext(ConfigurableListableBeanFactory beanFactory) {
356+
// TODO SPR-7420: consider unifying the two through a superinterface.
357+
// TODO SPR-7420: create a common ParserContext-to-SpecificationContext adapter util
358+
private SpecificationContext createSpecificationContext(ConfigurableListableBeanFactory beanFactory) {
357359
final BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
358-
ExecutorContext executorContext = new ExecutorContext();
359-
executorContext.setEnvironment(this.environment);
360-
executorContext.setResourceLoader(this.resourceLoader);
361-
executorContext.setRegistry(registry);
362-
executorContext.setRegistrar(new SimpleComponentRegistrar(registry));
360+
SpecificationContext specificationContext = new SpecificationContext();
361+
specificationContext.setEnvironment(this.environment);
362+
specificationContext.setResourceLoader(this.resourceLoader);
363+
specificationContext.setRegistry(registry);
364+
specificationContext.setRegistrar(new SimpleComponentRegistrar(registry));
363365
// TODO SPR-7420: how to get hold of the current problem reporter here?
364-
executorContext.setProblemReporter(new FailFastProblemReporter());
365-
return executorContext;
366+
specificationContext.setProblemReporter(new FailFastProblemReporter());
367+
return specificationContext;
366368
}
367369

368370
private ConfigurationClassBeanDefinitionReader getConfigurationClassBeanDefinitionReader(BeanDefinitionRegistry registry) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public String sourceName() {
6969
return this.sourceName;
7070
}
7171

72-
public void execute(ExecutorContext executorContext) {
72+
public void execute(SpecificationContext specificationContext) {
7373
FeatureSpecificationExecutor executor =
7474
BeanUtils.instantiateClass(this.executorType, FeatureSpecificationExecutor.class);
75-
executor.execute(this, executorContext);
75+
executor.execute(this, specificationContext);
7676
}
7777

7878
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public abstract class AbstractSpecificationExecutor<S extends FeatureSpecificati
3434
* only if valid.
3535
*/
3636
@SuppressWarnings("unchecked")
37-
public final void execute(FeatureSpecification spec, ExecutorContext executorContext) {
37+
public final void execute(FeatureSpecification spec, SpecificationContext specificationContext) {
3838
Assert.notNull(spec, "Specification must not be null");
39-
Assert.notNull(spec, "ExecutorContext must not be null");
39+
Assert.notNull(spec, "SpecificationContext must not be null");
4040
Class<?> typeArg = GenericTypeResolver.resolveTypeArgument(this.getClass(), AbstractSpecificationExecutor.class);
4141
Assert.isTrue(typeArg.equals(spec.getClass()), "Specification cannot be executed by this executor");
42-
if (spec.validate(executorContext.getProblemReporter())) {
43-
doExecute((S)spec, executorContext);
42+
if (spec.validate(specificationContext.getProblemReporter())) {
43+
doExecute((S)spec, specificationContext);
4444
}
4545
}
4646

@@ -49,6 +49,6 @@ public final void execute(FeatureSpecification spec, ExecutorContext executorCon
4949
* against a bean factory.
5050
* @param specification the {@linkplain FeatureSpecification#validate() validated} specification
5151
*/
52-
protected abstract void doExecute(S specification, ExecutorContext executorContext);
52+
protected abstract void doExecute(S specification, SpecificationContext specificationContext);
5353

5454
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ public interface FeatureSpecification {
122122
* specified within. Should work by delegating to an underlying
123123
* {@link FeatureSpecificationExecutor} for proper separation of concerns.
124124
*/
125-
void execute(ExecutorContext executorContext);
125+
void execute(SpecificationContext specificationContext);
126126

127127
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public interface FeatureSpecificationExecutor {
3636
* Execute the given specification, usually resulting in registration
3737
* of bean definitions against a bean factory.
3838
*/
39-
void execute(FeatureSpecification spec, ExecutorContext executorContext);
39+
void execute(FeatureSpecification spec, SpecificationContext specificationContext);
4040

4141
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
* @author Chris Beams
2929
* @since 3.1
3030
*/
31-
public class ExecutorContext {
31+
public class SpecificationContext {
3232

3333
private BeanDefinitionRegistry registry;
3434
private ComponentRegistrar registrar;
3535
private ResourceLoader resourceLoader;
3636
private Environment environment;
3737
private ProblemReporter problemReporter;
3838

39-
public ExecutorContext() { }
39+
public SpecificationContext() { }
4040

4141
public void setRegistry(BeanDefinitionRegistry registry) {
4242
this.registry = registry;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
2525
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
2626
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
27-
import org.springframework.context.config.ExecutorContext;
27+
import org.springframework.context.config.SpecificationContext;
2828
import org.springframework.core.io.DefaultResourceLoader;
2929
import org.springframework.mock.env.MockEnvironment;
3030

@@ -37,31 +37,31 @@
3737
public class ComponentScanExecutorTests {
3838

3939
private ComponentScanExecutor executor;
40-
private ExecutorContext executorContext;
40+
private SpecificationContext specificationContext;
4141
private DefaultListableBeanFactory bf;
4242

4343
@Before
4444
public void setUp() {
4545
this.bf = new DefaultListableBeanFactory();
4646
this.executor = new ComponentScanExecutor();
47-
this.executorContext = new ExecutorContext();
48-
this.executorContext.setRegistry(bf);
49-
this.executorContext.setResourceLoader(new DefaultResourceLoader());
50-
this.executorContext.setEnvironment(new MockEnvironment());
51-
this.executorContext.setRegistrar(new SimpleComponentRegistrar(bf));
52-
this.executorContext.setProblemReporter(new FailFastProblemReporter());
47+
this.specificationContext = new SpecificationContext();
48+
this.specificationContext.setRegistry(bf);
49+
this.specificationContext.setResourceLoader(new DefaultResourceLoader());
50+
this.specificationContext.setEnvironment(new MockEnvironment());
51+
this.specificationContext.setRegistrar(new SimpleComponentRegistrar(bf));
52+
this.specificationContext.setProblemReporter(new FailFastProblemReporter());
5353
}
5454

5555
@Test
5656
public void validSpec() {
57-
this.executor.execute(new ComponentScanSpec("example.scannable"), this.executorContext);
57+
this.executor.execute(new ComponentScanSpec("example.scannable"), this.specificationContext);
5858
assertThat(bf.containsBean("fooServiceImpl"), is(true));
5959
}
6060

6161
@Test(expected=BeanDefinitionParsingException.class)
6262
public void invalidSpec() {
6363
// ff problem reporter should throw due to no packages specified
64-
this.executor.execute(new ComponentScanSpec(), this.executorContext);
64+
this.executor.execute(new ComponentScanSpec(), this.specificationContext);
6565
}
6666

6767
}

0 commit comments

Comments
 (0)