BATCH-1180: Error occurs if parent= attribute appears on inline <step/> without tasket

This commit is contained in:
dhgarrette
2009-03-25 17:53:55 +00:00
parent e2d5282701
commit d25a779444
9 changed files with 21 additions and 29 deletions

View File

@@ -94,15 +94,18 @@ public abstract class AbstractStepParser {
+ stepElement.getNodeName() + "/>.", stepElement);
}
if (bd != null) {
setUpBeanDefinition(stepElement, bd, parserContext, jobRepositoryRef);
}
else if (!stepUnderspecified) {
parserContext.getReaderContext().error(
"Step [" + stepElement.getAttribute(ID_ATTR) + "] has neither a <" + TASKLET_ELE
+ "/> element nor a '" + TASKLET_ATTR + "' attribute.", stepElement);
if (bd == null) {
if (stepUnderspecified) {
bd = new GenericBeanDefinition();
}
else {
parserContext.getReaderContext().error(
"Step [" + stepElement.getAttribute(ID_ATTR) + "] has neither a <" + TASKLET_ELE
+ "/> element nor a '" + TASKLET_ATTR + "' attribute.", stepElement);
}
}
setUpBeanDefinition(stepElement, bd, parserContext, jobRepositoryRef);
return bd;
}

View File

@@ -85,10 +85,8 @@ public class InlineStepParser extends AbstractStepParser {
}
else {
AbstractBeanDefinition bd = parseTasklet(element, parserContext, jobRepositoryRef);
if (bd != null) {
parserContext.registerBeanComponent(new BeanComponentDefinition(bd, stepId));
stateBuilder.addConstructorArgReference(stepId);
}
parserContext.registerBeanComponent(new BeanComponentDefinition(bd, stepId));
stateBuilder.addConstructorArgReference(stepId);
}
return FlowParser.getNextElements(parserContext, stepId, stateBuilder.getBeanDefinition(), element);

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core.configuration.xml;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
@@ -39,12 +38,6 @@ public class StandaloneStepParser extends AbstractStepParser {
*/
public AbstractBeanDefinition parse(Element element, ParserContext parserContext) {
String jobRepositoryRef = element.getAttribute("job-repository");
AbstractBeanDefinition bd = parseTasklet(element, parserContext, jobRepositoryRef);
if (bd == null) {
bd = new GenericBeanDefinition();
setUpBeanDefinition(element, bd, parserContext, element.getAttribute("job-repository"));
}
return bd;
return parseTasklet(element, parserContext, jobRepositoryRef);
}
}

View File

@@ -14,7 +14,7 @@ import org.w3c.dom.Element;
*/
public class TopLevelJobListenerParser extends AbstractSingleBeanDefinitionParser {
private JobExecutionListenerParser jobListenerParser = new JobExecutionListenerParser();
private static final JobExecutionListenerParser jobListenerParser = new JobExecutionListenerParser();
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

View File

@@ -14,7 +14,7 @@ import org.w3c.dom.Element;
*/
public class TopLevelStepListenerParser extends AbstractSingleBeanDefinitionParser {
private StepListenerParser stepListenerParser = new StepListenerParser();
private static final StepListenerParser stepListenerParser = new StepListenerParser();
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

View File

@@ -29,11 +29,12 @@ import org.w3c.dom.Element;
*/
public class TopLevelStepParser extends AbstractBeanDefinitionParser {
private static final StandaloneStepParser stepParser = new StandaloneStepParser();
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
CoreNamespaceUtils.checkForStepScope(parserContext, parserContext.extractSource(element));
StandaloneStepParser stepParser = new StandaloneStepParser();
return stepParser.parse(element, parserContext);
}

View File

@@ -43,7 +43,7 @@ public class StopRestartOnCompletedStepJobParserTests extends AbstractJobParserT
//
// First Launch
//
launchAndAssert("[s0, s1]");
launchAndAssert("[s1]");
//
// Second Launch

View File

@@ -7,7 +7,6 @@
<beans:import resource="common-context.xml" />
<job id="job">
<step id="s0" ref="step2" next="s1"/>
<step id="s1" ref="taskletStep">
<!-- On normal step status: stop the job, but restart with the same step. -->
<stop on="COMPLETED" restart="s1"/>
@@ -17,6 +16,5 @@
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<step id="taskletStep" parent="step1" allow-start-if-complete="true"/>
</beans:beans>

View File

@@ -8,14 +8,13 @@
<job id="job">
<step id="s0" ref="step2" next="fail"/>
<step id="fail" ref="taskletStep">
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<step id="fail" parent="failingStep" allow-start-if-complete="true">
<!-- On failure: stop the job, but restart with the same step. -->
<stop on="FAILED" restart="fail"/>
<end on="*"/>
</step>
</job>
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<step id="taskletStep" parent="failingStep" allow-start-if-complete="true"/>
</beans:beans>