BATCH-1593: decorate nested bean definitions as well as parsing them
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.springframework.batch.core.listener.AbstractListenerFactoryBean;
|
||||
import org.springframework.batch.core.listener.ListenerMetaData;
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -63,7 +64,11 @@ public abstract class AbstractListenerParser {
|
||||
return new RuntimeBeanReference(listenerRef);
|
||||
}
|
||||
else if (beanElements.size() == 1) {
|
||||
return parserContext.getDelegate().parseBeanDefinitionElement(beanElements.get(0));
|
||||
Element beanElement = beanElements.get(0);
|
||||
BeanDefinitionHolder beanDefinitionHolder = parserContext.getDelegate().parseBeanDefinitionElement(
|
||||
beanElement);
|
||||
parserContext.getDelegate().decorateBeanDefinitionIfRequired(beanElement, beanDefinitionHolder);
|
||||
return beanDefinitionHolder;
|
||||
}
|
||||
else {
|
||||
return (BeanMetadataElement) parserContext.getDelegate().parsePropertySubElement(refElements.get(0), null);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
@@ -104,11 +105,11 @@ public class ChunkElementParser {
|
||||
propertyValues.addPropertyValue("skipLimit", skipLimit);
|
||||
}
|
||||
|
||||
handleItemHandler("skip-policy", "skipPolicy", null, false, element, parserContext,
|
||||
propertyValues, underspecified);
|
||||
handleItemHandler("skip-policy", "skipPolicy", null, false, element, parserContext, propertyValues,
|
||||
underspecified);
|
||||
|
||||
handleItemHandler("retry-policy", "retryPolicy", null, false, element, parserContext,
|
||||
propertyValues, underspecified);
|
||||
handleItemHandler("retry-policy", "retryPolicy", null, false, element, parserContext, propertyValues,
|
||||
underspecified);
|
||||
|
||||
String retryLimit = element.getAttribute("retry-limit");
|
||||
if (StringUtils.hasText(retryLimit)) {
|
||||
@@ -188,8 +189,11 @@ public class ChunkElementParser {
|
||||
+ "/> element or a <" + REF_ELE + "/> element.", element);
|
||||
}
|
||||
else if (beanElements.size() == 1) {
|
||||
propertyValues.addPropertyValue(propertyName, parserContext.getDelegate().parseBeanDefinitionElement(
|
||||
beanElements.get(0)));
|
||||
Element beanElement = beanElements.get(0);
|
||||
BeanDefinitionHolder beanDefinitionHolder = parserContext.getDelegate().parseBeanDefinitionElement(
|
||||
beanElement);
|
||||
parserContext.getDelegate().decorateBeanDefinitionIfRequired(beanElement, beanDefinitionHolder);
|
||||
propertyValues.addPropertyValue(propertyName, beanDefinitionHolder);
|
||||
}
|
||||
else if (refElements.size() == 1) {
|
||||
propertyValues.addPropertyValue(propertyName, parserContext.getDelegate().parsePropertySubElement(
|
||||
@@ -299,7 +303,7 @@ public class ChunkElementParser {
|
||||
ManagedMap map, ParserContext parserContext) {
|
||||
for (Element child : (List<Element>) DomUtils.getChildElementsByTagName(exceptionClassesElement, elementName)) {
|
||||
String className = child.getAttribute("class");
|
||||
map.put(new TypedStringValue(className, Class.class), include);
|
||||
map.put(new TypedStringValue(className, Class.class), include);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -158,7 +159,10 @@ public class JobParser extends AbstractSingleBeanDefinitionParser {
|
||||
return new RuntimeBeanReference(refAttribute);
|
||||
}
|
||||
else if (beanElement != null) {
|
||||
return parserContext.getDelegate().parseBeanDefinitionElement(beanElement);
|
||||
BeanDefinitionHolder beanDefinitionHolder = parserContext.getDelegate().parseBeanDefinitionElement(
|
||||
beanElement);
|
||||
parserContext.getDelegate().decorateBeanDefinitionIfRequired(beanElement, beanDefinitionHolder);
|
||||
return beanDefinitionHolder;
|
||||
}
|
||||
else if (refElement != null) {
|
||||
return (BeanMetadataElement) parserContext.getDelegate().parsePropertySubElement(refElement, null);
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter;
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
@@ -91,7 +92,10 @@ public class TaskletParser {
|
||||
bme = new RuntimeBeanReference(taskletRef);
|
||||
}
|
||||
else if (beanElements.size() == 1) {
|
||||
bme = parserContext.getDelegate().parseBeanDefinitionElement(beanElements.get(0));
|
||||
Element beanElement = beanElements.get(0);
|
||||
BeanDefinitionHolder beanDefinitionHolder = parserContext.getDelegate().parseBeanDefinitionElement(beanElement);
|
||||
parserContext.getDelegate().decorateBeanDefinitionIfRequired(beanElement, beanDefinitionHolder);
|
||||
bme = beanDefinitionHolder;
|
||||
}
|
||||
else if (refElements.size() == 1) {
|
||||
bme = (BeanMetadataElement) parserContext.getDelegate().parsePropertySubElement(refElements.get(0),
|
||||
|
||||
@@ -83,8 +83,7 @@ public class TaskletParserBeanPropertiesTests {
|
||||
job2.execute(jobExecution);
|
||||
Step step = job2.getStep("step2");
|
||||
tasklet = (TestTasklet) ReflectionTestUtils.getField(step, "tasklet");
|
||||
// TODO: BATCH-1593: uncomment this
|
||||
// assertEquals("foo", tasklet.getName());
|
||||
assertEquals("foo", tasklet.getName());
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user