From 85806724a5126438ee341afba95d88bbe03133e5 Mon Sep 17 00:00:00 2001 From: dsyer Date: Mon, 25 Feb 2008 17:54:36 +0000 Subject: [PATCH] Remove RepeatOperationsStep --- .../execution/step/RepeatOperationsStep.java | 69 ---------- .../execution/launch/SimpleJobTests.java | 8 +- .../support/RepeatOperationsStepTests.java | 125 ------------------ .../StepExecutorInterruptionTests.java | 6 +- .../src/main/resources/jobs/hibernateJob.xml | 2 +- .../src/main/resources/jobs/parallelJob.xml | 2 +- .../resources/simple-container-definition.xml | 5 - 7 files changed, 9 insertions(+), 208 deletions(-) delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/step/RepeatOperationsStep.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/RepeatOperationsStepTests.java diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/RepeatOperationsStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/RepeatOperationsStep.java deleted file mode 100644 index d2166ec01..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/RepeatOperationsStep.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2006-2007 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.execution.step; - -import org.springframework.batch.core.domain.JobInterruptedException; -import org.springframework.batch.core.domain.Step; -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.repeat.RepeatOperations; - -/** - * A {@link Step} implementation that allows full configuration of the - * {@link RepeatOperations} that will be used in the chunk (inner loop). - *
- * - * This class may be obsolete soon. - * - * @author Lucas Ward - * @author Dave Syer - * @author Ben Hale - */ -public class RepeatOperationsStep extends ItemOrientedStep { - - private volatile RepeatOperations chunkOperations; - - private volatile RepeatOperations stepOperations; - - /** - * Public setter for the chunkOperations. - * - * @param chunkOperations the repeatOperations to set - */ - public void setChunkOperations(RepeatOperations chunkOperations) { - this.chunkOperations = chunkOperations; - } - - /** - * Public setter for the {@link RepeatOperations} property. - * - * @param stepOperations the stepOperations to set - */ - public void setStepOperations(RepeatOperations stepOperations) { - this.stepOperations = stepOperations; - } - - public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException { - if (stepOperations != null) { - super.setStepOperations(stepOperations); - } - if (chunkOperations != null) { - super.setChunkOperations(chunkOperations); - } - super.execute(stepExecution); - } -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java index 72629548a..fd444102b 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java @@ -33,7 +33,7 @@ import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.MapJobDao; import org.springframework.batch.execution.repository.dao.MapStepDao; import org.springframework.batch.execution.step.AbstractStep; -import org.springframework.batch.execution.step.RepeatOperationsStep; +import org.springframework.batch.execution.step.ItemOrientedStep; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.reader.ListItemReader; @@ -75,8 +75,8 @@ public class SimpleJobTests extends TestCase { return getStep(new String[] { arg0, arg1 }); } - private RepeatOperationsStep getStep(String[] args) throws Exception { - RepeatOperationsStep step = new RepeatOperationsStep(); + private ItemOrientedStep getStep(String[] args) throws Exception { + ItemOrientedStep step = new ItemOrientedStep(); List items = TransactionAwareProxyFactory.createTransactionalList(); items.addAll(Arrays.asList(args)); provider = new ListItemReader(items); @@ -132,7 +132,7 @@ public class SimpleJobTests extends TestCase { * is recovered ("skipped") on the second attempt (see retry policy * definition above)... */ - RepeatOperationsStep step = getStep(new String[] { "foo", "bar", "spam" }); + ItemOrientedStep step = getStep(new String[] { "foo", "bar", "spam" }); // Tasklet module = getTasklet(new String[] { "foo", "bar", "spam" }); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/RepeatOperationsStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/RepeatOperationsStepTests.java deleted file mode 100644 index 5e71fb89c..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/RepeatOperationsStepTests.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2006-2007 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.execution.step.support; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.domain.JobParameters; -import org.springframework.batch.core.domain.JobSupport; -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.core.domain.StepSupport; -import org.springframework.batch.execution.step.ItemOrientedStep; -import org.springframework.batch.execution.step.RepeatOperationsStep; -import org.springframework.batch.item.reader.AbstractItemReader; -import org.springframework.batch.item.reader.ItemReaderAdapter; -import org.springframework.batch.item.writer.AbstractItemWriter; -import org.springframework.batch.item.writer.ItemWriterAdapter; -import org.springframework.batch.repeat.RepeatContext; -import org.springframework.batch.repeat.interceptor.RepeatListenerSupport; -import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; -import org.springframework.batch.repeat.support.RepeatTemplate; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; - -/** - * @author Dave Syer - * - */ -public class RepeatOperationsStepTests extends TestCase { - - RepeatOperationsStep repeatStep = new RepeatOperationsStep(); - - protected void setUp() throws Exception { - super.setUp(); - - repeatStep.setItemReader(new ItemReaderAdapter()); - repeatStep.setItemWriter(new ItemWriterAdapter()); - } - - public void testSuccessfulRepeatOperationsHolder() throws Exception { - RepeatTemplate repeatTemplate = new RepeatTemplate(); - final List list = new ArrayList(); - repeatTemplate.setListener(new RepeatListenerSupport() { - public void onError(RepeatContext context, Throwable e) { - list.add(e); - } - }); - repeatTemplate.setCompletionPolicy(new SimpleCompletionPolicy(2)); - ItemOrientedStep configuration = new ItemOrientedStep(); - configuration.setItemReader(new AbstractItemReader(){ - public Object read() throws Exception { - throw new NullPointerException(); - }}); - configuration.setItemWriter(new AbstractItemWriter(){ - public void write(Object item) throws Exception { - }}); - configuration.setChunkOperations(repeatTemplate); - configuration.setJobRepository(new JobRepositorySupport()); - configuration.setTransactionManager(new ResourcelessTransactionManager()); - StepExecution stepExecution = new StepExecution(new StepSupport("stepName"), new JobExecution(new JobInstance(new Long(0L), new JobParameters(), new JobSupport("testJob")), - new Long(12))); - configuration.afterPropertiesSet(); - try { - configuration.execute(stepExecution); - fail("Expected RuntimeException"); - } catch (NullPointerException e) { - // expected - } - assertEquals(1, list.size()); - } - - public void testSuccessfulRepeatOperationsHolderWithStepOperations() throws Exception { - RepeatTemplate chunkTemplate = new RepeatTemplate(); - final List list = new ArrayList(); - chunkTemplate.setListener(new RepeatListenerSupport() { - public void before(RepeatContext context) { - list.add(context); - } - }); - chunkTemplate.setCompletionPolicy(new SimpleCompletionPolicy(2)); - RepeatTemplate stepTemplate = new RepeatTemplate(); - final List steps = new ArrayList(); - stepTemplate.setListener(new RepeatListenerSupport() { - public void before(RepeatContext context) { - steps.add(context); - } - }); - stepTemplate.setCompletionPolicy(new SimpleCompletionPolicy(1)); - RepeatOperationsStep configuration = new RepeatOperationsStep(); - configuration.setItemReader(new AbstractItemReader(){ - public Object read() throws Exception { - return new Object(); - }}); - configuration.setItemWriter(new AbstractItemWriter(){ - public void write(Object item) throws Exception { - }}); - configuration.setChunkOperations(chunkTemplate); - configuration.setStepOperations(stepTemplate); - configuration.setJobRepository(new JobRepositorySupport()); - configuration.setTransactionManager(new ResourcelessTransactionManager()); - StepExecution stepExecution = new StepExecution(new StepSupport("stepName"), new JobExecution(new JobInstance(new Long(0L), new JobParameters(), new JobSupport("testJob")), - new Long(12))); - configuration.afterPropertiesSet(); - configuration.execute(stepExecution); - assertEquals(2, list.size()); - assertEquals(1, steps.size()); - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java index adc5ffbe0..cbe9613f6 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/support/StepExecutorInterruptionTests.java @@ -32,7 +32,7 @@ import org.springframework.batch.execution.repository.dao.JobInstanceDao; import org.springframework.batch.execution.repository.dao.MapJobDao; import org.springframework.batch.execution.repository.dao.MapStepDao; import org.springframework.batch.execution.repository.dao.StepExecutionDao; -import org.springframework.batch.execution.step.RepeatOperationsStep; +import org.springframework.batch.execution.step.ItemOrientedStep; import org.springframework.batch.item.reader.AbstractItemReader; import org.springframework.batch.item.reader.ItemReaderAdapter; import org.springframework.batch.item.writer.AbstractItemWriter; @@ -50,14 +50,14 @@ public class StepExecutorInterruptionTests extends TestCase { private StepExecutionDao stepExecutionDao = new MapStepDao(); - private RepeatOperationsStep step; + private ItemOrientedStep step; public void setUp() throws Exception { jobRepository = new SimpleJobRepository(jobInstanceDao, jobExecutionDao, stepExecutionDao); JobSupport jobConfiguration = new JobSupport(); - step = new RepeatOperationsStep(); + step = new ItemOrientedStep(); step.setName("stepName"); jobConfiguration.addStep(step); jobConfiguration.setBeanName("testJob"); diff --git a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml index 399fe11dc..3ab7fb863 100644 --- a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml @@ -18,7 +18,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml index b789b3822..9b23d98b9 100644 --- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml @@ -46,7 +46,7 @@ value="true" /> - + - - -