Jan 28th, 2010, 02:59 PM
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?
Jan 29th, 2010, 12:52 AM
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.