ResourceLineReader did not need to implement ItemStream
This commit is contained in:
@@ -221,7 +221,7 @@ public class FlatFileItemReader extends AbstractBufferedItemReaderItemStream imp
|
||||
try {
|
||||
if (reader != null) {
|
||||
log.debug("Closing flat file for reading: " + resource);
|
||||
reader.close(null);
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -16,17 +16,20 @@
|
||||
package org.springframework.batch.item.file.separator;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface LineReader extends ItemReader, ItemStream {
|
||||
public interface LineReader extends ItemReader {
|
||||
|
||||
/**
|
||||
* @return position
|
||||
*/
|
||||
int getPosition();
|
||||
|
||||
void open();
|
||||
|
||||
void close();
|
||||
|
||||
}
|
||||
|
||||
@@ -25,11 +25,9 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemStreamSupport;
|
||||
import org.springframework.batch.item.MarkFailedException;
|
||||
import org.springframework.batch.item.ResetFailedException;
|
||||
import org.springframework.batch.item.UnexpectedInputException;
|
||||
@@ -54,7 +52,7 @@ import org.springframework.util.Assert;
|
||||
* @author Dave Syer
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class ResourceLineReader extends ItemStreamSupport implements LineReader, ItemReader {
|
||||
public class ResourceLineReader implements LineReader, ItemReader {
|
||||
|
||||
private static final Collection DEFAULT_COMMENTS = Collections.singleton("#");
|
||||
|
||||
@@ -156,10 +154,8 @@ public class ResourceLineReader extends ItemStreamSupport implements LineReader,
|
||||
|
||||
/**
|
||||
* Close the reader associated with this input source.
|
||||
*
|
||||
* @see org.springframework.batch.item.ItemStreamSupport#close(org.springframework.batch.item.ExecutionContext)
|
||||
*/
|
||||
public synchronized void close(ExecutionContext executionContext) {
|
||||
public synchronized void close() {
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public abstract class CommonDatabaseItemStreamItemReaderTests extends CommonItem
|
||||
private ClassPathXmlApplicationContext ctx;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
ctx = new ClassPathXmlApplicationContext("foo-data-source-context.xml", JdbcCursorItemReaderCommonTests.class);
|
||||
ctx = new ClassPathXmlApplicationContext("org/springframework/batch/item/database/data-source-context.xml");
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ public class ResourceLineReaderTests extends TestCase {
|
||||
Resource resource = new ByteArrayResource("a,b,c\n1,2,3".getBytes());
|
||||
ResourceLineReader reader = new ResourceLineReader(resource);
|
||||
reader.open();
|
||||
reader.close(null);
|
||||
reader.close();
|
||||
try {
|
||||
reader.close(null); // just closing a BufferedReader twice should be fine
|
||||
reader.close(); // just closing a BufferedReader twice should be fine
|
||||
} catch (Exception e) {
|
||||
fail("Unexpected Exception "+e);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class ResourceLineReaderTests extends TestCase {
|
||||
Resource resource = new ByteArrayResource("1\n# 2\n3".getBytes());
|
||||
ResourceLineReader reader = new ResourceLineReader(resource);
|
||||
reader.read();
|
||||
reader.close(null);
|
||||
reader.close();
|
||||
reader.mark();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
</bean>
|
||||
</property>
|
||||
<property name="initScripts" value="org/springframework/batch/item/database/init-foo-schema-hsqldb.sql" />
|
||||
<property name="destroyScript" value="org/springframework/batch/item/database/destroy-foo-schema-hsqldb.sql" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="dataSource" class="test.jdbc.datasource.InitializingDataSourceFactoryBean">
|
||||
<property name="dataSource">
|
||||
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:foodb" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="initScripts" value="org/springframework/batch/item/database/init-foo-schema-hsqldb.sql" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user