Class AsyncItemWriter<T>
java.lang.Object
org.springframework.batch.integration.async.AsyncItemWriter<T>
- All Implemented Interfaces:
ItemStream
,ItemStreamWriter<Future<T>>
,ItemWriter<Future<T>>
,org.springframework.beans.factory.InitializingBean
public class AsyncItemWriter<T>
extends Object
implements ItemStreamWriter<Future<T>>, org.springframework.beans.factory.InitializingBean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
close()
If any resources are needed for the stream to operate they need to be destroyed here.void
open
(ExecutionContext executionContext) Open the stream for the providedExecutionContext
.void
setDelegate
(ItemWriter<T> delegate) void
update
(ExecutionContext executionContext) Indicates that the execution context provided during open is about to be saved.void
In the processing of theFuture
s passed, nulls are not passed to the delegate since they are considered filtered out by theAsyncItemProcessor
's delegatedItemProcessor
.
-
Constructor Details
-
AsyncItemWriter
public AsyncItemWriter()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
setDelegate
- Parameters:
delegate
- ItemWriter that does the actual writing of the Future results
-
write
In the processing of theFuture
s passed, nulls are not passed to the delegate since they are considered filtered out by theAsyncItemProcessor
's delegatedItemProcessor
. If the unwrapping of theFuture
results in anExecutionException
, that will be unwrapped and the cause will be thrown.- Specified by:
write
in interfaceItemWriter<T>
- Parameters:
items
-Future
s to be unwrapped and passed to the delegate- Throws:
Exception
- The exception returned by the Future if one was thrown
-
open
Description copied from interface:ItemStream
Open the stream for the providedExecutionContext
.- Specified by:
open
in interfaceItemStream
- Parameters:
executionContext
- current step'sExecutionContext
. Will be the executionContext from the last run of the step on a restart.- Throws:
ItemStreamException
-
update
Description copied from interface:ItemStream
Indicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.- Specified by:
update
in interfaceItemStream
- Parameters:
executionContext
- to be updated- Throws:
ItemStreamException
-
close
Description copied from interface:ItemStream
If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.- Specified by:
close
in interfaceItemStream
- Throws:
ItemStreamException
-