diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java
index 465d13397..24d40b9b8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java
@@ -31,5 +31,6 @@ public class CoreNamespaceHandler extends NamespaceHandlerSupport {
*/
public void init() {
this.registerBeanDefinitionParser("job", new JobParser());
+ this.registerBeanDefinitionParser("job-repository", new JobRepositoryParser());
}
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java
new file mode 100644
index 000000000..62aa245b7
--- /dev/null
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobRepositoryParser.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006-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.core.configuration.xml;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the lt;job-repository/gt; element in the Batch namespace. Sets up and returns
+ * a JobRepositoryFactoryBean.
+ *
+ * @author Thomas Risberg
+ * @since 2.0
+ *
+ */
+public class JobRepositoryParser extends AbstractSingleBeanDefinitionParser {
+
+ private final Log logger = LogFactory.getLog(getClass());
+
+ protected String getBeanClassName(Element element) {
+ return "org.springframework.batch.core.repository.support.JobRepositoryFactoryBean";
+ }
+
+ /**
+ * Parse and create a bean definition for a
+ * {@link org.springframework.batch.core.repository.support.JobRepositoryFactoryBean}.
+ */
+ protected void doParse(Element element, BeanDefinitionBuilder builder) {
+
+ String dataSource = element.getAttribute("data-source");
+
+ String transactionManager = element.getAttribute("transaction-manager");
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Using data-source: " + dataSource);
+ logger.debug("Using transaction-manager: " + transactionManager);
+ }
+
+ RuntimeBeanReference ds = new RuntimeBeanReference(dataSource);
+ builder.addPropertyValue("dataSource", ds);
+ RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager);
+ builder.addPropertyValue("transactionManager", tx);
+
+ builder.setRole(BeanDefinition.ROLE_SUPPORT);
+
+ }
+
+}
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
index 162d6ec28..686a42a5f 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
@@ -177,6 +177,48 @@ The decider is a reference to a JobExecutionDecider that can produce a status to
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests.java
new file mode 100644
index 000000000..3091585c8
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006-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.core.configuration.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+
+/**
+ * @author Thomas Risberg
+ *
+ */
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class JobRepositoryParserTests {
+
+ @Autowired
+ @Qualifier("jobRepo1")
+ private JobRepository jobRepository;
+
+ @Test
+ public void testOneStep() throws Exception {
+ assertNotNull(jobRepository);
+ }
+
+}
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests-context.xml
new file mode 100644
index 000000000..33a907cce
--- /dev/null
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobRepositoryParserTests-context.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file