lundi 20 avril 2015

How to filter Spring Jobs defined in a given context?

I have a basic Spring Batch job module. It just provides the basic configuration required to set-up and launch a job like TransactionManager, JobRepository etc. Now I have kept it generic so that different projects/modules can simply import it and use it to define jobs specific to the project. Different modules define their jobs in their application context files and populate the jobRepository. Now I want to have a Spring Admin UI which picks up the jobs defined in the application context of say, module A. But it seems to be picking up all the jobs defined by all the projects that are in the repository. And it is because I am doing the following to pick up the jobs. My question is this-- is there an alternative approach so that jobs defined in a particular context are picked up and not the others? If, how should that be achieved?

    for (ConfigurableApplicationContext factory : rootContext.getChildren())
            String[] str = factory.getBeanNamesforType(Job.class)

Please assist. Thanks as always

Aucun commentaire:

Enregistrer un commentaire