From 3b2662a16b5b64a2483fbca897c3eab673043185 Mon Sep 17 00:00:00 2001 From: dsyer Date: Thu, 4 Oct 2007 15:34:32 +0000 Subject: [PATCH] OPEN - issue BATCH-157: *Source does not need to extend ResourceLifecycle http://opensource.atlassian.com/projects/spring/browse/BATCH-157 --- .../main/java/org/springframework/batch/io/InputSource.java | 3 +-- .../batch/io/file/support/ResourceLineReader.java | 5 +++-- .../batch/io/file/support/SimpleFlatFileInputSource.java | 4 ++-- .../batch/io/sql/SingleKeySqlDrivingQueryInputSource.java | 3 ++- .../springframework/batch/io/sql/SqlCursorInputSource.java | 4 +++- .../batch/io/stax/StaxEventReaderInputSource.java | 3 ++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/infrastructure/src/main/java/org/springframework/batch/io/InputSource.java b/infrastructure/src/main/java/org/springframework/batch/io/InputSource.java index 557a32675..61629d998 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/InputSource.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/InputSource.java @@ -16,7 +16,6 @@ package org.springframework.batch.io; -import org.springframework.batch.item.ResourceLifecycle; /** * Basic interface for generic input operations. Class implementing this @@ -27,7 +26,7 @@ import org.springframework.batch.item.ResourceLifecycle; * * @author Dave Syer */ -public interface InputSource extends ResourceLifecycle { +public interface InputSource { /** * Read record from input stream and map it to an object. diff --git a/infrastructure/src/main/java/org/springframework/batch/io/file/support/ResourceLineReader.java b/infrastructure/src/main/java/org/springframework/batch/io/file/support/ResourceLineReader.java index 781f9bdfb..d147bbffc 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/file/support/ResourceLineReader.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/file/support/ResourceLineReader.java @@ -29,6 +29,7 @@ import org.springframework.batch.io.InputSource; import org.springframework.batch.io.exception.BatchEnvironmentException; import org.springframework.batch.io.file.support.separator.DefaultRecordSeparatorPolicy; import org.springframework.batch.io.file.support.separator.RecordSeparatorPolicy; +import org.springframework.batch.item.ResourceLifecycle; import org.springframework.beans.factory.DisposableBean; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -46,13 +47,13 @@ import org.springframework.util.Assert; * prefixes) and they will be ignored. The default is "#", so lines starting * with a pound sign will be ignored.
* - * All the public methods that interact wit hthe underlying resource (open, + * All the public methods that interact with the underlying resource (open, * close, read etc.) are synchronized on this.
* * @author Dave Syer * @author Rob Harrop */ -public class ResourceLineReader implements InputSource, DisposableBean { +public class ResourceLineReader implements ResourceLifecycle, InputSource, DisposableBean { private static final Collection DEFAULT_COMMENTS = Collections.singleton("#"); diff --git a/infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileInputSource.java b/infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileInputSource.java index b2d209186..19bef828a 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileInputSource.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileInputSource.java @@ -40,14 +40,14 @@ import org.springframework.util.Assert; * * A {@link SimpleFlatFileInputSource} is not thread safe because it maintains * state in the form of a {@link ResourceLineReader}. Be careful to configure a - * {@link SimpleFlatFileInputSource} using an appropiate factory or scope so + * {@link SimpleFlatFileInputSource} using an appropriate factory or scope so * that it is not shared between threads.
* * @see FieldSetInputSource * * @author Dave Syer */ -public class SimpleFlatFileInputSource implements FieldSetInputSource, InitializingBean, DisposableBean { +public class SimpleFlatFileInputSource implements ResourceLifecycle, FieldSetInputSource, InitializingBean, DisposableBean { // default encoding for input files - set to ISO-8859-1 public static final String DEFAULT_CHARSET = "ISO-8859-1"; diff --git a/infrastructure/src/main/java/org/springframework/batch/io/sql/SingleKeySqlDrivingQueryInputSource.java b/infrastructure/src/main/java/org/springframework/batch/io/sql/SingleKeySqlDrivingQueryInputSource.java index 9b9b1ac7e..d188b1435 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/sql/SingleKeySqlDrivingQueryInputSource.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/sql/SingleKeySqlDrivingQueryInputSource.java @@ -24,6 +24,7 @@ import java.util.Properties; import javax.sql.DataSource; import org.springframework.batch.io.InputSource; +import org.springframework.batch.item.ResourceLifecycle; import org.springframework.batch.restart.GenericRestartData; import org.springframework.batch.restart.RestartData; import org.springframework.batch.restart.Restartable; @@ -50,7 +51,7 @@ import org.springframework.util.Assert; * @author Lucas Ward * */ -public class SingleKeySqlDrivingQueryInputSource implements InputSource, Restartable { +public class SingleKeySqlDrivingQueryInputSource implements ResourceLifecycle, InputSource, Restartable { private static final String RESTART_KEY = "SingleKeySqlDrivingQueryInputSource.lastProcessedKey"; diff --git a/infrastructure/src/main/java/org/springframework/batch/io/sql/SqlCursorInputSource.java b/infrastructure/src/main/java/org/springframework/batch/io/sql/SqlCursorInputSource.java index adc37e2e6..949423571 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/sql/SqlCursorInputSource.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/sql/SqlCursorInputSource.java @@ -31,6 +31,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.io.InputSource; import org.springframework.batch.io.Skippable; +import org.springframework.batch.item.ResourceLifecycle; import org.springframework.batch.repeat.synch.BatchTransactionSynchronizationManager; import org.springframework.batch.restart.GenericRestartData; import org.springframework.batch.restart.RestartData; @@ -38,6 +39,7 @@ import org.springframework.batch.restart.Restartable; import org.springframework.batch.statistics.StatisticsProvider; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; +import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.jdbc.SQLWarningException; import org.springframework.jdbc.core.RowMapper; @@ -115,7 +117,7 @@ import org.springframework.util.Assert; * @author Lucas Ward * @author Peter Zozom */ -public class SqlCursorInputSource implements InputSource, DisposableBean, +public class SqlCursorInputSource implements InputSource, ResourceLifecycle, DisposableBean, InitializingBean, Restartable, StatisticsProvider, Skippable { private static Log log = LogFactory.getLog(SqlCursorInputSource.class); diff --git a/infrastructure/src/main/java/org/springframework/batch/io/stax/StaxEventReaderInputSource.java b/infrastructure/src/main/java/org/springframework/batch/io/stax/StaxEventReaderInputSource.java index 6e00e46d2..2d36c662b 100644 --- a/infrastructure/src/main/java/org/springframework/batch/io/stax/StaxEventReaderInputSource.java +++ b/infrastructure/src/main/java/org/springframework/batch/io/stax/StaxEventReaderInputSource.java @@ -14,6 +14,7 @@ import javax.xml.stream.events.StartElement; import org.springframework.batch.io.InputSource; import org.springframework.batch.io.Skippable; +import org.springframework.batch.item.ResourceLifecycle; import org.springframework.batch.repeat.synch.BatchTransactionSynchronizationManager; import org.springframework.batch.restart.GenericRestartData; import org.springframework.batch.restart.RestartData; @@ -37,7 +38,7 @@ import org.springframework.util.Assert; * * @author Robert Kasanicky */ -public class StaxEventReaderInputSource implements InputSource, Skippable, Restartable, StatisticsProvider, InitializingBean, DisposableBean { +public class StaxEventReaderInputSource implements InputSource, ResourceLifecycle, Skippable, Restartable, StatisticsProvider, InitializingBean, DisposableBean { public static final String READ_COUNT_STATISTICS_NAME = "StaxEventReaderInputSource.readCount";