[BATCH-63] Refactoring to accomodate the new <config/> element

This commit is contained in:
nebhale
2008-02-27 15:43:24 +00:00
parent aa76ec4e26
commit dc656d248d
43 changed files with 772 additions and 874 deletions

View File

@@ -1,45 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.beans.factory.parsing.ParseState;
/**
* {@link ParseState} entry representing a step. This is an abstract class intended to be overriden with given step
* types.
*
* @author Ben Hale
*/
abstract class AbstractStepEntry implements ParseState.Entry {
private final String name;
/**
* Creates a new instance of the {@link AbstractStepEntry} class.
*
* @param name the bean name of the job
*/
AbstractStepEntry(String name) {
this.name = name;
}
abstract String getType();
public String toString() {
return "Step '" + name + "', Type'" + getType() + "'";
}
}

View File

@@ -20,25 +20,18 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
* <code>NamespaceHandler</code> for the <code>batch-execution</code> namespace.
* <code>NamespaceHandler</code> for the <code>batch</code> namespace.
*
* <p>
* Provides a {@link BeanDefinitionParser} for the <code>&lt;batch:job&gt;</code> tag. A <code>job</code> tag can
* include nested <code>chunked-step</code> and <code>tasklet-step</code> tags.
*
* <p>
* Provides a {@link BeanDefinitionParser} for the <code>&lt;batch:job-repository&gt;</code> tag.
* Provides a {@link BeanDefinitionParser} for the <code>&lt;batch:config&gt;</code> tag. A <code>config</code> tag
* must include nested <code>job-repository</code> and <code>job</code> tags.
*
* @author Ben Hale
*/
public class BatchNamespaceHandler extends NamespaceHandlerSupport {
/**
* Register the {@link BeanDefinitionParser BeanDefinitionParser} for the '<code>job</code>', tag.
*/
public void init() {
registerBeanDefinitionParser("job", new JobBeanDefinitionParser());
registerBeanDefinitionParser("job-repository", new JobRepositoryBeanDefinitionParser());
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
}
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.beans.factory.parsing.ParseState;
/**
* {@link ParseState} entry representing a {@link ChunkStep}.
*
* @author Ben Hale
*/
public class ChunkStepEntry extends AbstractStepEntry {
/**
* Creates a new instance of the {@link ChunkStepEntry} class.
*
* @param name the bean name of the job
*/
ChunkStepEntry(String name) {
super(name);
}
String getType() {
return "chunk";
}
}

View File

@@ -0,0 +1,333 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.JdbcJobExecutionDao;
import org.springframework.batch.execution.repository.dao.JdbcJobInstanceDao;
import org.springframework.batch.execution.repository.dao.JdbcStepExecutionDao;
import org.springframework.batch.execution.step.ItemOrientedStep;
import org.springframework.batch.execution.step.TaskletStep;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @author Ben Hale
*/
public class ConfigBeanDefinitionParser implements BeanDefinitionParser {
private static final String JOB_REPOSITORY_ELEMENT = "job-repository";
private static final String JOB_REPOSITORY_BEAN_NAME = "_jobRepository";
private static final String DATA_SOURCE_ATT = "data-source";
private static final String DB_TYPE_ATT = "db-type";
private static final String DB_TYPE_DB2 = "db2";
private static final String DB_TYPE_DERBY = "derby";
private static final String DB_TYPE_HSQL = "hsql";
private static final String DB_TYPE_MYSQL = "mysql";
private static final String DB_TYPE_ORACLE = "oracle";
private static final String DB_TYPE_POSTGRES = "postgres";
private static final String JOB_ELEMENT = "job";
private static final String ID_ATT = "id";
private static final String RERUN_ATT = "rerun";
private static final String RERUN_ALWAYS = "always";
private static final String RERUN_NEVER = "never";
private static final String RERUN_INCOMPLETE = "incomplete";
private static final String STEP_ELEMENT = "step";
private static final String SIZE_ATT = "size";
private static final String TRANSACTION_MANAGER_ATT = "transaction-manager";
private static final String ITEM_READER_ATT = "item-reader";
private static final String ITEM_WRITER_ATT = "item-writer";
private static final String INPUT_SKIP_LIMIT_ATT = "input-skip-limit";
private static final String OUTPUT_SKIP_LIMIT_ATT = "output-skip-limit";
private static final String TASKLET_STEP_ELEMENT = "tasklet-step";
private static final String TASKLET_ATT = "tasklet";
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
String localName = child.getLocalName();
if (JOB_REPOSITORY_ELEMENT.equals(localName)) {
parseJobRepository((Element) child, parserContext);
} else if (JOB_ELEMENT.equals(localName)) {
parseJob((Element) child, parserContext);
}
}
}
parserContext.popAndRegisterContainingComponent();
return null;
}
private void parseJobRepository(Element jobRepoEle, ParserContext parserContext) {
RootBeanDefinition jobRepoDef = new RootBeanDefinition(SimpleJobRepository.class);
jobRepoDef.setSource(parserContext.extractSource(jobRepoEle));
String dataSourceId = jobRepoEle.getAttribute(DATA_SOURCE_ATT);
if (!StringUtils.hasText(dataSourceId)) {
parserContext.getReaderContext().error("'data-source' attribute contains empty value", jobRepoEle);
} else {
String dbType = jobRepoEle.getAttribute(DB_TYPE_ATT);
ConstructorArgumentValues constructorArgumentValues = jobRepoDef.getConstructorArgumentValues();
String templateId = createJdbcTemplateDefinition(dataSourceId, parserContext);
constructorArgumentValues.addGenericArgumentValue(createJobInstanceDao(templateId, dataSourceId, dbType,
parserContext));
constructorArgumentValues.addGenericArgumentValue(createJobExecutionDao(templateId, dataSourceId, dbType,
parserContext));
constructorArgumentValues.addGenericArgumentValue(createStepExecutionDao(templateId, dataSourceId, dbType,
parserContext));
}
parserContext.registerBeanComponent(new BeanComponentDefinition(jobRepoDef, JOB_REPOSITORY_BEAN_NAME));
}
private String createJdbcTemplateDefinition(String dataSourceId, ParserContext parserContext) {
RootBeanDefinition templateDef = new RootBeanDefinition(JdbcTemplate.class);
templateDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
return parserContext.getReaderContext().registerWithGeneratedName(templateDef);
}
private BeanDefinition createJobInstanceDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcJobInstanceDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue("jdbcTemplate", new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue("jobIncrementer", getIncrementer(dbType, dataSourceId, "BATCH_JOB_SEQ"));
return daoDef;
}
private BeanDefinition createJobExecutionDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcJobExecutionDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue("jdbcTemplate", new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue("jobExecutionIncrementer", getIncrementer(dbType, dataSourceId,
"BATCH_JOB_EXECUTION_SEQ"));
return daoDef;
}
private BeanDefinition createStepExecutionDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcStepExecutionDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue("jdbcTemplate", new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue("stepExecutionIncrementer", getIncrementer(dbType, dataSourceId,
"BATCH_STEP_EXECUTION_SEQ"));
return daoDef;
}
private BeanDefinition getIncrementer(String dbType, String dataSourceId, String incrementerName) {
RootBeanDefinition incrementerDef = new RootBeanDefinition();
if (DB_TYPE_DB2.equals(dbType)) {
incrementerDef.setBeanClass(DB2SequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (DB_TYPE_DERBY.equals(dbType)) {
incrementerDef.setBeanClass(DerbyMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (DB_TYPE_HSQL.equals(dbType)) {
incrementerDef.setBeanClass(HsqlMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (DB_TYPE_MYSQL.equals(dbType)) {
incrementerDef.setBeanClass(MySQLMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (DB_TYPE_ORACLE.equals(dbType)) {
incrementerDef.setBeanClass(OracleSequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (DB_TYPE_POSTGRES.equals(dbType)) {
incrementerDef.setBeanClass(PostgreSQLSequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
}
return incrementerDef;
}
private void addSequenceIncrementer(String dataSourceId, String incrementerName,
ConstructorArgumentValues constructorArgumentValues) {
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
constructorArgumentValues.addGenericArgumentValue(incrementerName);
}
private void addTableIncrementer(String dataSourceId, String incrementerName,
ConstructorArgumentValues constructorArgumentValues) {
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
constructorArgumentValues.addGenericArgumentValue(incrementerName);
constructorArgumentValues.addGenericArgumentValue("id");
}
private void parseJob(Element jobEle, ParserContext parserContext) {
NodeList childNodes = jobEle.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
String localName = child.getLocalName();
if (STEP_ELEMENT.equals(localName)) {
parseStep((Element) child, parserContext);
} else if (TASKLET_STEP_ELEMENT.equals(localName)) {
parseTaskletStep((Element) child, parserContext);
}
}
}
}
private void parseStep(Element stepEle, ParserContext parserContext) {
AbstractBeanDefinition stepDef = createStepBeanDefinition(stepEle, parserContext);
String id = stepEle.getAttribute(ID_ATT);
if (StringUtils.hasText(id)) {
parserContext.getRegistry().registerBeanDefinition(id, stepDef);
} else {
parserContext.getReaderContext().registerWithGeneratedName(stepDef);
}
}
private AbstractBeanDefinition createStepBeanDefinition(Element stepElement, ParserContext parserContext) {
RootBeanDefinition stepDef = new RootBeanDefinition(ItemOrientedStep.class);
stepDef.setSource(parserContext.extractSource(stepElement));
MutablePropertyValues propertyValues = stepDef.getPropertyValues();
String size = stepElement.getAttribute(SIZE_ATT);
propertyValues.addPropertyValue("commitInterval", Integer.valueOf(size));
String transactionManager = stepElement.getAttribute(TRANSACTION_MANAGER_ATT);
if (!StringUtils.hasText(transactionManager)) {
parserContext.getReaderContext().error("'transaction-manager' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue("transactionManager", new RuntimeBeanReference(transactionManager));
}
String itemReader = stepElement.getAttribute(ITEM_READER_ATT);
if (!StringUtils.hasText(itemReader)) {
parserContext.getReaderContext().error("'item-reader' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue("itemReader", new RuntimeBeanReference(itemReader));
}
String itemWriter = stepElement.getAttribute(ITEM_WRITER_ATT);
if (!StringUtils.hasText(itemWriter)) {
parserContext.getReaderContext().error("'item-writer' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue("itemWriter", new RuntimeBeanReference(itemWriter));
}
if (stepElement.hasAttribute(INPUT_SKIP_LIMIT_ATT)) {
String inputSkipLimit = stepElement.getAttribute(INPUT_SKIP_LIMIT_ATT);
propertyValues.addPropertyValue("skipLimit", Integer.valueOf(inputSkipLimit));
}
// TODO: Create difference between input skip limit and output skip limit
// if (stepElement.hasAttribute(ATT_OUTPUT_SKIP_LIMIT)) {
// String outputSkipLimit = stepElement.getAttribute(ATT_OUTPUT_SKIP_LIMIT);
// propertyValues.addPropertyValue(PROP_OUTPUT_SKIP_LIMIT, Integer.valueOf(outputSkipLimit));
// }
String rerun = stepElement.getAttribute(RERUN_ATT);
setPropertiesForRerun(rerun, propertyValues);
propertyValues.addPropertyValue("jobRepository", new RuntimeBeanReference(JOB_REPOSITORY_BEAN_NAME));
return stepDef;
}
private void parseTaskletStep(Element taskletStepEle, ParserContext parserContext) {
AbstractBeanDefinition stepDef = createTaskletStepBeanDefinition(taskletStepEle, parserContext);
String id = taskletStepEle.getAttribute(ID_ATT);
if (StringUtils.hasText(id)) {
parserContext.getRegistry().registerBeanDefinition(id, stepDef);
} else {
parserContext.getReaderContext().registerWithGeneratedName(stepDef);
}
}
private AbstractBeanDefinition createTaskletStepBeanDefinition(Element taskletElement, ParserContext parserContext) {
RootBeanDefinition stepDef = new RootBeanDefinition(TaskletStep.class);
stepDef.setSource(parserContext.extractSource(taskletElement));
MutablePropertyValues propertyValues = stepDef.getPropertyValues();
String tasklet = taskletElement.getAttribute(TASKLET_ATT);
if (!StringUtils.hasText(tasklet)) {
parserContext.getReaderContext().error("'tasklet' attribute contains empty value", taskletElement);
} else {
propertyValues.addPropertyValue("tasklet", new RuntimeBeanReference(tasklet));
}
String rerun = taskletElement.getAttribute(RERUN_ATT);
setPropertiesForRerun(rerun, propertyValues);
propertyValues.addPropertyValue("jobRepository", new RuntimeBeanReference(JOB_REPOSITORY_BEAN_NAME));
return stepDef;
}
private void setPropertiesForRerun(String rerun, MutablePropertyValues propertyValues) {
if (RERUN_ALWAYS.equals(rerun)) {
propertyValues.addPropertyValue("allowStartIfComplete", Boolean.TRUE);
propertyValues.addPropertyValue("startLimit", new Integer(Integer.MAX_VALUE));
} else if (RERUN_NEVER.equals(rerun)) {
propertyValues.addPropertyValue("allowStartIfComplete", Boolean.FALSE);
propertyValues.addPropertyValue("startLimit", Integer.valueOf(1));
} else if (RERUN_INCOMPLETE.equals(rerun)) {
propertyValues.addPropertyValue("allowStartIfComplete", Boolean.FALSE);
propertyValues.addPropertyValue("startLimit", new Integer(Integer.MAX_VALUE));
}
}
}

View File

@@ -1,205 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.batch.execution.step.ItemOrientedStep;
import org.springframework.batch.execution.step.TaskletStep;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
*
* @author Ben Hale
*/
class JobBeanDefinitionParser implements BeanDefinitionParser {
private static final String TAG_JOB = "job";
private static final String TAG_STEP = "step";
private static final String TAG_TASKLET_STEP = "tasklet-step";
private static final String ATT_ID = "id";
private static final String ATT_TASKLET = "tasklet";
private static final String ATT_RERUN = "rerun";
private static final String PROP_TASKLET = "tasklet";
private static final String ENUM_ALWAYS = "always";
private static final String ENUM_NEVER = "never";
private static final String ENUM_INCOMPLETE = "incomplete";
private static final String PROP_ALLOW_START_IF_COMPLETE = "allowStartIfComplete";
private static final String PROP_JOB_REPOSITORY = "jobRepository";
private static final String PROP_START_LIMIT = "startLimit";
private static final String REPOSITORY_BEAN_NAME = "_jobRepository";
private static final String ATT_SIZE = "size";
private static final String PROP_COMMIT_INTERVAL = "commitInterval";
private static final String ATT_TRANSACTION_MANAGER = "transaction-manager";
private static final String PROP_TRANSACTION_MANAGER = "transactionManager";
private static final String ATT_ITEM_READER = "item-reader";
private static final String PROP_ITEM_READER = "itemReader";
private static final String ATT_ITEM_WRITER = "item-writer";
private static final String PROP_ITEM_WRITER = "itemWriter";
private static final String ATT_INPUT_SKIP_LIMIT = "input-skip-limit";
// TODO: Create difference between input skip limit and output skip limit
private static final String PROP_INPUT_SKIP_LIMIT = "skipLimit";
private static final String ATT_OUTPUT_SKIP_LIMIT = "output-skip-limit";
private static final String PROP_OUTPUT_SKIP_LIMIT = "outputSkipLimit";
public BeanDefinition parse(Element element, ParserContext parserContext) {
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
String localName = node.getLocalName();
if (TAG_STEP.equals(localName)) {
parseStep((Element) node, parserContext);
} else if (TAG_TASKLET_STEP.equals(localName)) {
parseTaskletStep((Element) node, parserContext);
}
}
}
return null;
}
private void parseStep(Element stepElement, ParserContext parserContext) {
AbstractBeanDefinition stepDef = createStepBeanDefinition(stepElement, parserContext);
String id = stepElement.getAttribute(ATT_ID);
if (StringUtils.hasText(id)) {
parserContext.getRegistry().registerBeanDefinition(id, stepDef);
} else {
parserContext.getReaderContext().registerWithGeneratedName(stepDef);
}
}
private AbstractBeanDefinition createStepBeanDefinition(Element stepElement, ParserContext parserContext) {
RootBeanDefinition stepDef = new RootBeanDefinition(ItemOrientedStep.class);
stepDef.setSource(parserContext.extractSource(stepElement));
MutablePropertyValues propertyValues = stepDef.getPropertyValues();
String size = stepElement.getAttribute(ATT_SIZE);
propertyValues.addPropertyValue(PROP_COMMIT_INTERVAL, Integer.valueOf(size));
String transactionManager = stepElement.getAttribute(ATT_TRANSACTION_MANAGER);
if (!StringUtils.hasText(transactionManager)) {
parserContext.getReaderContext().error("'transaction-manager' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue(PROP_TRANSACTION_MANAGER, new RuntimeBeanReference(transactionManager));
}
String itemReader = stepElement.getAttribute(ATT_ITEM_READER);
if (!StringUtils.hasText(itemReader)) {
parserContext.getReaderContext().error("'item-reader' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue(PROP_ITEM_READER, new RuntimeBeanReference(itemReader));
}
String itemWriter = stepElement.getAttribute(ATT_ITEM_WRITER);
if (!StringUtils.hasText(itemWriter)) {
parserContext.getReaderContext().error("'item-writer' attribute contains empty value", stepElement);
} else {
propertyValues.addPropertyValue(PROP_ITEM_WRITER, new RuntimeBeanReference(itemWriter));
}
if (stepElement.hasAttribute(ATT_INPUT_SKIP_LIMIT)) {
String inputSkipLimit = stepElement.getAttribute(ATT_INPUT_SKIP_LIMIT);
propertyValues.addPropertyValue(PROP_INPUT_SKIP_LIMIT, Integer.valueOf(inputSkipLimit));
}
// TODO: Create difference between input skip limit and output skip limit
// if (stepElement.hasAttribute(ATT_OUTPUT_SKIP_LIMIT)) {
// String outputSkipLimit = stepElement.getAttribute(ATT_OUTPUT_SKIP_LIMIT);
// propertyValues.addPropertyValue(PROP_OUTPUT_SKIP_LIMIT, Integer.valueOf(outputSkipLimit));
// }
String rerun = stepElement.getAttribute(ATT_RERUN);
setPropertiesForRerun(rerun, propertyValues);
propertyValues.addPropertyValue(PROP_JOB_REPOSITORY, new RuntimeBeanReference(REPOSITORY_BEAN_NAME));
return stepDef;
}
private void parseTaskletStep(Element taskletElement, ParserContext parserContext) {
AbstractBeanDefinition stepDef = createTaskletStepBeanDefinition(taskletElement, parserContext);
String id = taskletElement.getAttribute(ATT_ID);
if (StringUtils.hasText(id)) {
parserContext.getRegistry().registerBeanDefinition(id, stepDef);
} else {
parserContext.getReaderContext().registerWithGeneratedName(stepDef);
}
}
private AbstractBeanDefinition createTaskletStepBeanDefinition(Element taskletElement, ParserContext parserContext) {
RootBeanDefinition stepDef = new RootBeanDefinition(TaskletStep.class);
stepDef.setSource(parserContext.extractSource(taskletElement));
MutablePropertyValues propertyValues = stepDef.getPropertyValues();
String tasklet = taskletElement.getAttribute(ATT_TASKLET);
if (!StringUtils.hasText(tasklet)) {
parserContext.getReaderContext().error("'tasklet' attribute contains empty value", taskletElement);
} else {
propertyValues.addPropertyValue(PROP_TASKLET, new RuntimeBeanReference(tasklet));
}
String rerun = taskletElement.getAttribute(ATT_RERUN);
setPropertiesForRerun(rerun, propertyValues);
propertyValues.addPropertyValue(PROP_JOB_REPOSITORY, new RuntimeBeanReference(REPOSITORY_BEAN_NAME));
return stepDef;
}
private void setPropertiesForRerun(String rerun, MutablePropertyValues propertyValues) {
if (ENUM_ALWAYS.equals(rerun)) {
propertyValues.addPropertyValue(PROP_ALLOW_START_IF_COMPLETE, Boolean.TRUE);
propertyValues.addPropertyValue(PROP_START_LIMIT, new Integer(Integer.MAX_VALUE));
} else if (ENUM_NEVER.equals(rerun)) {
propertyValues.addPropertyValue(PROP_ALLOW_START_IF_COMPLETE, Boolean.FALSE);
propertyValues.addPropertyValue(PROP_START_LIMIT, Integer.valueOf(1));
} else if (ENUM_INCOMPLETE.equals(rerun)) {
propertyValues.addPropertyValue(PROP_ALLOW_START_IF_COMPLETE, Boolean.FALSE);
propertyValues.addPropertyValue(PROP_START_LIMIT, new Integer(Integer.MAX_VALUE));
}
}
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.beans.factory.parsing.ParseState;
/**
* {@link ParseState} entry representing a job.
*
* @author Ben Hale
*/
class JobEntry implements ParseState.Entry {
private final String name;
/**
* Creates a new instance of the {@link JobEntry} class.
*
* @param name the bean name of the job
*/
JobEntry(String name) {
this.name = name;
}
public String toString() {
return "Job '" + name + "'";
}
}

View File

@@ -1,169 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.batch.execution.repository.SimpleJobRepository;
import org.springframework.batch.execution.repository.dao.JdbcJobExecutionDao;
import org.springframework.batch.execution.repository.dao.JdbcJobInstanceDao;
import org.springframework.batch.execution.repository.dao.JdbcStepExecutionDao;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
/**
* Creates a {@link BeanDefinitionParser} for the <code>&lt;job-repository&gt;</code> tag.
*
* @author Ben Hale
*/
class JobRepositoryBeanDefinitionParser implements BeanDefinitionParser {
private static final String ATT_DATA_SOURCE = "data-source";
private static final String ATT_DB_TYPE = "db-type";
private static final String ENUM_DB2 = "db2";
private static final String ENUM_DERBY = "derby";
private static final String ENUM_HSQL = "hsql";
private static final String ENUM_MYSQL = "mysql";
private static final String ENUM_ORACLE = "oracle";
private static final String ENUM_POSTGRES = "postgres";
private static final String PROP_JDBC_TEMPLATE = "jdbcTemplate";
private static final String PROP_JOB_INCREMENTER = "jobIncrementer";
private static final String PROP_JOB_EXECUTION_INCREMENTER = "jobExecutionIncrementer";
private static final String PROP_STEP_EXECUTION_INCREMENTER = "stepExecutionIncrementer";
private static final String REPOSITORY_BEAN_NAME = "_jobRepository";
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition repositoryDef = new RootBeanDefinition(SimpleJobRepository.class);
String dbType = element.getAttribute(ATT_DB_TYPE);
String dataSourceId = element.getAttribute(ATT_DATA_SOURCE);
if (!StringUtils.hasText(dataSourceId)) {
parserContext.getReaderContext().error("'data-source' attribute contains empty value", element);
} else {
ConstructorArgumentValues constructorArgumentValues = repositoryDef.getConstructorArgumentValues();
String templateId = createJdbcTemplateDefinition(dataSourceId, parserContext);
constructorArgumentValues.addGenericArgumentValue(createJobInstanceDao(templateId, dataSourceId, dbType,
parserContext));
constructorArgumentValues.addGenericArgumentValue(createJobExecutionDao(templateId, dataSourceId, dbType,
parserContext));
constructorArgumentValues.addGenericArgumentValue(createStepExecutionDao(templateId, dataSourceId, dbType,
parserContext));
}
parserContext.getRegistry().registerBeanDefinition(REPOSITORY_BEAN_NAME, repositoryDef);
return null;
}
private String createJdbcTemplateDefinition(String dataSourceId, ParserContext parserContext) {
RootBeanDefinition templateDef = new RootBeanDefinition(JdbcTemplate.class);
templateDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
return parserContext.getReaderContext().registerWithGeneratedName(templateDef);
}
private BeanDefinition createJobInstanceDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcJobInstanceDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue(PROP_JDBC_TEMPLATE, new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue(PROP_JOB_INCREMENTER, getIncrementer(dbType, dataSourceId, "BATCH_JOB_SEQ"));
return daoDef;
}
private BeanDefinition createJobExecutionDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcJobExecutionDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue(PROP_JDBC_TEMPLATE, new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue(PROP_JOB_EXECUTION_INCREMENTER, getIncrementer(dbType, dataSourceId,
"BATCH_JOB_EXECUTION_SEQ"));
return daoDef;
}
private BeanDefinition createStepExecutionDao(String templateId, String dataSourceId, String dbType,
ParserContext parserContext) {
RootBeanDefinition daoDef = new RootBeanDefinition(JdbcStepExecutionDao.class);
MutablePropertyValues propertyValues = daoDef.getPropertyValues();
propertyValues.addPropertyValue(PROP_JDBC_TEMPLATE, new RuntimeBeanReference(templateId));
propertyValues.addPropertyValue(PROP_STEP_EXECUTION_INCREMENTER, getIncrementer(dbType, dataSourceId,
"BATCH_STEP_EXECUTION_SEQ"));
return daoDef;
}
private BeanDefinition getIncrementer(String dbType, String dataSourceId, String incrementerName) {
RootBeanDefinition incrementerDef = new RootBeanDefinition();
if (ENUM_DB2.equals(dbType)) {
incrementerDef.setBeanClass(DB2SequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (ENUM_DERBY.equals(dbType)) {
incrementerDef.setBeanClass(DerbyMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (ENUM_HSQL.equals(dbType)) {
incrementerDef.setBeanClass(HsqlMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (ENUM_MYSQL.equals(dbType)) {
incrementerDef.setBeanClass(MySQLMaxValueIncrementer.class);
addTableIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (ENUM_ORACLE.equals(dbType)) {
incrementerDef.setBeanClass(OracleSequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
} else if (ENUM_POSTGRES.equals(dbType)) {
incrementerDef.setBeanClass(PostgreSQLSequenceMaxValueIncrementer.class);
addSequenceIncrementer(dataSourceId, incrementerName, incrementerDef.getConstructorArgumentValues());
}
return incrementerDef;
}
private void addSequenceIncrementer(String dataSourceId, String incrementerName,
ConstructorArgumentValues constructorArgumentValues) {
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
constructorArgumentValues.addGenericArgumentValue(incrementerName);
}
private void addTableIncrementer(String dataSourceId, String incrementerName,
ConstructorArgumentValues constructorArgumentValues) {
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(dataSourceId));
constructorArgumentValues.addGenericArgumentValue(incrementerName);
constructorArgumentValues.addGenericArgumentValue("id");
}
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import org.springframework.beans.factory.parsing.ParseState;
/**
* {@link ParseState} entry representing a {@link TaskletStep}.
*
* @author Ben Hale
*/
public class TaskletStepEntry extends AbstractStepEntry {
/**
* Creates a new instance of the {@link TaskletStepEntry} class.
*
* @param name the bean name of the job
*/
TaskletStepEntry(String name) {
super(name);
}
String getType() {
return "tasklet";
}
}

View File

@@ -4,60 +4,70 @@
targetNamespace="http://www.springframework.org/schema/batch"
elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
<xs:element name="job-repository">
<xs:element name="config">
<xs:annotation>
<xs:documentation><![CDATA[Defines a repository for storing and retrieving metadata for jobs and steps.]]></xs:documentation>
<xs:documentation><![CDATA[Defines a configuration for a batch job or a group of batch jobs. This encapsulating element sets the default configuration for all jobs and steps defined inside.]]></xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="data-source" type="xs:token" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The datasource to use to back this repository.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="db-type" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The type of database this job repository will be communicating with.]]></xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="db2"/>
<xs:enumeration value="derby"/>
<xs:enumeration value="hsql"/>
<xs:enumeration value="mysql"/>
<xs:enumeration value="oracle"/>
<xs:enumeration value="postgres"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="job">
<xs:annotation>
<xs:documentation><![CDATA[Defines a uniquely identified job that is referenced at runtime.]]></xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="step" type="stepType">
<xs:sequence>
<xs:element name="job-repository" type="jobRepositoryType" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation><![CDATA[Defines a step that supports chunking]]></xs:documentation>
<xs:documentation><![CDATA[Defines a repository for storing and retrieving metadata for jobs and steps.]]></xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tasklet-step" type="taskletStepType">
<xs:element name="job" type="jobType" minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation><![CDATA[Defines a step that executes a tasklet]]></xs:documentation>
<xs:documentation><![CDATA[Defines a uniquely identified job that is referenced at runtime.]]></xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:attribute name="id" type="xs:token" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The unique identifier to use in this step. The id must be unique within the context of this job.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Types -->
<xs:complexType name="jobRepositoryType">
<xs:attribute name="data-source" type="xs:token" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The datasource to use to back this repository.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="db-type" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The type of database this job repository will be communicating with.]]></xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="db2"/>
<xs:enumeration value="derby"/>
<xs:enumeration value="hsql"/>
<xs:enumeration value="mysql"/>
<xs:enumeration value="oracle"/>
<xs:enumeration value="postgres"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="jobType">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="step" type="stepType">
<xs:annotation>
<xs:documentation><![CDATA[Defines a step that supports chunking]]></xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tasklet-step" type="taskletStepType">
<xs:annotation>
<xs:documentation><![CDATA[Defines a step that executes a tasklet]]></xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:attribute name="id" type="xs:token" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The unique identifier to use in this step. The id must be unique within the context of this job.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="stepType">
<xs:attribute name="id" type="xs:token" use="required">
<xs:annotation>

View File

@@ -1,62 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import junit.framework.TestCase;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BatchNamespaceHandlerJobRepositoryTests extends TestCase {
private static final String PACKAGE = "org/springframework/batch/execution/configuration/";
public void testRepositoryOk() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryOk.xml");
}
public void testRepositoryMissingDataSource() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryMissingDataSource.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) { }
}
public void testRepositoryDb2() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryDb2.xml");
}
public void testRepositoryDerby() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryDerby.xml");
}
public void testRepositoryHsql() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryHsql.xml");
}
public void testRepositoryMySql() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryMySql.xml");
}
public void testRepositoryOracle() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryOracle.xml");
}
public void testRepositoryPostgres() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryPostgres.xml");
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.configuration;
import junit.framework.TestCase;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class JobRepositoryBeanDefinitionParserTests extends TestCase {
private static final String PACKAGE = "org/springframework/batch/execution/configuration/";
public void testJobRepoOk() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoOk.xml");
}
public void testJobRepoMissingDataSource() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoMissingDataSource.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) {
}
}
public void testJobRepoDb2() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoDb2.xml");
}
public void testJobRepoDerby() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoDerby.xml");
}
public void testJobRepoHsql() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoHsql.xml");
}
public void testJobRepoMySql() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoMySql.xml");
}
public void testJobRepoOracle() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoOracle.xml");
}
public void testJobRepoPostgres() {
new ClassPathXmlApplicationContext(PACKAGE + "JobRepoPostgres.xml");
}
}

