BATCH-1154:
*Renamed the "master" step factory bean to StepParserStepFactoryBean *Moved it to the same package as the parser *Made it package visibility since it should only be used by the parser
This commit is contained in:
@@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.step.item.StepFactoryBean;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
@@ -111,7 +110,7 @@ public abstract class AbstractStepParser {
|
||||
String jobRepositoryRef) {
|
||||
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setBeanClass(StepFactoryBean.class);
|
||||
bd.setBeanClass(StepParserStepFactoryBean.class);
|
||||
|
||||
if (StringUtils.hasText(taskletRef)) {
|
||||
RuntimeBeanReference taskletBeanRef = new RuntimeBeanReference(taskletRef);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.step.item;
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
import java.util.ArrayList;
|
||||
@@ -25,6 +25,8 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean;
|
||||
import org.springframework.batch.core.step.item.SimpleStepFactoryBean;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.batch.item.ItemProcessor;
|
||||
@@ -46,14 +48,18 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* This {@link FactoryBean} is used by the batch namespace parser to create
|
||||
* {@link Step} objects.
|
||||
* {@link Step} objects. Stores all of the properties that are configurable on
|
||||
* the <step/> (and its inner <tasklet/>). Based on which properties
|
||||
* are configured, the {@link #getObject()} method will delegate to the
|
||||
* appropriate class for generating the {@link Step}.
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
* @see SimpleStepFactoryBean
|
||||
* @see FaultTolerantStepFactoryBean
|
||||
* @see TaskletStep
|
||||
*/
|
||||
public class StepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
|
||||
class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
|
||||
|
||||
//
|
||||
// Step Attributes
|
||||
@@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.step.item.StepFactoryBean;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanReference;
|
||||
@@ -50,7 +49,7 @@ public class TaskletElementParser {
|
||||
protected AbstractBeanDefinition parse(Element element, ParserContext parserContext, boolean underspecified) {
|
||||
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setBeanClass(StepFactoryBean.class);
|
||||
bd.setBeanClass(StepParserStepFactoryBean.class);
|
||||
|
||||
MutablePropertyValues propertyValues = bd.getPropertyValues();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.step.item;
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -22,12 +22,10 @@ import java.util.ArrayList;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.configuration.xml.DummyCompletionPolicy;
|
||||
import org.springframework.batch.core.configuration.xml.DummyItemReader;
|
||||
import org.springframework.batch.core.configuration.xml.DummyItemWriter;
|
||||
import org.springframework.batch.core.configuration.xml.DummyTasklet;
|
||||
import org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.JobRepositorySupport;
|
||||
import org.springframework.batch.core.step.item.ChunkOrientedTasklet;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.file.FlatFileItemReader;
|
||||
@@ -41,17 +39,17 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
public class StepFactoryBeanTests {
|
||||
public class StepParserStepFactoryBeanTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testNothingSet() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.getObject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyTaskletSet() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setTasklet(new DummyTasklet());
|
||||
Object step = fb.getObject();
|
||||
assertTrue(step instanceof TaskletStep);
|
||||
@@ -61,14 +59,14 @@ public class StepFactoryBeanTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSkipLimitSet() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setSkipLimit(5);
|
||||
fb.getObject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletStep_All() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
@@ -85,7 +83,7 @@ public class StepFactoryBeanTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSimpleStep_All() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
@@ -108,7 +106,7 @@ public class StepFactoryBeanTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testFaultTolerantStep_All() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
@@ -139,7 +137,7 @@ public class StepFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleStep() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setHasTaskletElement(true);
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -163,7 +161,7 @@ public class StepFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
public void testFaultTolerantStep() throws Exception {
|
||||
StepFactoryBean<Object, Object> fb = new StepFactoryBean<Object, Object>();
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
|
||||
fb.setHasTaskletElement(true);
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -27,7 +27,6 @@ import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.item.StepFactoryBean;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.batch.repeat.CompletionPolicy;
|
||||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
@@ -50,9 +49,9 @@ public class StepParserTests {
|
||||
public void testTaskletStepAttributes() throws Exception {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml");
|
||||
Map<String, Object> beans = ctx.getBeansOfType(StepFactoryBean.class);
|
||||
Map<String, Object> beans = ctx.getBeansOfType(StepParserStepFactoryBean.class);
|
||||
String factoryName = (String) beans.keySet().toArray()[0];
|
||||
StepFactoryBean<Object, Object> factory = (StepFactoryBean<Object, Object>) beans.get(factoryName);
|
||||
StepParserStepFactoryBean<Object, Object> factory = (StepParserStepFactoryBean<Object, Object>) beans.get(factoryName);
|
||||
TaskletStep bean = (TaskletStep) factory.getObject();
|
||||
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
import org.springframework.batch.core.step.item.StepFactoryBean;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -67,7 +66,7 @@ public class StepWithBasicProcessTaskJobParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Autowired
|
||||
private StepFactoryBean factory;
|
||||
private StepParserStepFactoryBean factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
import org.springframework.batch.core.step.item.StepFactoryBean;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.retry.RetryListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -75,7 +74,7 @@ public class StepWithFaultTolerantProcessTaskJobParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Autowired
|
||||
private StepFactoryBean factory;
|
||||
private StepParserStepFactoryBean factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
Reference in New Issue
Block a user