Class MultiResourceItemWriterBuilder<T>
- java.lang.Object
- org.springframework.batch.item.file.builder.MultiResourceItemWriterBuilder<T>
public class MultiResourceItemWriterBuilder<T> extends java.lang.Object
A builder implementation for theMultiResourceItemWriter
.- Since:
- 4.0
- Author:
- Glenn Renfro, Glenn Renfro
- See Also:
MultiResourceItemWriter
Constructor Summary
Constructors Constructor Description MultiResourceItemWriterBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiResourceItemWriter<T>
build()
Builds theMultiResourceItemWriter
.MultiResourceItemWriterBuilder<T>
delegate(ResourceAwareItemWriterItemStream<? super T> delegate)
Delegate used for actual writing of the output.MultiResourceItemWriterBuilder<T>
itemCountLimitPerResource(int itemCountLimitPerResource)
After this limit is exceeded the next chunk will be written into newly created resource.MultiResourceItemWriterBuilder<T>
name(java.lang.String name)
The name used to calculate the key within theExecutionContext
.MultiResourceItemWriterBuilder<T>
resource(org.springframework.core.io.Resource resource)
Prototype for output resources.MultiResourceItemWriterBuilder<T>
resourceSuffixCreator(ResourceSuffixCreator suffixCreator)
Allows customization of the suffix of the created resources based on the index.MultiResourceItemWriterBuilder<T>
saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.
Method Detail
saveState
public MultiResourceItemWriterBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
name
public MultiResourceItemWriterBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext
. Required ifsaveState(boolean)
is set to true.- Parameters:
name
- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
ItemStreamSupport.setName(String)
resourceSuffixCreator
public MultiResourceItemWriterBuilder<T> resourceSuffixCreator(ResourceSuffixCreator suffixCreator)
Allows customization of the suffix of the created resources based on the index.- Parameters:
suffixCreator
- the customizable ResourceSuffixCreator to use.- Returns:
- The current instance of the builder.
- See Also:
MultiResourceItemWriter.setResourceSuffixCreator(ResourceSuffixCreator)
itemCountLimitPerResource
public MultiResourceItemWriterBuilder<T> itemCountLimitPerResource(int itemCountLimitPerResource)
After this limit is exceeded the next chunk will be written into newly created resource.- Parameters:
itemCountLimitPerResource
- the max numbers of items to be written per chunk.- Returns:
- The current instance of the builder.
- See Also:
MultiResourceItemWriter.setItemCountLimitPerResource(int)
delegate
public MultiResourceItemWriterBuilder<T> delegate(ResourceAwareItemWriterItemStream<? super T> delegate)
Delegate used for actual writing of the output.- Parameters:
delegate
- The delegate to use for writing.- Returns:
- The current instance of the builder.
- See Also:
MultiResourceItemWriter.setDelegate(ResourceAwareItemWriterItemStream)
resource
public MultiResourceItemWriterBuilder<T> resource(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 toMultiResourceItemWriter.setResourceSuffixCreator(ResourceSuffixCreator)
.- Parameters:
resource
- the prototype resource to use as the basis for creating resources.- Returns:
- The current instance of the builder.
- See Also:
MultiResourceItemWriter.setResource(Resource)
build
public MultiResourceItemWriter<T> build()
Builds theMultiResourceItemWriter
.- Returns:
- a
MultiResourceItemWriter