diff --git a/spring-batch-execution/.springBeans b/spring-batch-execution/.springBeans
index 9d32ce747..e94082c10 100644
--- a/spring-batch-execution/.springBeans
+++ b/spring-batch-execution/.springBeans
@@ -1,56 +1,58 @@
-
-NamespaceHandler for the batch-execution namespace.
+ *
+ *
Provides a {@link BeanDefinitionParser} for the <batch:job> tag. A job
+ * tag can include nested chunked-step and tasklet-step tags.
+ *
+ * @author Ben Hale
+ */
+public class BatchNamespaceHandler extends NamespaceHandlerSupport {
+
+ /**
+ * Register the {@link BeanDefinitionParser BeanDefinitionParser} for the
+ * 'job', tag.
+ */
+ public void init() {
+ registerBeanDefinitionParser("job", new JobBeanDefinitionParser());
+ }
+
+}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/ChunkStepEntry.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/ChunkStepEntry.java
new file mode 100644
index 000000000..048f9c5eb
--- /dev/null
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/ChunkStepEntry.java
@@ -0,0 +1,41 @@
+/*
+ * 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";
+ }
+
+}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobBeanDefinitionParser.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobBeanDefinitionParser.java
index c3bd73622..7380711dc 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobBeanDefinitionParser.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobBeanDefinitionParser.java
@@ -1,21 +1,79 @@
package org.springframework.batch.execution.configuration;
+import org.springframework.batch.execution.step.tasklet.TaskletStep;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanNameReference;
+import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
+import org.springframework.beans.factory.parsing.ParseState;
+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;
class JobBeanDefinitionParser implements BeanDefinitionParser {
-
- public static final String JOB = "job";
-
- public static final String CHUNKING_STEP = "chunking-step";
-
- public static final String TASKLET_STEP ="tasklet-step";
+
+ private static final String TAG_JOB = "job";
+
+ private static final String TAG_CHUNKING_STEP = "chunking-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 final ParseState parseState = new ParseState();
public BeanDefinition parse(Element element, ParserContext parserContext) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
+ 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 node = childNodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String localName = node.getLocalName();
+ if (TAG_CHUNKING_STEP.equals(localName)) {
+// parseChunkingStep((Element) node, parserContext);
+ } else if (TAG_TASKLET_STEP.equals(localName)) {
+ parseTaskletStep((Element) node, parserContext);
+ }
+ }
+ }
+
+ parserContext.popAndRegisterContainingComponent();
+ return null;
}
+ private void parseTaskletStep(Element taskletElement, ParserContext parserContext) {
+ AbstractBeanDefinition taskletStepDef = createTaskletStepBeanDefinition(taskletElement, parserContext);
+ }
+
+ private AbstractBeanDefinition createTaskletStepBeanDefinition(Element taskletElement, ParserContext parserContext) {
+ RootBeanDefinition taskletStepDefinition = new RootBeanDefinition(TaskletStep.class);
+ taskletStepDefinition.setSource(parserContext.extractSource(taskletElement));
+
+ String tasklet = taskletElement.getAttribute(ATT_TASKLET);
+ if (!StringUtils.hasText(tasklet)) {
+ parserContext.getReaderContext().error("'tasklet' attribute contains empty value", taskletElement,
+ parseState.snapshot());
+ } else {
+ taskletStepDefinition.getPropertyValues().addPropertyValue(PROP_TASKLET,
+ new RuntimeBeanNameReference(tasklet));
+ }
+
+ System.out.println(taskletElement.hasAttribute("rerun"));
+ System.out.println(taskletElement.getAttribute("rerun"));
+
+ return taskletStepDefinition;
+ }
}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobEntry.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobEntry.java
new file mode 100644
index 000000000..4aa503471
--- /dev/null
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/JobEntry.java
@@ -0,0 +1,42 @@
+/*
+ * 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 + "'";
+ }
+}
diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/TaskletStepEntry.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/TaskletStepEntry.java
new file mode 100644
index 000000000..245f3b203
--- /dev/null
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/configuration/TaskletStepEntry.java
@@ -0,0 +1,41 @@
+/*
+ * 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";
+ }
+
+}
diff --git a/spring-batch-execution/src/main/resources/META-INF/spring.handlers b/spring-batch-execution/src/main/resources/META-INF/spring.handlers
index c3d371f98..cb8e0c842 100644
--- a/spring-batch-execution/src/main/resources/META-INF/spring.handlers
+++ b/spring-batch-execution/src/main/resources/META-INF/spring.handlers
@@ -1 +1 @@
-http\://www.springframework.org/schema/batch-execution=org.springframework.batch.execution.config.BatchCoreNamespaceHandler
+http\://www.springframework.org/schema/batch=org.springframework.batch.execution.configuration.BatchNamespaceHandler
diff --git a/spring-batch-execution/src/main/resources/META-INF/spring.schemas b/spring-batch-execution/src/main/resources/META-INF/spring.schemas
index b9b173a13..100a80e5a 100644
--- a/spring-batch-execution/src/main/resources/META-INF/spring.schemas
+++ b/spring-batch-execution/src/main/resources/META-INF/spring.schemas
@@ -1 +1 @@
-http\://www.springframework.org/schema/batch/spring-batch-execution-1.0.xsd=org/springframework/batch/core/config/spring-batch-execution-1.0.xsd
+http\://www.springframework.org/schema/batch/spring-batch-1.0.xsd=org/springframework/batch/execution/configuration/spring-batch-1.0.xsd
\ No newline at end of file
diff --git a/spring-batch-execution/src/main/resources/org/springframework/batch/execution/configuration/spring-batch-1.0.xsd b/spring-batch-execution/src/main/resources/org/springframework/batch/execution/configuration/spring-batch-1.0.xsd
new file mode 100644
index 000000000..41a228a0a
--- /dev/null
+++ b/spring-batch-execution/src/main/resources/org/springframework/batch/execution/configuration/spring-batch-1.0.xsd
@@ -0,0 +1,105 @@
+
+