IN PROGRESS - issue BATCH-476: samples cleanup

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

removed interrupt advice (to sandbox)
This commit is contained in:
robokaso
2008-03-18 10:30:15 +00:00
parent 9f9d909b5a
commit 9d51fffcb0
4 changed files with 0 additions and 174 deletions

View File

@@ -1,44 +0,0 @@
package org.springframework.batch.sample.advice;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInterruptedException;
/**
* Monitors {@link JobExecution} and throws a {@link JobInterruptedException} in
* case the execution has been requested to stop using
* {@link JobExecution#stop()} or executing thread has been interrupted.
*
* @author Robert Kasanicky
*/
public class DefaultJobInterruptionAdvice implements JobInterruptionAdvice {
private static final Log logger = LogFactory.getLog(DefaultJobInterruptionAdvice.class);
private JobExecution jobExecution;
/*
* (non-Javadoc)
* @see org.springframework.batch.core.runtime.JobInterruptionAdvice#checkInterrupt()
*/
public void checkInterrupt() throws JobInterruptedException {
logger.info("checking job execution for interrupt");
if (Thread.currentThread().isInterrupted() || jobExecution.getStatus() == BatchStatus.STOPPING) {
throw new JobInterruptedException("Job execution interrupted by user");
}
}
/**
* Setter for JobExecution - to be applied as 'after returning' advice that
* captures return value on the method that creates {@link JobExecution} for
* the job run.
*/
public void setJobExecution(JobExecution jobExecution) {
this.jobExecution = jobExecution;
logger.info("JobExecution set");
}
}

View File

@@ -1,25 +0,0 @@
package org.springframework.batch.sample.advice;
import org.springframework.batch.core.JobInterruptedException;
/**
* Interface for monitors that check whether a job was interrupted by user.
*
* Interruption checking is a cross-cutting concern, therefore favorably handled
* by AOP. The implementation if expected to be used as 'before advice' or
* 'after advice' or both.
*
* @see DefaultJobInterruptionAdvice
*
* @author Robert Kasanicky
*/
public interface JobInterruptionAdvice {
/**
* No-op unless job was interrupted by user.
*
* @throws JobInterruptedException if job was interrupted
*/
void checkInterrupt() throws JobInterruptedException;
}