Tidy up some exception class names
This commit is contained in:
@@ -17,7 +17,7 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
|
||||
/**
|
||||
* Batch domain object representing a job. Job is an explicit abstraction
|
||||
@@ -43,8 +43,8 @@ public interface Job {
|
||||
* and statistics as necessary.
|
||||
*
|
||||
* @param execution a {@link JobExecution}
|
||||
* @throws BatchCriticalException
|
||||
* @throws InfrastructureException
|
||||
*/
|
||||
void execute(JobExecution execution) throws BatchCriticalException;
|
||||
void execute(JobExecution execution) throws InfrastructureException;
|
||||
|
||||
}
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* in a runtime exception (usually {@link InfrastructureException} before
|
||||
* reaching the client.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
|
||||
/**
|
||||
* Batch domain interface representing the configuration of a step. As with the
|
||||
@@ -57,9 +57,9 @@ public interface Step {
|
||||
* @param stepExecution an entity representing the step to be executed
|
||||
*
|
||||
* @throws JobInterruptedException if the step is interrupted externally
|
||||
* @throws BatchCriticalException if there is a problem that needs to be
|
||||
* @throws InfrastructureException if there is a problem that needs to be
|
||||
* signalled to the caller
|
||||
*/
|
||||
void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException;
|
||||
void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException;
|
||||
|
||||
}
|
||||
@@ -61,10 +61,12 @@ public interface JobRepository {
|
||||
* @throws JobExecutionAlreadyRunningException if there is a
|
||||
* {@link JobExecution} alrady running for the job instance that would
|
||||
* otherwise be returned
|
||||
* @throws JobRestartException if more than one JobInstance if found or if
|
||||
* JobInstance.getJobExecutionCount() is greater than Job.getStartLimit()
|
||||
*
|
||||
*/
|
||||
public JobExecution createJobExecution(Job job, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException;
|
||||
throws JobExecutionAlreadyRunningException, JobRestartException;
|
||||
|
||||
/**
|
||||
* Save or Update a {@link JobExecution}. If no ID is found a new instance
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
|
||||
/**
|
||||
* An exception indicating an illegal attempt to restart a job.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BatchRestartException extends BatchCriticalException {
|
||||
public class JobRestartException extends JobException {
|
||||
|
||||
/**
|
||||
* @param string the message
|
||||
*/
|
||||
public BatchRestartException(String string) {
|
||||
public JobRestartException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BatchRestartException extends BatchCriticalException {
|
||||
* @param msg the cause
|
||||
* @param t the message
|
||||
*/
|
||||
public BatchRestartException(String msg, Throwable t) {
|
||||
public JobRestartException(String msg, Throwable t) {
|
||||
super(msg, t);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public void execute(JobExecution execution) throws BatchCriticalException {
|
||||
public void execute(JobExecution execution) throws InfrastructureException {
|
||||
throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.core.domain;
|
||||
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.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,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 JobInterruptedException, BatchCriticalException {
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ import org.springframework.batch.core.AbstractExceptionTests;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class BatchRestartExceptionTests extends AbstractExceptionTests {
|
||||
public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new BatchRestartException(msg);
|
||||
return new JobRestartException(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -37,7 +37,7 @@ public class BatchRestartExceptionTests extends AbstractExceptionTests {
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new BatchRestartException(msg, t);
|
||||
return new JobRestartException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
@@ -161,6 +162,9 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ
|
||||
catch (JobExecutionAlreadyRunningException e) {
|
||||
return e.getClass().getName() + ": " + e.getMessage();
|
||||
}
|
||||
catch (JobRestartException e) {
|
||||
return e.getClass().getName() + ": " + e.getMessage();
|
||||
}
|
||||
|
||||
registry.put(name + params, execution);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.execution.listener.CompositeJobListener;
|
||||
import org.springframework.batch.execution.step.support.SimpleExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class SimpleJob extends AbstractJob {
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.Job#execute(org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public void execute(JobExecution execution) throws BatchCriticalException {
|
||||
public void execute(JobExecution execution) throws InfrastructureException {
|
||||
|
||||
JobInstance jobInstance = execution.getJobInstance();
|
||||
jobInstance.setLastExecution(execution);
|
||||
@@ -158,7 +158,7 @@ public class SimpleJob extends AbstractJob {
|
||||
}
|
||||
|
||||
if (stepStatus == BatchStatus.UNKNOWN) {
|
||||
throw new BatchCriticalException("Cannot restart step from UNKNOWN status. "
|
||||
throw new InfrastructureException("Cannot restart step from UNKNOWN status. "
|
||||
+ "The last execution ended with a failure that could not be rolled back, "
|
||||
+ "so it may be dangerous to proceed. " + "Manual intervention is probably necessary.");
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class SimpleJob extends AbstractJob {
|
||||
}
|
||||
else {
|
||||
// start max has been exceeded, throw an exception.
|
||||
throw new BatchCriticalException("Maximum start limit exceeded for step: " + step.getName() + "StartMax: "
|
||||
throw new InfrastructureException("Maximum start limit exceeded for step: " + step.getName() + "StartMax: "
|
||||
+ step.getStartLimit());
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class SimpleJob extends AbstractJob {
|
||||
throw (RuntimeException) t;
|
||||
}
|
||||
else {
|
||||
throw new BatchCriticalException(t);
|
||||
throw new InfrastructureException(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,16 @@ package org.springframework.batch.execution.launch;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
|
||||
/**
|
||||
* Simple interface for controlling jobs, including possible ad-hoc executions,
|
||||
* based on different runtime identifiers. It is extremely important to note
|
||||
* that this interface makes absolutely no guarantees about whether or not
|
||||
* calls to it are executed synchronously or asynchronously. The javadocs
|
||||
* for specific implementations should be checked to ensure callers fully
|
||||
* understand how the job will be run.
|
||||
* based on different runtime identifiers. It is extremely important to note
|
||||
* that this interface makes absolutely no guarantees about whether or not calls
|
||||
* to it are executed synchronously or asynchronously. The javadocs for specific
|
||||
* implementations should be checked to ensure callers fully understand how the
|
||||
* job will be run.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
@@ -38,13 +39,16 @@ public interface JobLauncher {
|
||||
* Start a job execution for the given {@link Job} and {@link JobParameters}.
|
||||
*
|
||||
* @return the exit code from the job if it returns synchronously. If the
|
||||
* implementation is asynchronous, the status might well be unknown.
|
||||
* implementation is asynchronous, the status might well be unknown.
|
||||
*
|
||||
* @throws JobExecutionAlreadyRunningException if the JobInstance identified
|
||||
* by the properties already has an execution running. Throws
|
||||
* IllegalArgumentException if the job or jobInstanceProperties are null.
|
||||
* by the properties already has an execution running.
|
||||
* @throws IllegalArgumentException if the job or jobInstanceProperties are
|
||||
* null.
|
||||
* @throws JobRestartException if the job has been run before and
|
||||
* circumstances that preclude a re-start.
|
||||
*/
|
||||
public JobExecution run(Job job, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException;
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
|
||||
JobRestartException;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.batch.core.domain.Job;
|
||||
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.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -30,8 +31,8 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Simple implementation of the {@link JobLauncher} interface. The Spring Core
|
||||
* {@link TaskExecutor} interface is used to launch a {@link Job}. This
|
||||
* means that the type of executor set is very important. If a
|
||||
* {@link TaskExecutor} interface is used to launch a {@link Job}. This means
|
||||
* that the type of executor set is very important. If a
|
||||
* {@link SyncTaskExecutor} is used, then the job will be processed
|
||||
* <strong>within the same thread that called the launcher.</strong> Care
|
||||
* should be taken to ensure any users of this class understand fully whether or
|
||||
@@ -40,9 +41,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* There is only one required dependency of this Launcher, a
|
||||
* {@link JobRepository}. The JobRepository is used to obtain a valid
|
||||
* JobExecution. The Repository must be used because the provided
|
||||
* {@link Job} could be a restart of an existing {@link JobInstance},
|
||||
* and only the Repository can reliably recreate it.
|
||||
* JobExecution. The Repository must be used because the provided {@link Job}
|
||||
* could be a restart of an existing {@link JobInstance}, and only the
|
||||
* Repository can reliably recreate it.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @since 1.0
|
||||
@@ -67,9 +68,11 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
|
||||
* execution.
|
||||
* @return JobExecutionAlreadyRunningException if the JobInstance already
|
||||
* exists and has an execution already running.
|
||||
* @throws JobRestartException if the execution would be a re-start, but a
|
||||
* re-start is either not allowed or not needed.
|
||||
*/
|
||||
public JobExecution run(final Job job, final JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException {
|
||||
throws JobExecutionAlreadyRunningException, JobRestartException {
|
||||
|
||||
Assert.notNull(job, "The Job must not be null.");
|
||||
Assert.notNull(jobParameters, "The JobParameters must not be null.");
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.repository.BatchRestartException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.JobExecutionDao;
|
||||
@@ -132,15 +132,9 @@ public class SimpleJobRepository implements JobRepository {
|
||||
*
|
||||
* @see JobRepository#createJobExecution(Job, JobParameters)
|
||||
*
|
||||
* @throws BatchRestartException if more than one JobInstance if found or if
|
||||
* JobInstance.getJobExecutionCount() is greater than Job.getStartLimit()
|
||||
* @throws JobExecutionAlreadyRunningException if a job execution is found
|
||||
* for the given {@link JobIdentifier} that is already running
|
||||
* @throws CannotRestartJobInstanceException
|
||||
*
|
||||
*/
|
||||
public JobExecution createJobExecution(Job job, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException {
|
||||
throws JobExecutionAlreadyRunningException, JobRestartException {
|
||||
|
||||
Assert.notNull(job, "Job must not be null.");
|
||||
Assert.notNull(jobParameters, "JobParameters must not be null.");
|
||||
@@ -161,12 +155,12 @@ public class SimpleJobRepository implements JobRepository {
|
||||
// existing job instance found
|
||||
if (jobInstance != null) {
|
||||
if (!job.isRestartable()) {
|
||||
throw new BatchRestartException("JobInstance already exists and is not restartable");
|
||||
throw new JobRestartException("JobInstance already exists and is not restartable");
|
||||
}
|
||||
|
||||
jobInstance.setJobExecutionCount(jobExecutionDao.getJobExecutionCount(jobInstance));
|
||||
if (jobInstance.getJobExecutionCount() > job.getStartLimit()) {
|
||||
throw new BatchRestartException("Restart Max exceeded for Job: " + jobInstance.toString());
|
||||
throw new JobRestartException("Restart Max exceeded for Job: " + jobInstance.toString());
|
||||
}
|
||||
List executions = jobExecutionDao.findJobExecutions(jobInstance);
|
||||
JobExecution lastExecution = null;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.domain.BatchStatus;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
@@ -147,7 +146,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
// is invalid and
|
||||
// an exception should be thrown.
|
||||
if (getJdbcTemplate().queryForInt(getQuery(CHECK_JOB_EXECUTION_EXISTS), new Object[] { jobExecution.getId() }) != 1) {
|
||||
throw new NoSuchBatchDomainObjectException("Invalid JobExecution, ID " + jobExecution.getId()
|
||||
throw new NoSuchObjectException("Invalid JobExecution, ID " + jobExecution.getId()
|
||||
+ " not found.");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.batch.core.domain.BatchStatus;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
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.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -108,7 +108,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
executionContext.put(key, rs.getObject("OBJECT_VAL"));
|
||||
}
|
||||
else {
|
||||
throw new BatchCriticalException("Invalid type found: [" + typeCd + "] for execution id: ["
|
||||
throw new InfrastructureException("Invalid type found: [" + typeCd + "] for execution id: ["
|
||||
+ executionId + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.repository;
|
||||
package org.springframework.batch.execution.repository.dao;
|
||||
|
||||
/**
|
||||
* This exception identifies that a batch domain object is invalid, which
|
||||
@@ -24,11 +24,11 @@ package org.springframework.batch.core.repository;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class NoSuchBatchDomainObjectException extends RuntimeException {
|
||||
public class NoSuchObjectException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 4399621765157283111L;
|
||||
|
||||
public NoSuchBatchDomainObjectException(String message){
|
||||
public NoSuchObjectException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.execution.step.support.NeverSkipItemSkipPolicy;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.exception.handler.ExceptionHandler;
|
||||
@@ -195,5 +195,5 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
|
||||
}
|
||||
|
||||
public abstract void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException;
|
||||
public abstract void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import org.springframework.batch.execution.step.support.SimpleExitStatusExceptio
|
||||
import org.springframework.batch.execution.step.support.StepInterruptionPolicy;
|
||||
import org.springframework.batch.execution.step.support.ThreadStepInterruptionPolicy;
|
||||
import org.springframework.batch.io.Skippable;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemRecoverer;
|
||||
@@ -227,7 +227,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean {
|
||||
* execution
|
||||
* @see StepExecutor#execute(StepExecution)
|
||||
*/
|
||||
public void execute(final StepExecution stepExecution) throws BatchCriticalException, JobInterruptedException {
|
||||
public void execute(final StepExecution stepExecution) throws InfrastructureException, JobInterruptedException {
|
||||
|
||||
JobInstance jobInstance = stepExecution.getJobExecution().getJobInstance();
|
||||
StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, this);
|
||||
@@ -418,7 +418,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean {
|
||||
if (!fatalException.hasException()) {
|
||||
fatalException.setException(e);
|
||||
}
|
||||
throw new BatchCriticalException(msg, fatalException.getException());
|
||||
throw new InfrastructureException(msg, fatalException.getException());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -431,11 +431,11 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean {
|
||||
if (!fatalException.hasException()) {
|
||||
fatalException.setException(e);
|
||||
}
|
||||
throw new BatchCriticalException(msg, fatalException.getException());
|
||||
throw new InfrastructureException(msg, fatalException.getException());
|
||||
}
|
||||
|
||||
if (fatalException.hasException()) {
|
||||
throw new BatchCriticalException("Encountered an error saving batch meta data.", fatalException
|
||||
throw new InfrastructureException("Encountered an error saving batch meta data.", fatalException
|
||||
.getException());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.batch.core.domain.StepListener;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.listener.CompositeStepListener;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -191,7 +191,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware {
|
||||
this.jobRepository = jobRepository;
|
||||
}
|
||||
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException {
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
|
||||
stepExecution.setStartTime(new Date());
|
||||
updateStatus(stepExecution, BatchStatus.STARTED);
|
||||
|
||||
@@ -230,7 +230,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
throw new BatchCriticalException(e);
|
||||
throw new InfrastructureException(e);
|
||||
}
|
||||
finally {
|
||||
stepExecution.setExitStatus(exitStatus);
|
||||
@@ -244,7 +244,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware {
|
||||
if (fatalException != null) {
|
||||
logger.error("Encountered an error saving batch meta data."
|
||||
+ "This job is now in an unknown state and should not be restarted.", fatalException);
|
||||
throw new BatchCriticalException("Encountered an error saving batch meta data.", fatalException);
|
||||
throw new InfrastructureException("Encountered an error saving batch meta data.", fatalException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.execution.step.support;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
|
||||
/**
|
||||
* Exception indicating that the skip limit for a particular {@Step} has
|
||||
@@ -24,7 +24,7 @@ import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
* @author Ben Hale
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class SkipLimitExceededException extends BatchCriticalException {
|
||||
public class SkipLimitExceededException extends InfrastructureException {
|
||||
|
||||
private final int skipLimit;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public void execute(JobExecution execution) throws BatchCriticalException {
|
||||
public void execute(JobExecution execution) throws InfrastructureException {
|
||||
throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.batch.execution.repository.dao.MapJobInstanceDao;
|
||||
import org.springframework.batch.execution.repository.dao.MapStepExecutionDao;
|
||||
import org.springframework.batch.execution.repository.dao.StepExecutionDao;
|
||||
import org.springframework.batch.execution.step.AbstractStep;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.reader.AbstractItemReader;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -193,7 +193,7 @@ public class SimpleJobTests extends TestCase {
|
||||
try {
|
||||
job.execute(jobExecution);
|
||||
}
|
||||
catch (BatchCriticalException e) {
|
||||
catch (InfrastructureException e) {
|
||||
assertEquals(exception, e.getCause());
|
||||
}
|
||||
assertEquals(0, list.size());
|
||||
@@ -223,7 +223,7 @@ public class SimpleJobTests extends TestCase {
|
||||
job.execute(jobExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (BatchCriticalException ex) {
|
||||
catch (InfrastructureException ex) {
|
||||
// expected
|
||||
assertTrue("Wrong message in exception: " + ex.getMessage(), ex.getMessage()
|
||||
.indexOf("start limit exceeded") >= 0);
|
||||
@@ -255,7 +255,7 @@ public class SimpleJobTests extends TestCase {
|
||||
try {
|
||||
job.execute(jobExecution);
|
||||
}
|
||||
catch (BatchCriticalException e) {
|
||||
catch (InfrastructureException e) {
|
||||
assertTrue(e.getCause() instanceof JobInterruptedException);
|
||||
}
|
||||
assertEquals(0, list.size());
|
||||
@@ -310,7 +310,7 @@ public class SimpleJobTests extends TestCase {
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException {
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException)exception;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.repository.BatchRestartException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.execution.job.JobSupport;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -108,7 +108,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
|
||||
jobRepository.createJobExecution(job, jobParameters);
|
||||
fail();
|
||||
}
|
||||
catch (BatchRestartException e) {
|
||||
catch (JobRestartException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.JobParametersBuilder;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.repository.BatchRestartException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.execution.job.JobSupport;
|
||||
import org.springframework.batch.execution.repository.dao.JobExecutionDao;
|
||||
import org.springframework.batch.execution.repository.dao.JobInstanceDao;
|
||||
@@ -243,7 +243,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
jobRepository.createJobExecution(jobConfiguration, jobParameters);
|
||||
fail();
|
||||
}
|
||||
catch (BatchRestartException ex) {
|
||||
catch (JobRestartException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ 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.JobParametersBuilder;
|
||||
import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException;
|
||||
import org.springframework.batch.execution.job.JobSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
@@ -174,7 +173,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc
|
||||
jobExecutionDao.updateJobExecution(execution);
|
||||
fail("Expected NoSuchBatchDomainObjectException");
|
||||
}
|
||||
catch (NoSuchBatchDomainObjectException ex) {
|
||||
catch (NoSuchObjectException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
package org.springframework.batch.execution.repository.dao;
|
||||
|
||||
import org.springframework.batch.execution.repository.dao.NoSuchObjectException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -24,7 +26,7 @@ import junit.framework.TestCase;
|
||||
public class NoSuchBatchDomainObjectExceptionTests extends TestCase {
|
||||
|
||||
public void testCreateException() throws Exception {
|
||||
NoSuchBatchDomainObjectException e = new NoSuchBatchDomainObjectException("Foo");
|
||||
NoSuchObjectException e = new NoSuchObjectException("Foo");
|
||||
assertEquals("Foo", e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import org.springframework.batch.execution.repository.dao.MapJobInstanceDao;
|
||||
import org.springframework.batch.execution.repository.dao.MapStepExecutionDao;
|
||||
import org.springframework.batch.execution.step.support.JobRepositorySupport;
|
||||
import org.springframework.batch.execution.step.support.StepInterruptionPolicy;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
@@ -255,7 +255,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (BatchCriticalException e) {
|
||||
catch (InfrastructureException e) {
|
||||
assertEquals("foo", e.getCause().getMessage());
|
||||
}
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
@@ -548,7 +548,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (BatchCriticalException ex) {
|
||||
catch (InfrastructureException ex) {
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertTrue("Message does not contain ResetFailedException: " + msg, msg.contains("ResetFailedException"));
|
||||
@@ -576,7 +576,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (BatchCriticalException ex) {
|
||||
catch (InfrastructureException ex) {
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertEquals("", msg);
|
||||
@@ -637,7 +637,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
}
|
||||
catch (BatchCriticalException ex) {
|
||||
catch (InfrastructureException ex) {
|
||||
// The job actually completeed, but teh streams couldn't be closed.
|
||||
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
|
||||
@@ -18,7 +18,7 @@ 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.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,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 JobInterruptedException, BatchCriticalException {
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.batch.core.listener.StepListenerSupport;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.job.JobSupport;
|
||||
import org.springframework.batch.execution.step.support.JobRepositorySupport;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
public class TaskletStepTests extends TestCase {
|
||||
@@ -89,7 +89,7 @@ public class TaskletStepTests extends TestCase {
|
||||
try {
|
||||
step.execute(stepExecution);
|
||||
fail("Expected BatchCriticalException");
|
||||
} catch (BatchCriticalException e){
|
||||
} catch (InfrastructureException e){
|
||||
assertEquals("foo", e.getCause().getMessage());
|
||||
}
|
||||
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
|
||||
@@ -118,7 +118,7 @@ public class TaskletStepTests extends TestCase {
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
public void testExceptionExecution() throws JobInterruptedException, BatchCriticalException {
|
||||
public void testExceptionExecution() throws JobInterruptedException, InfrastructureException {
|
||||
TaskletStep step = new TaskletStep(new StubTasklet(false, true), new JobRepositorySupport());
|
||||
try {
|
||||
step.execute(stepExecution);
|
||||
|
||||
@@ -1,50 +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.io.exception;
|
||||
|
||||
/**
|
||||
* Exception that should be thrown to indicate an error in the environment.
|
||||
* Excamples of such errors include file or database access errors. Because this
|
||||
* class extends BatchCriticalException, throwing this error will indicate to
|
||||
* the framework that processing should stop. It is vital that an error-code be
|
||||
* passed as well, since this will be returned from the main method of the
|
||||
* launcher.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class BatchEnvironmentException extends BatchCriticalException {
|
||||
private static final long serialVersionUID = 1382420837776529019L;
|
||||
|
||||
/**
|
||||
* Refer to the similar constructor in the parent class
|
||||
* {@link BatchCriticalException}.
|
||||
*
|
||||
*/
|
||||
public BatchEnvironmentException(String msg, Throwable nested) {
|
||||
super(msg, nested);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refer to the similar constructor in the parent class
|
||||
* {@link BatchCriticalException}.
|
||||
*
|
||||
*/
|
||||
public BatchEnvironmentException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,28 +22,28 @@ package org.springframework.batch.io.exception;
|
||||
*
|
||||
* @author Kerry O'Brien
|
||||
*/
|
||||
public class BatchConfigurationException extends BatchCriticalException {
|
||||
public class ConfigurationException extends InfrastructureException {
|
||||
private static final long serialVersionUID = 759498454063502984L;
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @param ex
|
||||
*/
|
||||
public BatchConfigurationException(String msg, Throwable ex) {
|
||||
public ConfigurationException(String msg, Throwable ex) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
*/
|
||||
public BatchConfigurationException(String msg) {
|
||||
public ConfigurationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nested
|
||||
*/
|
||||
public BatchConfigurationException(Throwable nested) {
|
||||
public ConfigurationException(Throwable nested) {
|
||||
super(nested);
|
||||
}
|
||||
}
|
||||
@@ -17,20 +17,13 @@
|
||||
package org.springframework.batch.io.exception;
|
||||
|
||||
/**
|
||||
* BatchCritcalException - Indiates to the framework that a critical error has
|
||||
* occured and batch processing should immeadiately stop. However, in most cases
|
||||
* status should still be persisted indicating that an error foced the job to
|
||||
* terminate. Any framework code that catches a BatchCriticalException will
|
||||
* rethrow the exception. This allows any code that creates a critical exception
|
||||
* to be able to add an error code that will still be accesible at the very
|
||||
* beginning of the call chain. (usually a launcher that kicked off the
|
||||
* JobController). Error code values 0 - 2000 a reserved for framework classes.
|
||||
* Anything greater than 2000 can be used by application code.
|
||||
* Indicates to the framework that a critical error has occurred and processing
|
||||
* should immediately stop.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class BatchCriticalException extends RuntimeException {
|
||||
public class InfrastructureException extends RuntimeException {
|
||||
private static final long serialVersionUID = 8838982304219248527L;
|
||||
|
||||
/**
|
||||
@@ -39,7 +32,7 @@ public class BatchCriticalException extends RuntimeException {
|
||||
* @param msg the exception message.
|
||||
*
|
||||
*/
|
||||
public BatchCriticalException(String msg) {
|
||||
public InfrastructureException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@@ -49,7 +42,7 @@ public class BatchCriticalException extends RuntimeException {
|
||||
* @param msg the exception message.
|
||||
*
|
||||
*/
|
||||
public BatchCriticalException(String msg, Throwable nested) {
|
||||
public InfrastructureException(String msg, Throwable nested) {
|
||||
super(msg, nested);
|
||||
}
|
||||
|
||||
@@ -57,7 +50,7 @@ public class BatchCriticalException extends RuntimeException {
|
||||
* Constructs a new instance with a nested exception. The error code is
|
||||
* defaulted to 1 and the message is empty.
|
||||
*/
|
||||
public BatchCriticalException(Throwable nested) {
|
||||
public InfrastructureException(Throwable nested) {
|
||||
super(nested);
|
||||
}
|
||||
|
||||
@@ -65,7 +58,7 @@ public class BatchCriticalException extends RuntimeException {
|
||||
* Constructs a new instance, the error code is defaulted to one and the
|
||||
* message is empty.
|
||||
*/
|
||||
public BatchCriticalException() {
|
||||
public InfrastructureException() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.batch.item.ItemReader;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class ReadFailureException extends BatchCriticalException {
|
||||
public class ReadFailureException extends InfrastructureException {
|
||||
|
||||
private static final long serialVersionUID = 4113323182216735223L;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class WriteFailureException extends BatchCriticalException {
|
||||
public class WriteFailureException extends InfrastructureException {
|
||||
private static final long serialVersionUID = -1933213086873834098L;
|
||||
|
||||
private final Object item;
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.BatchEnvironmentException;
|
||||
import org.springframework.batch.io.exception.ConfigurationException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.io.file.mapping.FieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetCreator;
|
||||
import org.springframework.batch.io.file.transform.DelimitedLineAggregator;
|
||||
@@ -258,7 +258,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
pos = fileChannel.position();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchCriticalException("An Error occured while trying to get filechannel position", e);
|
||||
throw new InfrastructureException("An Error occured while trying to get filechannel position", e);
|
||||
}
|
||||
|
||||
return pos;
|
||||
@@ -308,7 +308,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
fileChannel.close();
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
throw new BatchEnvironmentException("Unable to close the the ItemWriter", ioe);
|
||||
throw new StreamException("Unable to close the the ItemWriter", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
linesWritten++;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchCriticalException("An Error occured while trying to write to FlatFileItemWriter", e);
|
||||
throw new InfrastructureException("An Error occured while trying to write to FlatFileItemWriter", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
fileChannel.position(lastMarkedByteOffsetPosition);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchCriticalException("An Error occured while truncating output file", e);
|
||||
throw new InfrastructureException("An Error occured while truncating output file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
file.delete();
|
||||
}
|
||||
else {
|
||||
throw new BatchEnvironmentException("Resource already exists: " + resource);
|
||||
throw new StreamException("Resource already exists: " + resource);
|
||||
}
|
||||
}
|
||||
String parent = file.getParent();
|
||||
@@ -395,7 +395,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
fileChannel = (new FileOutputStream(file.getAbsolutePath(), true)).getChannel();
|
||||
}
|
||||
catch (FileNotFoundException fnfe) {
|
||||
throw new BatchEnvironmentException("Bad filename property parameter " + file, fnfe);
|
||||
throw new ConfigurationException("Bad filename property parameter " + file, fnfe);
|
||||
}
|
||||
|
||||
outputBufferedWriter = getBufferedWriter(fileChannel, encoding, bufferSize);
|
||||
@@ -429,7 +429,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
return outputBufferedWriter;
|
||||
}
|
||||
catch (UnsupportedCharsetException ucse) {
|
||||
throw new BatchEnvironmentException("Bad encoding configuration for output file " + fileChannel, ucse);
|
||||
throw new StreamException("Bad encoding configuration for output file " + fileChannel, ucse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
* truncates the file to that reset position, and set the cursor to
|
||||
* start writing at that point.
|
||||
*/
|
||||
public void reset() throws BatchCriticalException {
|
||||
public void reset() throws InfrastructureException {
|
||||
checkFileSize();
|
||||
getOutputState().truncate();
|
||||
}
|
||||
@@ -460,11 +460,11 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
size = fileChannel.size();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchCriticalException("An Error occured while checking file size", e);
|
||||
throw new InfrastructureException("An Error occured while checking file size", e);
|
||||
}
|
||||
|
||||
if (size < lastMarkedByteOffsetPosition) {
|
||||
throw new BatchCriticalException("Current file size is smaller than size at last commit");
|
||||
throw new InfrastructureException("Current file size is smaller than size at last commit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ public class FlatFileItemWriter implements ItemWriter, ItemStream,
|
||||
try {
|
||||
getOutputState().reset();
|
||||
}
|
||||
catch (BatchCriticalException e) {
|
||||
catch (InfrastructureException e) {
|
||||
throw new ResetFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchEnvironmentException;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.exception.MarkFailedException;
|
||||
import org.springframework.batch.item.exception.ResetFailedException;
|
||||
import org.springframework.batch.item.exception.StreamException;
|
||||
import org.springframework.batch.item.stream.ItemStreamSupport;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -120,9 +120,6 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
*
|
||||
* @return a String.
|
||||
*
|
||||
* @throws BatchEnvironmentException if there is an IOException while
|
||||
* accessing the input resource.
|
||||
*
|
||||
* @see org.springframework.batch.item.reader.support.ItemReader#read()
|
||||
*/
|
||||
public synchronized Object read() {
|
||||
@@ -170,9 +167,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
/**
|
||||
* Close the reader associated with this input source.
|
||||
*
|
||||
* @see org.springframework.batch.io.ItemReader#close(ExecutionContext)
|
||||
* @throws BatchEnvironmentException if there is an {@link IOException}
|
||||
* during the close operation.
|
||||
* @see org.springframework.batch.item.stream.ItemStreamSupport#close(org.springframework.batch.item.ExecutionContext)
|
||||
*/
|
||||
public synchronized void close(ExecutionContext executionContext) {
|
||||
if (state == null) {
|
||||
@@ -260,7 +255,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchEnvironmentException("Unable to read from resource '" + resource + "' at line "
|
||||
throw new StreamException("Unable to read from resource '" + resource + "' at line "
|
||||
+ currentLineCount, e);
|
||||
}
|
||||
return line;
|
||||
@@ -275,7 +270,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
mark();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchEnvironmentException("Could not open resource", e);
|
||||
throw new StreamException("Could not open resource", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +286,7 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
reader.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BatchEnvironmentException("Could not close reader", e);
|
||||
throw new StreamException("Could not close reader", e);
|
||||
}
|
||||
finally {
|
||||
currentLineCount = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.batch.io.file.transform;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchConfigurationException;
|
||||
import org.springframework.batch.io.exception.ConfigurationException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
|
||||
*/
|
||||
public DelimitedLineTokenizer(char delimiter) {
|
||||
if (delimiter == DEFAULT_QUOTE_CHARACTER) {
|
||||
throw new BatchConfigurationException("'" + DEFAULT_QUOTE_CHARACTER
|
||||
throw new ConfigurationException("'" + DEFAULT_QUOTE_CHARACTER
|
||||
+ "' is not allowed as delimiter for tokenizers.");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.item.exception;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
|
||||
/**
|
||||
* Exception representing any errors encountered while processing
|
||||
@@ -24,7 +24,7 @@ import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
* @author Dave Syer
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class StreamException extends BatchCriticalException {
|
||||
public class StreamException extends InfrastructureException {
|
||||
|
||||
/**
|
||||
* @param message
|
||||
|
||||
@@ -1,36 +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.io.exception;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.BatchEnvironmentException;
|
||||
|
||||
public class BatchEnvironmentExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new BatchEnvironmentException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(Throwable t) throws Exception {
|
||||
return new BatchCriticalException(t);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new BatchEnvironmentException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,20 +16,20 @@
|
||||
|
||||
package org.springframework.batch.io.exception;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchConfigurationException;
|
||||
import org.springframework.batch.io.exception.ConfigurationException;
|
||||
|
||||
public class BatchConfigurationExceptionTests extends AbstractExceptionTests {
|
||||
public class ConfigurationExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new BatchConfigurationException(msg);
|
||||
return new ConfigurationException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(Throwable t) throws Exception {
|
||||
return new BatchConfigurationException(t);
|
||||
return new ConfigurationException(t);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new BatchConfigurationException(msg, t);
|
||||
return new ConfigurationException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,18 +17,18 @@
|
||||
package org.springframework.batch.io.exception;
|
||||
|
||||
|
||||
public class BatchCriticalExceptionTests extends AbstractExceptionTests {
|
||||
public class InfrastructureExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new BatchCriticalException(msg);
|
||||
return new InfrastructureException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(Throwable t) throws Exception {
|
||||
return new BatchCriticalException(t);
|
||||
return new InfrastructureException(t);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new BatchCriticalException(msg, t);
|
||||
return new InfrastructureException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import java.io.InputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchEnvironmentException;
|
||||
import org.springframework.batch.io.exception.FlatFileParsingException;
|
||||
import org.springframework.batch.io.file.mapping.DefaultFieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSet;
|
||||
@@ -211,7 +210,7 @@ public class FlatFileItemReaderBasicTests extends TestCase {
|
||||
itemReader.open(executionContext);
|
||||
fail("Expected BatchEnvironmentException");
|
||||
}
|
||||
catch (BatchEnvironmentException e) {
|
||||
catch (StreamException e) {
|
||||
// expected
|
||||
assertEquals("foo", e.getCause().getMessage());
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.io.InputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchEnvironmentException;
|
||||
import org.springframework.batch.io.file.separator.ResourceLineReader;
|
||||
import org.springframework.batch.io.file.separator.SuffixRecordSeparatorPolicy;
|
||||
import org.springframework.batch.item.exception.StreamException;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -43,7 +43,7 @@ public class ResourceLineReaderTests extends TestCase {
|
||||
reader.read();
|
||||
fail("Expected InputException");
|
||||
}
|
||||
catch (BatchEnvironmentException e) {
|
||||
catch (StreamException e) {
|
||||
// expected
|
||||
assertTrue(e.getMessage().startsWith("Unable to read"));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.sample.item.writer;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.writer.DelegatingItemWriter;
|
||||
import org.springframework.batch.sample.domain.Order;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.sample.domain.Order;
|
||||
public class OrderWriter extends DelegatingItemWriter {
|
||||
public Object doProcess(Object data) {
|
||||
if (!(data instanceof Order)) {
|
||||
throw new BatchCriticalException("OrderProcessor can process only Order objects");
|
||||
throw new InfrastructureException("OrderProcessor can process only Order objects");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.batch.sample.tasklet;
|
||||
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.reader.DelegatingItemReader;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ExceptionThrowingItemReaderProxy extends DelegatingItemReader {
|
||||
|
||||
counter++;
|
||||
if (counter == throwExceptionOnRecordNumber) {
|
||||
throw new BatchCriticalException("Planned failure on count="+counter);
|
||||
throw new InfrastructureException("Planned failure on count="+counter);
|
||||
}
|
||||
|
||||
return super.read();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class RestartFunctionalTests extends AbstractBatchLauncherTests {
|
||||
runJob();
|
||||
fail("First run of the job is expected to fail.");
|
||||
}
|
||||
catch (BatchCriticalException expected) {
|
||||
catch (InfrastructureException expected) {
|
||||
//expected
|
||||
assertTrue("Not planned exception: "+expected.getMessage(), expected.getMessage().toLowerCase().indexOf("planned")>=0);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
jobIds.add(execution.getJobId());
|
||||
}
|
||||
|
||||
private JobExecution doConcurrentStart() throws InterruptedException, JobExecutionAlreadyRunningException {
|
||||
private JobExecution doConcurrentStart() throws Exception {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.springframework.batch.sample.item.writer;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.sample.domain.Order;
|
||||
import org.springframework.batch.sample.item.writer.OrderWriter;
|
||||
@@ -46,7 +46,7 @@ public class OrderWriterTests extends TestCase {
|
||||
try {
|
||||
processor.write(this);
|
||||
fail("Batch critical exception was expected");
|
||||
} catch (BatchCriticalException bce) {
|
||||
} catch (InfrastructureException bce) {
|
||||
assertTrue(true);
|
||||
}
|
||||
writerControl.verify();
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.batch.item.reader.ListItemReader;
|
||||
import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;
|
||||
@@ -40,7 +40,7 @@ public class ExceptionThrowingItemReaderProxyTests extends TestCase {
|
||||
try {
|
||||
itemReader.read();
|
||||
assertTrue(i < ITER_COUNT);
|
||||
} catch (BatchCriticalException bce) {
|
||||
} catch (InfrastructureException bce) {
|
||||
assertEquals(ITER_COUNT,i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class JobSupport implements BeanNameAware, Job {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public void execute(JobExecution execution) throws BatchCriticalException {
|
||||
public void execute(JobExecution execution) throws InfrastructureException {
|
||||
throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.sample.tasklet;
|
||||
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.io.exception.InfrastructureException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,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 JobInterruptedException, BatchCriticalException {
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user