Announcement Announcement Module
No announcement yet.
Adding JobExecutionListener Programatically Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding JobExecutionListener Programatically


    I want to add a JobExecutionListener to Jobs programatically. Is there a way?

    I'm trying to have something like a Global JobExecutionListener. I discover a list of the jobs registered in the application context, and want to add my Listener to each of them. The idea behind is to get an update on each job as it gets fired/completed.

    Also, the Job interface does not have methods to add the listener? Even if I get hold of an instance of job how do I add it?

  • #2
    Usually it's better to do these sorts of things in the xml. You could, for instance, create an abstract <job/> that only has the listener on it and then all of your concrete jobs could have a parent= attribute that references it (thus inheriting the listener).

    If you really want to do it programmatically, you can do it with a BeanPostProcessor.