Is it possible in JSR-352 / Java Batch to have batch properties as List? How would they get initialized from the batch job XML?
public class MyItemProcessor extends ItemProcessor {
@Inject
@BatchProperty
private List<String> items;
public final Object processItem(Object o) throws Exception {
...
}
}
Here is a skeleton batch job xml:
<?xml version="1.0" encoding="UTF-8"?>
<job xmlns="https://jakarta.ee/xml/ns/jakartaee" version="2.0" id="exportToExcel" restartable="true">
<chunk item-count="10">
...some reader...
<processor ref="MyItemProcessor">
<properties>
<property name="items"/> <-- how would the list of strings go in here?
</properties>
</processor>
...some writer...
</chunk>
</job>
asked Mar 26, 2024 at 11:55
queeg
9,9502 gold badges26 silver badges64 bronze badges
1 Answer 1
Yes. see JBeret examples below. This is specific to JBeret, not a standard feature in Java Batch spec.
See JBeret Docs for more info. The list value can be simple comma-separated string values.
Sign up to request clarification or add additional context in comments.
2 Comments
queeg
It seems the examples parse a single string value to generate lists, dates, etc. Is there some more documentation about it? E.g. what to do if my strings contain commas?
cheng
commas will be interpreted as delimiter. For such values, it's better to inject them as string value and then parse it.
lang-java