View File

@@ -23,55 +23,60 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BatchNamespaceHandlerStepTests extends TestCase {
public class StepBeanDefinitionParserTests extends TestCase {
private static final String PACKAGE = "org/springframework/batch/execution/configuration/";
public void testStepOk() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepOk.xml");
new ClassPathXmlApplicationContext(PACKAGE + "StepOk.xml");
}
public void testStepMissingIteamReader() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepMissingItemReader.xml");
new ClassPathXmlApplicationContext(PACKAGE + "StepMissingItemReader.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) { }
} catch (BeanDefinitionParsingException e) {
}
}
public void testStepMissingItemWriter() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepMissingItemWriter.xml");
new ClassPathXmlApplicationContext(PACKAGE + "StepMissingItemWriter.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) { }
} catch (BeanDefinitionParsingException e) {
}
}
public void testStepMissingTransactionManager() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepMissingTransactionManager.xml");
new ClassPathXmlApplicationContext(PACKAGE + "StepMissingTransactionManager.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) { }
} catch (BeanDefinitionParsingException e) {
}
}
public void testStepSpecificTransactionManager() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepSpecificTransactionManager.xml");
new ClassPathXmlApplicationContext(PACKAGE + "StepSpecificTransactionManager.xml");
}
public void testStepRerunAlways() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepRerunAlways.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE
+ "StepRerunAlways.xml");
ItemOrientedStep step = (ItemOrientedStep) ctx.getBean("process");
assertEquals(Integer.MAX_VALUE, step.getStartLimit());
assertTrue(step.isAllowStartIfComplete());
}
public void testStepRerunNever() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepRerunNever.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "StepRerunNever.xml");
ItemOrientedStep step = (ItemOrientedStep) ctx.getBean("process");
assertEquals(1, step.getStartLimit());
assertFalse(step.isAllowStartIfComplete());
}
public void testStepRerunIncomplete() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerStepRerunIncomplete.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE
+ "StepRerunIncomplete.xml");
ItemOrientedStep step = (ItemOrientedStep) ctx.getBean("process");
assertEquals(Integer.MAX_VALUE, step.getStartLimit());
assertFalse(step.isAllowStartIfComplete());

