BATCH-220: Half way to rename StepHandler -> Tasklet

This commit is contained in:
dsyer
2008-08-28 10:38:26 +00:00
parent 223a58da18
commit ad5b0010dd
38 changed files with 200 additions and 110 deletions

View File

@@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.listener.MulticasterBatchListener;
import org.springframework.batch.core.step.handler.StepHandler;
import org.springframework.batch.core.step.tasklet.StepHandler;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
@@ -114,7 +114,7 @@ public class ItemOrientedStepHandler<T, S> implements StepHandler {
* {@link ItemProcessor} returns null, the write is omitted and another item
* taken from the reader.
*
* @see org.springframework.batch.core.step.handler.StepHandler#handle(org.springframework.batch.core.StepContribution,
* @see org.springframework.batch.core.step.tasklet.StepHandler#handle(org.springframework.batch.core.StepContribution,
* AttributeAccessor)
*/
public ExitStatus handle(final StepContribution contribution, AttributeAccessor attributes) throws Exception {

View File

@@ -21,7 +21,7 @@ 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.handler.StepHandlerStep;
import org.springframework.batch.core.step.tasklet.StepHandlerStep;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;

View File

@@ -9,11 +9,11 @@ import java.util.List;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.step.handler.StepHandlerStep;
import org.springframework.batch.core.step.skip.ItemSkipPolicy;
import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy;
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
import org.springframework.batch.core.step.skip.SkipListenerFailedException;
import org.springframework.batch.core.step.tasklet.StepHandlerStep;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.core.AttributeAccessorSupport;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import java.util.concurrent.Callable;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.batch.repeat.ExitStatus;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.item.ItemReader;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -25,6 +25,7 @@ import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
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.AbstractStep;
import org.springframework.batch.core.step.StepExecutionSynchronizer;
@@ -82,6 +83,13 @@ public class StepHandlerStep extends AbstractStep {
private StepExecutionSynchronizer synchronizer;
/**
* Default constructor.
*/
public StepHandlerStep() {
this(null);
}
/**
* @param name
*/
@@ -114,6 +122,9 @@ public class StepHandlerStep extends AbstractStep {
*/
public void setStepHandler(StepHandler stepHandler) {
this.stepHandler = stepHandler;
if (stepHandler instanceof StepExecutionListener) {
registerStepExecutionListener((StepExecutionListener) stepHandler);
}
}
/**
@@ -195,9 +206,9 @@ public class StepHandlerStep extends AbstractStep {
* Process the step and update its context so that progress can be monitored
* by the caller. The step is broken down into chunks, each one executing in
* a transaction. The step and its execution and execution context are all
* given an up to date {@link BatchStatus}, and the {@link JobRepository} is
* used to store the result. Various reporting information are also added to
* the current context (the {@link RepeatContext} governing the step
* given an up to date {@link BatchStatus}, and the {@link JobRepository}
* is used to store the result. Various reporting information are also added
* to the current context (the {@link RepeatContext} governing the step
* execution, which would normally be available to the caller somehow
* through the step's {@link ExecutionContext}.<br/>
*
@@ -369,8 +380,8 @@ public class StepHandlerStep extends AbstractStep {
}
catch (Exception e) {
/*
* If we already failed to commit, it doesn't help to do this again
* - it's better to allow the CommitFailedException to propagate
* If we already failed to commit, it doesn't help to do this again -
* it's better to allow the CommitFailedException to propagate
*/
if (!fatalException.hasException()) {
fatalException.setException(e);

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
/**
* Exception indicating failed execution of system command.

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import java.io.File;
import java.io.IOException;

View File

@@ -1,6 +1,6 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.batch.core.step.handler.SystemCommandStepHandler;
import org.springframework.batch.core.step.tasklet.SystemCommandStepHandler;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -28,10 +28,10 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.step.handler.BasicAttributeAccessor;
import org.springframework.batch.core.step.item.SkipLimitStepFactoryBean.StatefulRetryStepHandler;
import org.springframework.batch.core.step.skip.ItemSkipPolicy;
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
import org.springframework.batch.core.step.tasklet.BasicAttributeAccessor;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -21,6 +21,7 @@ import static org.junit.Assert.fail;
import java.util.concurrent.Callable;
import org.junit.Test;
import org.springframework.batch.core.step.tasklet.CallableStepHandlerAdapter;
import org.springframework.batch.repeat.ExitStatus;
public class CallableStepHandlerAdapterTests {

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
@@ -7,7 +7,7 @@ import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.batch.core.step.handler.ConfigurableSystemProcessExitCodeMapper;
import org.springframework.batch.core.step.tasklet.ConfigurableSystemProcessExitCodeMapper;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import org.springframework.batch.core.step.handler.StepHandler;
import org.springframework.batch.core.step.item.ItemOrientedStepHandler;
import org.springframework.batch.core.step.tasklet.StepHandler;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.support.PassthroughItemProcessor;

View File

@@ -1,8 +1,9 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.batch.core.step.tasklet.SimpleSystemProcessExitCodeMapper;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import java.util.List;
@@ -33,7 +33,7 @@ import org.springframework.batch.core.repository.dao.MapJobInstanceDao;
import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.springframework.batch.core.step.StepExecutionSynchronizer;
import org.springframework.batch.core.step.handler.StepHandlerStep;
import org.springframework.batch.core.step.tasklet.StepHandlerStep;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;

View File

@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.step.tasklet.StepHandlerAdapter;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -39,7 +39,7 @@ import org.springframework.batch.core.repository.dao.MapJobExecutionDao;
import org.springframework.batch.core.repository.dao.MapJobInstanceDao;
import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
import org.springframework.batch.core.step.handler.StepHandlerStep;
import org.springframework.batch.core.step.tasklet.StepHandlerStep;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -47,7 +47,7 @@ import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.StepInterruptionPolicy;
import org.springframework.batch.core.step.handler.StepHandlerStep;
import org.springframework.batch.core.step.tasklet.StepHandlerStep;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.core.step.handler;
package org.springframework.batch.core.step.tasklet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -15,6 +15,9 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.step.tasklet.SystemCommandException;
import org.springframework.batch.core.step.tasklet.SystemCommandStepHandler;
import org.springframework.batch.core.step.tasklet.SystemProcessExitCodeMapper;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.util.Assert;