BATCH-263:XML and FlatFile item readers will no longer throw IllegalStateException on afterPropertiesSet if resource.exists() == false. Instead, they will check that a resource exists when initialized by the first call to read().

This commit is contained in:
lucasward
2008-01-03 20:31:15 +00:00
parent bb5de7a2b9
commit e8c2539656
4 changed files with 174 additions and 82 deletions

View File

@@ -123,8 +123,6 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item
public void afterPropertiesSet() throws Exception {
Assert.notNull(resource);
Assert.state(resource.exists(), "Resource must exist: [" + resource
+ "]");
Assert.notNull(fieldSetMapper, "FieldSetMapper must not be null.");
}
@@ -133,6 +131,10 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item
* @throws IllegalStateException if the resource cannot be opened
*/
public void open() throws IllegalStateException {
Assert.state(resource.exists(), "Resource must exist: [" + resource
+ "]");
if (this.reader == null) {
ResourceLineReader reader = new ResourceLineReader(resource, encoding);
if (recordSeparatorPolicy != null) {

View File

@@ -118,6 +118,8 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade
}
public void open() {
Assert.state(resource.exists(), "Input resource does not exist: [" + resource + "]");
registerSynchronization();
try {
inputStream = resource.getInputStream();
@@ -184,7 +186,6 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade
*/
public void afterPropertiesSet() throws Exception {
Assert.notNull(resource, "The Resource must not be null.");
Assert.state(resource.exists(), "Input resource does not exist: [" + resource + "]");
Assert.notNull(eventReaderDeserializer, "The FragmentDeserializer must not be null.");
Assert.hasLength(fragmentRootElementName, "The FragmentRootElementName must not be null");
}