Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get Quartz jobs running in a multi-ApplicationContext environment?
    text
    copied!<p>I have a Spring Web application with an <code>applicationContext.xml</code> loaded through a <code>ContextLoaderListener</code> in an <code>XmlWebApplicationContext</code>. The application context has a Quartz scheduler (defined with a <code>SchedulerFactoryBean</code> like <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/scheduling.html#scheduling-quartz-cron" rel="nofollow">here</a>) but has no trigger nor job details.</p> <p>During loading of this main application context, I load some "plug-in" JARs containing their own <code>pluginApplicationContext.xml</code> file. Each <code>pluginApplicationContext.xml</code> is loaded in a <code>GenericXmlApplicationContext</code> as a child of the main <code>XmlWebApplicationContext</code>.</p> <p>Those plug-ins may contain Quartz jobs (<code>QuartzJobBean</code>) which are scheduled within the scheduler discussed above. Scheduling have to be done programmatically through the Quartz API but this is fine for me. When the job is triggered, it is well instanciated by Quartz and, because it extends the <code>QuartzJobBean</code>, I'm able to get the current <code>ApplicationContext</code> through <code>setApplicationContext</code>. The problem here is that I get the <code>XmlWebApplicationContext</code> instead of the <code>GenericXmlApplicationContext</code> from which the job have been scheduled. Thus, I cannot call <code>getBean</code> to retrieve the beans defined within the plugin.</p> <p>I well understand why all of this happen. But I cannot find a clean and reusable solution to handle it. I've already had a look at OSGi but we're implementing this plug-in system on an existing application, not creating a new one from scratch and migrating the whole application to OSGi would be too much work to do. Do you know how OSGi and other plug-in frameworks deal with this kind of situation?</p> <p>Thanks a lot for your help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload