File tree 1 file changed +24
-0
lines changed
spring-batch-docs/src/main/asciidoc
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2492,3 +2492,27 @@ NOTE: There are some practical limitations of using job-scoped beans in multi-th
2492
2492
or partitioned steps. Spring Batch does not control the threads spawned in these
2493
2493
use cases, so it is not possible to set them up correctly to use such beans. Hence,
2494
2494
we do not recommend using job-scoped beans in multi-threaded or partitioned steps.
2495
+
2496
+ [[scoping-item-streams]]
2497
+ ==== Scoping `ItemStream` components
2498
+
2499
+ When using the Java configuration style to define job or step scoped `ItemStream` beans,
2500
+ the return type of the bean definition method should be at least `ItemStream`. This is required
2501
+ so that Spring Batch correctly creates a proxy that implements this interface, and therefore
2502
+ honors its contract by calling `open`, `update` and `close` methods as expected.
2503
+
2504
+ It is recommended to make the bean definition method of such beans return the most specific
2505
+ known implementation, as shown in the following example:
2506
+
2507
+ .Define a step-scoped bean with the most specific return type
2508
+ [source, java]
2509
+ ----
2510
+ @Bean
2511
+ @StepScope
2512
+ public FlatFileItemReader flatFileItemReader(@Value("#{jobParameters['input.file.name']}") String name) {
2513
+ return new FlatFileItemReaderBuilder<Foo>()
2514
+ .resource(new FileSystemResource(name))
2515
+ // set other properties of the item reader
2516
+ .build();
2517
+ }
2518
+ ----
You can’t perform that action at this time.
0 commit comments