View File

@@ -23,37 +23,37 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BatchNamespaceHandlerTaskletStepTests extends TestCase {
public class TaskletStepBeanDefinitionParserTests extends TestCase {
private static final String PACKAGE = "org/springframework/batch/execution/configuration/";
public void testTaskletStepOk() {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepOk.xml");
new ClassPathXmlApplicationContext(PACKAGE + "TaskletStepOk.xml");
}
public void testTaskletStepMissingTasklet() {
try {
new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepMissingTasklet.xml");
new ClassPathXmlApplicationContext(PACKAGE + "TaskletStepMissingTasklet.xml");
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException e) { }
}
public void testTaskletStepRerunAlways() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunAlways.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "TaskletStepRerunAlways.xml");
TaskletStep step = (TaskletStep) ctx.getBean("process");
assertEquals(Integer.MAX_VALUE, step.getStartLimit());
assertTrue(step.isAllowStartIfComplete());
}
public void testTaskletStepRerunNever() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunNever.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "TaskletStepRerunNever.xml");
TaskletStep step = (TaskletStep) ctx.getBean("process");
assertEquals(1, step.getStartLimit());
assertFalse(step.isAllowStartIfComplete());
}
public void testTaskletStepRerunIncomplete() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunIncomplete.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "TaskletStepRerunIncomplete.xml");
TaskletStep step = (TaskletStep) ctx.getBean("process");
assertEquals(Integer.MAX_VALUE, step.getStartLimit());
assertFalse(step.isAllowStartIfComplete());

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="hsql" />
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource" />
</beans:beans>

