Expected Behavior
A builder for ResourcesItemReader, consistent with the other readers and writers in the org.springframework.batch.infrastructure.item.file.builder package, that also supports specifying the resources with a file pattern:
ResourcesItemReader reader = new ResourcesItemReaderBuilder()
.filesPattern("/data/inputs/*.csv")
.name("resourcesReader")
.build();
Current Behavior
ResourcesItemReader is the only reader in the org.springframework.batch.infrastructure.item.file package without a builder. It can only be configured through the default constructor and setResources(Resource[]).
Its Javadoc even suggests configuring it with a pattern ("Hint: use a pattern to configure."), which worked out of the box in XML configuration thanks to ResourceArrayPropertyEditor. In Java configuration, however, resolving the pattern is left to the user:
var resourcePatternResolver = new PathMatchingResourcePatternResolver();
ResourcesItemReader reader = new ResourcesItemReader();
reader.setResources(resourcePatternResolver.getResources("file:/data/inputs/*.csv"));
reader.setName("resourcesReader");
Context
This is a companion of #5056, which proposes the same pattern support for MultiResourceItemReaderBuilder (PR #5071). The proposed filesPattern(String) method follows the same naming and semantics, so the two builders would stay consistent.
I will submit a pull request for this shortly.
Expected Behavior
A builder for
ResourcesItemReader, consistent with the other readers and writers in theorg.springframework.batch.infrastructure.item.file.builderpackage, that also supports specifying the resources with a file pattern:Current Behavior
ResourcesItemReaderis the only reader in theorg.springframework.batch.infrastructure.item.filepackage without a builder. It can only be configured through the default constructor andsetResources(Resource[]).Its Javadoc even suggests configuring it with a pattern ("Hint: use a pattern to configure."), which worked out of the box in XML configuration thanks to
ResourceArrayPropertyEditor. In Java configuration, however, resolving the pattern is left to the user:Context
This is a companion of #5056, which proposes the same pattern support for
MultiResourceItemReaderBuilder(PR #5071). The proposedfilesPattern(String)method follows the same naming and semantics, so the two builders would stay consistent.I will submit a pull request for this shortly.