RESOLVED - issue BATCH-241: Support for JobLauncher.stop() on job that hasn't started yet (delayed execution)

http://jira.springframework.org/browse/BATCH-241

Since SimpleJobLauncher no longer has a stop method, we have to do the check on execution, lower down the stack.  Added explicit check for STOPPED status in SimpleJob and JoBExecution.
This commit is contained in:
dsyer
2008-02-11 19:54:21 +00:00
parent 2ce3013ac1
commit 2b87124b85
25 changed files with 140 additions and 116 deletions

View File

@@ -66,7 +66,7 @@ public class JobExecution extends Entity {
public JobExecution(JobInstance job) {
this(job, null);
}
public Date getEndTime() {
return endTime;
}
@@ -164,7 +164,7 @@ public class JobExecution extends Entity {
* @return true if the end time is null
*/
public boolean isRunning() {
return endTime == null;
return endTime == null && !(BatchStatus.STOPPED==status);
}
/**
@@ -177,5 +177,6 @@ public class JobExecution extends Entity {
StepExecution stepExecution = (StepExecution) it.next();
stepExecution.setTerminateOnly();
}
status = BatchStatus.STOPPED;
}
}

View File

@@ -19,19 +19,19 @@ package org.springframework.batch.core.domain;
import org.springframework.batch.io.exception.BatchCriticalException;
/**
* Exception to indicate the the lifecycle has been interrupted. The exception
* state indicated is not normally recoverable by batch application clients, but
* internally it is useful to force a check. The exception will be wrapped in a
* runtime exception (usually {@link BatchCriticalException} before reaching the
* client.
* Exception to indicate the the job has been interrupted. The exception state
* indicated is not normally recoverable by batch application clients, but
* internally it is useful to force a check. The exception will often be wrapped
* in a runtime exception (usually {@link BatchCriticalException} before
* reaching the client.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class StepInterruptedException extends JobExecutionException {
public class JobInterruptedException extends JobExecutionException {
public StepInterruptedException(String msg) {
public JobInterruptedException(String msg) {
super(msg);
}
}

View File

@@ -62,10 +62,10 @@ public interface Step {
*
* @param stepExecution an entity representing the step to be executed
*
* @throws StepInterruptedException if the step is interrupted externally
* @throws JobInterruptedException if the step is interrupted externally
* @throws BatchCriticalException if there is a problem that needs to be
* signalled to the caller
*/
void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException;
void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException;
}

View File

@@ -117,7 +117,7 @@ public class StepSupport implements Step, BeanNameAware {
*
* @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution)
*/
public void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException {
public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException {
throw new UnsupportedOperationException(
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
}

View File

@@ -19,21 +19,22 @@ import org.springframework.batch.common.ExceptionClassifier;
import org.springframework.batch.repeat.ExitStatus;
/**
* Extension of the ExceptionClassifier that explicitly deals with
* returns an ExitStatus. This is useful for mapping from an exception
* type to an Exit Code with a detailed message.
* Extension of the {@link ExceptionClassifier} that explicitly deals with
* returns an {@link ExitStatus}. This is useful for mapping from an exception
* type to an exit status with a customised code or detailed message.
*
* @author Lucas Ward
*
*
*/
public interface ExitCodeExceptionClassifier extends ExceptionClassifier {
public interface ExitStatusExceptionClassifier extends ExceptionClassifier {
public static final String FATAL_EXCEPTION = "FATAL_EXCEPTION";
public static final String JOB_INTERRUPTED = "JOB_INTERRUPTED";
static final String FATAL_EXCEPTION = "FATAL_EXCEPTION";
static final String STEP_INTERRUPTED = "STEP_INTERRUPTED";
/**
* Typesafe version of classify that explicitly returns an {@link ExitStatus}
* object.
* Typesafe version of classify that explicitly returns an
* {@link ExitStatus} object.
*
* @param throwable
* @return ExitStatus representing the ExitCode and Message for the given