类 MultiResourceItemWriter<T>
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.item.support.AbstractItemStreamItemWriter<T>
- org.springframework.batch.item.file.MultiResourceItemWriter<T>
- 类型参数:
T
- item type
- 所有已实现的接口:
ItemStream
,ItemStreamWriter<T>
,ItemWriter<T>
public class MultiResourceItemWriter<T> extends AbstractItemStreamItemWriter<T>
Wraps aResourceAwareItemWriterItemStream
and creates a new output resource when the count of items written in current resource exceedssetItemCountLimitPerResource(int)
. Suffix creation can be customized withsetResourceSuffixCreator(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 bysetItemCountLimitPerResource(int)
and (limit + chunk size).- 作者:
- Robert Kasanicky
构造器概要
构造器 构造器 说明 MultiResourceItemWriter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
No-op.void
open(ExecutionContext executionContext)
No-op.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)
Indicates that the state of the reader will be saved after each commit.void
update(ExecutionContext executionContext)
Return emptyExecutionContext
.void
write(java.util.List<? extends T> items)
Process the supplied data element.从类继承的方法 org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, setExecutionContextName, setName
构造器详细资料
MultiResourceItemWriter
public MultiResourceItemWriter()
方法详细资料
write
public void write(java.util.List<? extends T> items) throws java.lang.Exception
从接口复制的说明:ItemWriter
Process the supplied data element. Will not be called with any null items in normal operation.- 参数:
items
- items to be written- 抛出:
java.lang.Exception
- if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.
setResourceSuffixCreator
public void setResourceSuffixCreator(ResourceSuffixCreator suffixCreator)
Allows customization of the suffix of the created resources based on the index.- 参数:
suffixCreator
-ResourceSuffixCreator
to be used by the writer.
setItemCountLimitPerResource
public void setItemCountLimitPerResource(int itemCountLimitPerResource)
After this limit is exceeded the next chunk will be written into newly created resource.- 参数:
itemCountLimitPerResource
- int item threshold used to determine when a new resource should be created.
setDelegate
public void setDelegate(ResourceAwareItemWriterItemStream<? super T> delegate)
Delegate used for actual writing of the output.- 参数:
delegate
-ResourceAwareItemWriterItemStream
that will be used to write the output.
setResource
public void setResource(org.springframework.core.io.Resource resource)
Prototype for output resources. Actual output files will be created in the same directory and use the same name as this prototype with appended suffix (according tosetResourceSuffixCreator(ResourceSuffixCreator)
.- 参数:
resource
- The prototype resource.
setSaveState
public void setSaveState(boolean saveState)
Indicates that the state of the reader will be saved after each commit.- 参数:
saveState
- true the state is saved.
close
public void close() throws ItemStreamException
从类复制的说明:ItemStreamSupport
No-op.- 指定者:
close
在接口中ItemStream
- 覆盖:
close
在类中ItemStreamSupport
- 抛出:
ItemStreamException
- 另请参阅:
ItemStream.close()
open
public void open(ExecutionContext executionContext) throws ItemStreamException
从类复制的说明:ItemStreamSupport
No-op.- 指定者:
open
在接口中ItemStream
- 覆盖:
open
在类中ItemStreamSupport
- 参数:
executionContext
- current step'sExecutionContext
. Will be the executionContext from the last run of the step on a restart.- 抛出:
ItemStreamException
- 另请参阅:
ItemStream.open(ExecutionContext)
update
public void update(ExecutionContext executionContext) throws ItemStreamException
从类复制的说明:ItemStreamSupport
Return emptyExecutionContext
.- 指定者:
update
在接口中ItemStream
- 覆盖:
update
在类中ItemStreamSupport
- 参数:
executionContext
- to be updated- 抛出:
ItemStreamException
- 另请参阅:
ItemStream.update(ExecutionContext)