View File

@@ -1,10 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="" db-type="db2" />
</beans:beans>

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="mysql"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="oracle"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -1,13 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="postgres"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -1,26 +0,0 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter"/>
</job>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>
<beans:bean id="itemWriter"
class="org.springframework.batch.execution.configuration.StubItemWriter"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="transactionManager"
class="org.springframework.batch.execution.configuration.StubTransactionManager"/>
</beans:beans>

View File

@@ -5,16 +5,18 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="never"/>
</job>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="derby"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="hsql" />
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -5,9 +5,15 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="derby" />
<config>
<job-repository data-source="" db-type="db2" />
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource" />
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="mysql"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -5,16 +5,18 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="oracle"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="postgres" />
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
</beans:beans>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="" item-writer="itemWriter"/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="" item-writer="itemWriter"/>
</job>
</config>
<beans:bean id="itemWriter"
class="org.springframework.batch.execution.configuration.StubItemWriter"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer=""/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer=""/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" transaction-manager=""/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" transaction-manager=""/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="incomplete"/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter"/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter"/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="always"/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -0,0 +1,28 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="incomplete"/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>
<beans:bean id="itemWriter"
class="org.springframework.batch.execution.configuration.StubItemWriter"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
<beans:bean id="transactionManager"
class="org.springframework.batch.execution.configuration.StubTransactionManager"/>
</beans:beans>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="always"/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="never"/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter" rerun="never"/>
</job>
<job id="processJob">
<step id="process" size="10" item-reader="itemReader" item-writer="itemWriter"/>
</job>
</config>
<beans:bean id="itemReader"
class="org.springframework.batch.execution.configuration.StubItemReader"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet=""/>
</job>
<job id="processJob">
<tasklet-step id="process" tasklet=""/>
</job>
</config>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="incomplete"/>
</job>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet"/>
</job>
</config>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>

View File

@@ -5,11 +5,13 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<job-repository data-source="dataSource" db-type="db2"/>
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="always"/>
</job>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="always"/>
</job>
</config>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>

View File

@@ -0,0 +1,22 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="incomplete"/>
</job>
</config>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>

View File

@@ -0,0 +1,23 @@
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-1.0.xsd">
<config>
<job-repository data-source="dataSource" db-type="db2"/>
<job id="processJob">
<tasklet-step id="process" tasklet="processorTasklet" rerun="never"/>
</job>
</config>
<beans:bean id="processorTasklet"
class="org.springframework.batch.execution.configuration.TaskletTestBean"/>
<beans:bean id="dataSource"
class="org.springframework.batch.execution.configuration.StubDataSource"/>
</beans:beans>