PDA

View Full Version : Manually launch Quartz jobs within ContextLoaderListener


bdusauso
Apr 24th, 2006, 09:35 AM
Hi,

I have two ContextLoaderListener, the first is from Spring's API, the other is home made.

I'd like to launch some Quartz jobs using Spring. They're already in the application context file.

The problem is that I have some "maintenance classes", that is classes that are launched outside of the webapp, in console. They also use the Spring application context file in order to get the beans they need.

What I want is to be able to not launch the Quartz jobs when I use these "maintenance classes", only when I'm using the webapp.

I already do it with my own beans, like this :

public void contextInitialized(ServletContextEvent ev) {
ServletContext servletContext = ev.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicati onContext(servletContext);
// ...
// launch of the event manager
((EventManager)wac.getBean("EventManager")).init();
//
}


How can I tell Spring not to automatically launch the scheduler but programmatically do it ?

Andreas Senft
Apr 24th, 2006, 09:49 AM
What about specifying the quartz beans as "lazy-init"? If they are not referenced by your maintenance classes they should not get instantiated automatically.

Regards,
Andreas

bdusauso
Apr 25th, 2006, 10:12 AM
Well, it may be a solution. I'll investigate it further.

Thanks.