James Schermann James Schermann - 1 year ago 93
Java Question

Spring Batch: get list of defined jobs at runtime

Is it possible to get a list of defined jobs in Spring Batch at runtime without using db? Maybe it's possible to get this metadata from

bean or some similar object?

Answer Source

It is possible to retrieve the list of all job names using JobExplorer.getJobNames().

You first have to define the jobExplorer bean using JobExplorerFactoryBean:

<bean id="jobExplorer" class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
    <property name="dataSource" ref="dataSource"/>

and then you can inject this bean when you need it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download