diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/InlineFlowParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/InlineFlowParser.java index 36faa624c..911225368 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/InlineFlowParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/InlineFlowParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2014 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. @@ -28,7 +28,6 @@ import org.w3c.dom.Element; * */ public class InlineFlowParser extends AbstractFlowParser { - private final String flowName; /** @@ -45,13 +44,17 @@ public class InlineFlowParser extends AbstractFlowParser { } + @Override + protected boolean shouldGenerateId() { + return true; + } + /** * @param element the top level element containing a flow definition * @param parserContext the {@link ParserContext} */ @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)); @@ -60,5 +63,4 @@ public class InlineFlowParser extends AbstractFlowParser { parserContext.popAndRegisterContainingComponent(); } - } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests.java new file mode 100644 index 000000000..e88b28d38 --- /dev/null +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests.java @@ -0,0 +1,41 @@ +/* + * Copyright 2014 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.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + *
+ * Test cases for BATCH-1863. + *
+ */ +public class BeanDefinitionOverrideTests { + @Test + public void testAllowBeanOverride() { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setConfigLocation("org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml"); + applicationContext.refresh(); + } + + @Test + public void testAllowBeanOverrideFalse() { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setAllowBeanDefinitionOverriding(false); + applicationContext.setConfigLocation("org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml"); + applicationContext.refresh(); + } +} diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml new file mode 100644 index 000000000..ea54fcf4c --- /dev/null +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml @@ -0,0 +1,24 @@ + + +