diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/FlowParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/FlowParser.java index 94993a28d..e2a4e7321 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/FlowParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/FlowParser.java @@ -26,7 +26,9 @@ import java.util.Set; import org.springframework.batch.core.configuration.xml.AbstractFlowParser; import org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean; import org.springframework.batch.core.job.flow.FlowExecutionStatus; +import org.springframework.batch.core.job.flow.support.DefaultStateTransitionComparator; 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.support.ManagedList; import org.springframework.beans.factory.xml.ParserContext; @@ -100,11 +102,7 @@ public class FlowParser extends AbstractFlowParser { } else if(nodeName.equals(DECISION_ELEMENT)) { stateTransitions.addAll(new DecisionParser().parse(child, parserContext, flowName)); } else if(nodeName.equals(FLOW_ELEMENT)) { - org.springframework.batch.core.jsr.configuration.xml.InlineFlowParser flowParser = - new org.springframework.batch.core.jsr.configuration.xml.InlineFlowParser(child.getAttribute(ID_ATTRIBUTE), jobFactoryRef); - flowParser.parse(child, parserContext); - - stateTransitions.addAll(parseFlow(child, parserContext)); + stateTransitions.addAll(parseFlow(child, parserContext, builder)); } } } @@ -122,7 +120,7 @@ public class FlowParser extends AbstractFlowParser { builder.addPropertyValue("stateTransitions", managedList); } - private Collection parseFlow(Element element, ParserContext parserContext) { + private Collection parseFlow(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String idAttribute = element.getAttribute(ID_ATTRIBUTE); BeanDefinitionBuilder stateBuilder = BeanDefinitionBuilder @@ -133,6 +131,12 @@ public class FlowParser extends AbstractFlowParser { stateBuilder.addConstructorArgValue(flowParser.parse(element, parserContext)); stateBuilder.addConstructorArgValue(idAttribute); + builder.getRawBeanDefinition().setAttribute("flowName", idAttribute); + builder.addPropertyValue("name", idAttribute); + builder.addPropertyValue("stateTransitionComparator", new RuntimeBeanReference(DefaultStateTransitionComparator.STATE_TRANSITION_COMPARATOR)); + doParse(element, parserContext, builder); + builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); + return FlowParser.getNextElements(parserContext, null, stateBuilder.getBeanDefinition(), element); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/InlineFlowParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/InlineFlowParser.java deleted file mode 100644 index ec4637711..000000000 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/xml/InlineFlowParser.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013 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.jsr.configuration.xml; - -import org.springframework.batch.core.job.flow.support.DefaultStateTransitionComparator; -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.ParserContext; -import org.w3c.dom.Element; - -/** - *

- * Parses a flow element in a JSR-352 job defintion. - *

- * - * @author Chris Schaefer - * @since 3.0 - */ -public class InlineFlowParser extends FlowParser { - private final String flowName; - - /** - * Construct a {@link InlineFlowParser} with the specified name and using the - * provided job repository ref. - * - * @param flowName the name of the flow - * @param jobFactoryRef the reference to the {@link org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean} - * from the enclosing tag - */ - public InlineFlowParser(String flowName, String jobFactoryRef) { - super(flowName, jobFactoryRef); - this.flowName = flowName; - } - - /** - * Parses the flow from the provided {@link Element}. - * - * @param element the top level element containing a flow definition - * @param parserContext the {@link org.springframework.beans.factory.xml.ParserContext} - * @param builder the {@link BeanDefinitionBuilder} to handle bean defintion operations - */ - @Override - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - builder.getRawBeanDefinition().setAttribute("flowName", flowName); - builder.addPropertyValue("name", flowName); - builder.addPropertyValue("stateTransitionComparator", new RuntimeBeanReference(DefaultStateTransitionComparator.STATE_TRANSITION_COMPARATOR)); - super.doParse(element, parserContext, builder); - builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); - } -}