Updated to remove redundant class

This commit is contained in:
Michael Minella
2013-11-20 17:13:26 -06:00
parent 1ef21104ac
commit 3ea8d3ed65
2 changed files with 10 additions and 70 deletions

View File

@@ -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<BeanDefinition> parseFlow(Element element, ParserContext parserContext) {
private Collection<BeanDefinition> 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);
}

View File

@@ -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;
/**
* <p>
* Parses a flow element in a JSR-352 job defintion.
* </p>
*
* @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);
}
}