T
- item typepublic class MultiResourceItemWriter<T> extends ExecutionContextUserSupport implements ItemWriter<T>, ItemStream
ResourceAwareItemWriterItemStream
and creates a new output
resource when the count of items written in current resource exceeds
setItemCountLimitPerResource(int)
. Suffix creation can be customized
with setResourceSuffixCreator(ResourceSuffixCreator)
.
Note that new resources are created only at chunk boundaries i.e. the number
of items written into one resource is between the limit set by
setItemCountLimitPerResource(int)
and (limit + chunk size).Constructor and Description |
---|
MultiResourceItemWriter() |
Modifier and Type | Method and Description |
---|---|
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 provided
ExecutionContext . |
void |
setDelegate(ResourceAwareItemWriterItemStream<? super T> delegate)
Delegate used for actual writing of the output.
|
void |
setItemCountLimitPerResource(int itemCountLimitPerResource)
After this limit is exceeded the next chunk will be written into newly
created resource.
|
void |
setResource(org.springframework.core.io.Resource resource)
Prototype for output resources.
|
void |
setResourceSuffixCreator(ResourceSuffixCreator suffixCreator)
Allows customization of the suffix of the created resources based on the
index.
|
void |
setSaveState(boolean saveState) |
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved.
|
void |
write(List<? extends T> items)
Process the supplied data element.
|
getKey, getName, setName
public void write(List<? extends T> items) throws Exception
ItemWriter
write
in interface ItemWriter<T>
Exception
- if there are errors. The framework will catch the
exception and convert or rethrow it as appropriate.public void setResourceSuffixCreator(ResourceSuffixCreator suffixCreator)
public void setItemCountLimitPerResource(int itemCountLimitPerResource)
public void setDelegate(ResourceAwareItemWriterItemStream<? super T> delegate)
public void setResource(org.springframework.core.io.Resource resource)
setResourceSuffixCreator(ResourceSuffixCreator)
.public void setSaveState(boolean saveState)
public void close() throws ItemStreamException
ItemStream
close
in interface ItemStream
ItemStreamException
public void open(ExecutionContext executionContext) throws ItemStreamException
ItemStream
ExecutionContext
.open
in interface ItemStream
ItemStreamException
public void update(ExecutionContext executionContext) throws ItemStreamException
ItemStream
update
in interface ItemStream
executionContext
- to be updatedItemStreamException
Copyright © 2013 SpringSource. All rights reserved.