Reputation: 13118
I have the following snippet from a conf spring file:
<bean id="taskletStep" abstract="true" class="org.springframework.batch.core.step.tasklet.TaskletStep">
<property name="jobRepository" ref="jobRepository"/>
<property name="transactionManager" ref="transactionManager"/>
</bean>
<bean id="hello" class="com.techavalanche.batch.PrintTasklet">
<property name="message" value="Hello"/>
</bean>
<bean id="world" class="com.techavalanche.batch.PrintTasklet">
<property name="message" value=" World!"/>
</bean>
<bean id="mySimpleJob" class="org.springframework.batch.core.job.SimpleJob">
<property name="name" value="mySimpleJob" />
<property name="steps">
<list>
<bean parent="taskletStep">
<property name="tasklet" ref="hello"/>
</bean>
<bean parent="taskletStep">
<property name="tasklet" ref="world"/>
</bean>
</list>
</property>
To me it is not very clear the following bit:
<bean parent="taskletStep">
<property name="tasklet" ref="hello"/>
</bean>
taskletStep it is an interface and does not have any property. However the code works fine, it seems that the bean with ID "hello" gets injected. Therefore I am asking, is this the standard way from the config file to inject a bean implementation (id: hello) to an interface bean (id: taskletStep)?
Upvotes: 0
Views: 235
Reputation: 9658
It's a tasklet step in Spring Batch Job. What you are doing is perfectly fine. Alternatively, you can also do something like this:
<job id="mySimpleJob">
<step id="step1">
<tasklet ref="hello"/>
</step>
<step id="step2">
<tasklet ref="world"/>
</step>
</job>
Here is a complete reference: http://docs.spring.io/spring-batch/reference/htmlsingle/
Upvotes: 1