kailash gaur
kailash gaur

Reputation: 1447

Read Data from java class in spring batch

I am generating different combination of strings in my one java class through spring batch. I have setup batch framework with implementing IteamReader, IteamWriter. It's working in simple manner like if we are reading from csv file or some other external source.

I want to read it from on of my java class and pass these input to Item processor. I have looked into the ListIteamReader class but it's constructor takes list as argument and I need to pass this from externally.

I am bit new in spring batch. Please give you suggestion or paste good links related to this type of scenario if you have any. Any help is appreciated.

Upvotes: 1

Views: 184

Answers (1)

Dean Clark
Dean Clark

Reputation: 3868

You can use SpEL to access the list from your bean (assuming you are storing your Strings in a List<String> listOfStrings in your class).

<bean id="listReader" class="org.springframework.batch.item.support.ListItemReader">
   <constructor-arg name="list" value="#{yourBean.listOfStrings}" />
</bean>

<bean id="yourBean" class="com.package.YourClass" />

Upvotes: 1

Related Questions