diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SplitParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SplitParser.java index 0a106c949..5209dc22b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SplitParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SplitParser.java @@ -26,14 +26,14 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.core.task.TaskExecutor; import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; /** * Internal parser for the <split/> elements inside a job. A split element - * references a bean definition for a - * {@link org.springframework.batch.core.job.flow.JobExecutionDecider} and goes + * optionally references a bean definition for a {@link TaskExecutor} and goes * on to list a set of transitions to other states with <next on="pattern" * to="stepName"/>. Used by the {@link JobParser}. * @@ -48,6 +48,7 @@ public class SplitParser { * */ private static final String PARENT_ATTR = "parent"; + private final String jobFactoryRef; /** @@ -93,12 +94,13 @@ public class SplitParser { @SuppressWarnings("unchecked") Collection flows = new ManagedList(); int i = 0; - String prefix = idAttribute.startsWith(jobFactoryRef) ? idAttribute : jobFactoryRef+"."+idAttribute; + String prefix = idAttribute; for (Element nextElement : flowElements) { String ref = nextElement.getAttribute(PARENT_ATTR); if (StringUtils.hasText(ref)) { if (nextElement.getElementsByTagName("*").getLength() > 0) { - parserContext.getReaderContext().error("A in a must have ref= or nested , but not both.", nextElement); + parserContext.getReaderContext().error( + "A in a must have ref= or nested , but not both.", nextElement); } AbstractBeanDefinition flowDefinition = new GenericBeanDefinition(); flowDefinition.setParentName(ref); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests.java new file mode 100644 index 000000000..13a30132e --- /dev/null +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2006-2011 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.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParameters; +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 Josh Long + * + */ +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public class SplitNestedJobParserTests { + + @Autowired + @Qualifier("job") + private Job job; + + @Autowired + private JobRepository jobRepository; + + @Test + public void testSplitJob() throws Exception { + assertNotNull(job); + JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters()); + job.execute(jobExecution); + assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); + } + +} \ No newline at end of file diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests-context.xml new file mode 100644 index 000000000..85c206411 --- /dev/null +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/SplitNestedJobParserTests-context.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file