Tidy up some exception class names
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user