Skip to content

BATCH-1509 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spring-batch-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId><artifactId>h2</artifactId><version>1.2.132</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* Batch domain interface representing the configuration of a step. As with the {@link Job}, a {@link Step} is meant to
* explicitly represent a the configuration of a step by a developer, but also the ability to execute the step.
* explicitly represent the configuration of a step by a developer, but also the ability to execute the step.
*
* @author Dave Syer
*
Expand Down Expand Up @@ -52,4 +52,4 @@ public interface Step {
*/
void execute(StepExecution stepExecution) throws JobInterruptedException;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
* {@link org.springframework.batch.core.Step} and goes on to (optionally) list
* a set of transitions from that step to others with &lt;next on="pattern"
* to="stepName"/&gt;. Used by the {@link JobParser}.
*
* @see JobParser
*
*
* @author Dave Syer
* @author Thomas Risberg
* @author Josh Long
* @see JobParser
* @since 2.0
*/
public abstract class AbstractStepParser {
Expand All @@ -60,6 +60,8 @@ public abstract class AbstractStepParser {

private static final String STEP_ATTR = "step";

private static final String STEP_ELE = STEP_ATTR;

private static final String PARTITIONER_ATTR = "partitioner";

private static final String HANDLER_ATTR = "handler";
Expand All @@ -75,10 +77,10 @@ public abstract class AbstractStepParser {
private static final String JOB_REPO_ATTR = "job-repository";

/**
* @param stepElement The &lt;step/&gt; element
* @param stepElement The &lt;step/&gt; element
* @param parserContext
* @param jobFactoryRef the reference to the {@link JobParserJobFactoryBean}
* from the enclosing tag. Use 'null' if unknown.
* from the enclosing tag. Use 'null' if unknown.
*/
protected AbstractBeanDefinition parseStep(Element stepElement, ParserContext parserContext, String jobFactoryRef) {

Expand All @@ -100,7 +102,7 @@ protected AbstractBeanDefinition parseStep(Element stepElement, ParserContext pa
Element partitionElement = DomUtils.getChildElementByTagName(stepElement, PARTITION_ELE);
if (partitionElement != null) {
boolean stepUnderspecified = CoreNamespaceUtils.isUnderspecified(stepElement);
parsePartition(stepElement, partitionElement, bd, parserContext, stepUnderspecified);
parsePartition(stepElement, partitionElement, bd, parserContext, stepUnderspecified, jobFactoryRef);
}

Element jobElement = DomUtils.getChildElementByTagName(stepElement, JOB_ELE);
Expand Down Expand Up @@ -137,26 +139,35 @@ protected AbstractBeanDefinition parseStep(Element stepElement, ParserContext pa

}

private void parsePartition(Element stepElement, Element partitionElement, AbstractBeanDefinition bd,
ParserContext parserContext, boolean stepUnderspecified) {
private void parsePartition(Element stepElement, Element partitionElement, AbstractBeanDefinition bd, ParserContext parserContext, boolean stepUnderspecified, String jobFactoryRef ) {

bd.setBeanClass(StepParserStepFactoryBean.class);
bd.setAttribute("isNamespaceStep", true);
String stepRef = partitionElement.getAttribute(STEP_ATTR);
String partitionerRef = partitionElement.getAttribute(PARTITIONER_ATTR);
String handlerRef = partitionElement.getAttribute(HANDLER_ATTR);

if (!StringUtils.hasText(stepRef)) {
parserContext.getReaderContext().error("You must specify a step", partitionElement);
return;
}
if (!StringUtils.hasText(partitionerRef)) {
parserContext.getReaderContext().error("You must specify a partitioner", partitionElement);
return;
}

Element inlineStepElement = DomUtils.getChildElementByTagName(partitionElement, STEP_ELE);
if (inlineStepElement == null && !StringUtils.hasText(stepRef)) {
parserContext.getReaderContext().error("You must specify a step", partitionElement);
return;
}


MutablePropertyValues propertyValues = bd.getPropertyValues();
propertyValues.addPropertyValue("step", new RuntimeBeanReference(stepRef));

if (StringUtils.hasText(stepRef)) {
propertyValues.addPropertyValue("step", new RuntimeBeanReference(stepRef));
} else if( inlineStepElement!=null) {
AbstractBeanDefinition stepDefinition = parseStep(inlineStepElement, parserContext, jobFactoryRef);
propertyValues.addPropertyValue("step", stepDefinition );
}

propertyValues.addPropertyValue("partitioner", new RuntimeBeanReference(partitionerRef));

if (!StringUtils.hasText(handlerRef)) {
Expand All @@ -171,15 +182,13 @@ private void parsePartition(Element stepElement, Element partitionElement, Abstr
propertyValues.addPropertyValue("gridSize", new TypedStringValue(gridSize));
}
}
}
else {
} else {
propertyValues.addPropertyValue("partitionHandler", new RuntimeBeanReference(handlerRef));
}

}

private void parseJob(Element stepElement, Element jobElement, AbstractBeanDefinition bd,
ParserContext parserContext, boolean stepUnderspecified) {
private void parseJob(Element stepElement, Element jobElement, AbstractBeanDefinition bd, ParserContext parserContext, boolean stepUnderspecified) {

bd.setBeanClass(StepParserStepFactoryBean.class);
bd.setAttribute("isNamespaceStep", true);
Expand Down Expand Up @@ -207,7 +216,7 @@ private void parseJob(Element stepElement, Element jobElement, AbstractBeanDefin


private void parseFlow(Element stepElement, Element flowElement, AbstractBeanDefinition bd,
ParserContext parserContext, boolean stepUnderspecified) {
ParserContext parserContext, boolean stepUnderspecified) {

bd.setBeanClass(StepParserStepFactoryBean.class);
bd.setAttribute("isNamespaceStep", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public class BeanDefinitionUtils {
* @return The {@link PropertyValue} for the property of the bean. Search
* parent hierarchy if necessary. Return null if none is found.
*/
public static PropertyValue getPropertyValue(String beanName, String propertyName,
ConfigurableListableBeanFactory beanFactory) {
public static PropertyValue getPropertyValue(String beanName, String propertyName, ConfigurableListableBeanFactory beanFactory) {
return beanFactory.getMergedBeanDefinition(beanName).getPropertyValues().getPropertyValue(propertyName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;

/**
*
*
* @author Dave Syer
*
*/
public class CoreNamespaceHandler extends NamespaceHandlerSupport {

/**
*
*
* @see NamespaceHandler#init()
*/
public void init() {
Expand Down
Loading