kiran
kiran

Reputation: 2428

Dependency Injection when using Spring Quartz with JDBC Store

I have to use Spring Quartz with JDBC Store for scheduling the app. I am not sure how to handle the Dependency Injection when the jobs are triggered from the database. One way would be retrieve the beans from the context after the job is triggered. But it wont be DI any longer. Any ideas on how to handle DI when using Spring Quartz on JDBC Store for clustering.

Upvotes: 2

Views: 777

Answers (1)

Guillaume Polet
Guillaume Polet

Reputation: 47608

This answer is the best I have found these kind of issues: inject bean reference in quartz job

Basic idea is to extend the SpringBeanJobFactory, inject application context in that new factory, and upon creation of the job, autowire any bean required.

Tested and it works like a charm.

Upvotes: 2

Related Questions