Class MultiResourceItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.infrastructure.item.file.builder.MultiResourceItemReaderBuilder<T>
A builder implementation for the
MultiResourceItemReader.- Since:
- 4.0
- Author:
- Glenn Renfro, Drummond Dawson, Stefano Cordio, Usman Ijaz, Sanghyuk Jung
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds theMultiResourceItemReader.comparator(Comparator<org.springframework.core.io.Resource> comparator) Used to order the injected resources, by default comparesResource.getFilename()values.delegate(ResourceAwareItemReaderItemStream<? extends T> delegate) Establishes the delegate to use for reading the resources provided.The name used to calculate the key within theExecutionContext.The location patterns of resources that theMultiResourceItemReaderwill use to retrieve items.resources(org.springframework.core.io.Resource... resources) The array of resources that theMultiResourceItemReaderwill use to retrieve items.saveState(boolean saveState) Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.setStrict(boolean strict) Deprecated, for removal: This API element is subject to removal in a future version.strict(boolean strict) In strict mode the reader will throw an exception onMultiResourceItemReader.open(ExecutionContext)if there are no resources to read.
-
Constructor Details
-
MultiResourceItemReaderBuilder
public MultiResourceItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext. Defaults to the bean name, or to the short class name if this instance is not a bean. Set it explicitly to disambiguate several non-bean instances of the same type in a step.- Parameters:
name- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
resources
public MultiResourceItemReaderBuilder<T> resources(org.springframework.core.io.Resource... resources) The array of resources that theMultiResourceItemReaderwill use to retrieve items.- Parameters:
resources- the array of resources to use.- Returns:
- this instance for method chaining.
- See Also:
-
resources
The location patterns of resources that theMultiResourceItemReaderwill use to retrieve items. Each pattern is resolved through aPathMatchingResourcePatternResolver, so it can use any resource prefix supported by Spring (for examplefile:,classpath:orclasspath*:) combined with Ant-style wildcards like*,**and?(for examplefile:/data/*.csvorclasspath*:data/**/user?.txt).- Parameters:
locationPatterns- the location patterns of resources to use.- Returns:
- this instance for method chaining.
- Since:
- 6.1.0
-
delegate
public MultiResourceItemReaderBuilder<T> delegate(ResourceAwareItemReaderItemStream<? extends T> delegate) Establishes the delegate to use for reading the resources provided.- Parameters:
delegate- reads items from singleResource.- Returns:
- this instance for method chaining.
- See Also:
-
setStrict
@Deprecated(since="6.1.0", forRemoval=true) public MultiResourceItemReaderBuilder<T> setStrict(boolean strict) Deprecated, for removal: This API element is subject to removal in a future version.as of 6.1.0 in favor ofstrict(boolean)In strict mode the reader will throw an exception onMultiResourceItemReader.open(ExecutionContext)if there are no resources to read.- Parameters:
strict- false by default.- Returns:
- this instance for method chaining.
- See Also:
-
strict
In strict mode the reader will throw an exception onMultiResourceItemReader.open(ExecutionContext)if there are no resources to read.- Parameters:
strict- false by default.- Returns:
- this instance for method chaining.
- Since:
- 6.1.0
- See Also:
-
comparator
public MultiResourceItemReaderBuilder<T> comparator(Comparator<org.springframework.core.io.Resource> comparator) Used to order the injected resources, by default comparesResource.getFilename()values.- Parameters:
comparator- the comparator to use for ordering resources.- Returns:
- this instance for method chaining.
- See Also:
-
build
Builds theMultiResourceItemReader.- Returns:
- a
MultiResourceItemReader
-
strict(boolean)