Tidy up streams on close in stream manager

This commit is contained in:
dsyer
2008-02-27 08:05:52 +00:00
parent b846c68550
commit e3c86285cf
6 changed files with 20 additions and 9 deletions

View File

@@ -102,6 +102,7 @@ public class SimpleStreamManager implements StreamManager {
ItemStream itemStream = (ItemStream) it.next();
itemStream.close(executionContext);
}
streams.clear();
}
}

View File

@@ -125,6 +125,22 @@ public class SimpleStreamManagerTests extends TestCase {
assertEquals(1, list.size());
}
/**
* Test method for
* {@link org.springframework.batch.item.stream.SimpleStreamManager#commit(org.springframework.transaction.TransactionStatus)}.
*/
public void testCloseUnregisters() {
manager.register(new ItemStreamSupport() {
public void open(ExecutionContext executionContext) throws StreamException {
list.add("bar");
}
});
manager.open(null);
manager.close(null);
manager.open(null);
assertEquals(1, list.size());
}
/**
* Test method for
* {@link org.springframework.batch.item.stream.SimpleStreamManager#commit(org.springframework.transaction.TransactionStatus)}.

View File

@@ -91,8 +91,8 @@ public class AsynchronousRepeatTests extends AbstractTradeBatchTests {
// Shouldn't be necessary to wait:
// Thread.sleep(500);
assertEquals(NUMBER_OF_ITEMS, processor.count);
// Because of the throttling and queing internally to a TaskExecutor,
// more than one thread wil be used - the number used is (as of writing)
// Because of the throttling and queueing internally to a TaskExecutor,
// more than one thread will be used - the number used is (as of writing)
// one less than the throttle limit of the template.
// TODO: see if we can get it to use only one thread?
assertTrue(threadNames.size() >= 1);

View File

@@ -51,8 +51,6 @@ public class SimpleTradeWriter extends AbstractItemWriter implements ItemStream
*/
private int tradeCount = 0;
private ExecutionContext executionContext;
/**
* The input template is read using the readAndMap method, which accepts a
* FieldSetMapper. This call returns a Trade object, which is then
@@ -70,7 +68,6 @@ public class SimpleTradeWriter extends AbstractItemWriter implements ItemStream
}
public void open(ExecutionContext context) throws StreamException {
this.executionContext = context;
}
/* (non-Javadoc)

View File

@@ -18,8 +18,6 @@
<list>
<bean id="playerload" parent="simpleStep">
<property name="commitInterval" value="1"/>
<property name="startLimit" value="100" />
<property name="allowStartIfComplete" value="false" />
<property name="itemReader"
ref="playerFileItemReader" />
<property name="itemWriter">
@@ -37,7 +35,6 @@
</bean>
<bean id="gameLoad" parent="simpleStep">
<property name="commitInterval" value="1" />
<property name="startLimit" value="100" />
<property name="itemReader"
ref="gameFileItemReader" />
<property name="itemWriter">
@@ -50,7 +47,6 @@
</bean>
<bean id="playerSummarization" parent="simpleStep">
<property name="commitInterval" value="1" />
<property name="startLimit" value="100" />
<property name="itemReader"
ref="playerSummarizationSource" />
<property name="itemWriter">

View File

@@ -102,6 +102,7 @@
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="allowStartIfComplete" value="true" />
<property name="startLimit" value="100"/>
<property name="exceptionHandler">
<bean