OPEN - issue BATCH-282: Make input parameters easier to access from ItemReaders, etc.

Revert change to method signature in AbstractStep
This commit is contained in:
dsyer
2008-10-16 11:08:59 +00:00
parent 9bf4241893
commit fa4a690cda
5 changed files with 15 additions and 17 deletions

View File

@@ -41,7 +41,8 @@ public abstract class StepContextRepeatCallback implements RepeatCallback {
/**
* Manage the {@link StepContext} lifecycle to ensure that the current
* thread has a reference to the context, even if the callback is executed
* in a pooled thread.
* in a pooled thread. Handles the registration and de-registration of the
* step context, so clients should not duplicate those calls.
*
* @see RepeatCallback#doInIteration(RepeatContext)
*/

View File

@@ -145,12 +145,12 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
/**
* Extension point for subclasses to execute business logic.
*
* @param stepContext the current step context
* @param stepExecution the current step context
* @return {@link ExitStatus} to show whether the step is finished
* processing.
* @throws Exception
*/
protected abstract ExitStatus doExecute(StepContext stepContext) throws Exception;
protected abstract ExitStatus doExecute(StepExecution stepExecution) throws Exception;
/**
* Extension point for subclasses to provide callbacks to their
@@ -177,7 +177,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
/**
* Template method for step execution logic - calls abstract methods for
* resource initialization ({@link #open(ExecutionContext)}), execution
* logic ({@link #doExecute(StepContext)}) and resource closing ({@link #close(ExecutionContext)}).
* logic ({@link #doExecute(StepExecution)}) and resource closing ({@link #close(ExecutionContext)}).
*/
public final void execute(StepExecution stepExecution) throws JobInterruptedException,
UnexpectedJobExecutionException {
@@ -195,7 +195,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
getCompositeListener().beforeStep(stepExecution);
open(stepExecution.getExecutionContext());
exitStatus = doExecute(stepContext);
exitStatus = doExecute(stepExecution);
// Check if someone is trying to stop us
if (stepExecution.isTerminateOnly()) {

View File

@@ -227,8 +227,8 @@ public class TaskletStep extends AbstractStep {
*
*/
@Override
protected ExitStatus doExecute(StepContext stepContext) throws Exception {
StepExecution stepExecution = stepContext.getStepExecution();
protected ExitStatus doExecute(StepExecution stepExecution) throws Exception {
StepContext stepContext = new StepContext(stepExecution);
stream.update(stepExecution.getExecutionContext());
getJobRepository().updateExecutionContext(stepExecution);

View File

@@ -16,7 +16,6 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.scope.StepContext;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.util.Assert;
@@ -55,8 +54,8 @@ public class AbstractStepTests {
events.add("open");
}
protected ExitStatus doExecute(StepContext context) throws Exception {
assertSame(execution, context.getStepExecution());
protected ExitStatus doExecute(StepExecution context) throws Exception {
assertSame(execution, context);
events.add("doExecute");
return ExitStatus.FINISHED;
}
@@ -167,7 +166,7 @@ public class AbstractStepTests {
public void testFailure() throws Exception {
tested = new EventTrackingStep() {
@Override
protected ExitStatus doExecute(StepContext context) throws Exception {
protected ExitStatus doExecute(StepExecution context) throws Exception {
super.doExecute(context);
throw new RuntimeException("crash!");
}
@@ -205,8 +204,8 @@ public class AbstractStepTests {
public void testStoppedStep() throws Exception {
tested = new EventTrackingStep() {
@Override
protected ExitStatus doExecute(StepContext context) throws Exception {
context.getStepExecution().setTerminateOnly();
protected ExitStatus doExecute(StepExecution context) throws Exception {
context.setTerminateOnly();
return super.doExecute(context);
}
};
@@ -241,7 +240,7 @@ public class AbstractStepTests {
public void testFailureInSavingExecutionContext() throws Exception {
tested = new EventTrackingStep() {
@Override
protected ExitStatus doExecute(StepContext context) throws Exception {
protected ExitStatus doExecute(StepExecution context) throws Exception {
super.doExecute(context);
return ExitStatus.FINISHED;
}

View File

@@ -19,7 +19,6 @@ import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.scope.StepContext;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
@@ -98,10 +97,9 @@ public class MessageOrientedStep extends AbstractStep {
* @see AbstractStep#execute(StepExecution)
*/
@Override
public ExitStatus doExecute(StepContext stepContext) throws JobInterruptedException,
public ExitStatus doExecute(StepExecution stepExecution) throws JobInterruptedException,
UnexpectedJobExecutionException {
StepExecution stepExecution = stepContext.getStepExecution();
JobExecutionRequest request = new JobExecutionRequest(stepExecution .getJobExecution());
ExecutionContext executionContext = stepExecution.getExecutionContext();