PDA

View Full Version : Scheduler in Spring



MmarcoM
Feb 13th, 2005, 12:08 PM
hi all,
i have a webapplication that schedules persistent jobs using Quartz and Spring.
In appplicationContext.xml i am currently defining a SchedulerFactoryBean and a JobDetailBean.
<code>
<bean id="springScheduler" class="org.springframework.scheduling.quartz.SchedulerFac toryBean">
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
</bean>

<bean name="budgetJob" class="org.springframework.scheduling.quartz.JobDetailBea n">
<property name="jobClass">
<value>com.myapp.scheduler.BudgetJob</value>
</property>
</bean>
</code>

In my application i want also to be able to stop/pause/resume tasks, and for that i need a reference to Quartz Scheduler. Can i get it from SchedulerFactoryBean? if so, how?

thanx in advance and regards
marco

dan.baumann
Feb 13th, 2005, 12:54 PM
To the rest of your application, the SchedulerFactoryBean is the Scheduler (see the FactoryBean JavaDocs for details).

So if your class has a property named myScheduler of type org.quartz.Scheduler, the following should be sufficient:



<bean id="springScheduler" class="org.springframework.scheduling.quartz.SchedulerFac toryBean">
...
</bean>

<bean name="myBean" class="org.example.MyBean">
<property name="myScheduler">
<ref local="springScheduler"/>
</property>
</bean>


At least that's how I understand it..

MmarcoM
Feb 16th, 2005, 04:08 AM
ok found answer.
"org.springframework.scheduling.quartz.SchedulerFac toryBean" will return a org.quartz.StdScheduler , which is what i needed..

thanx and regards
marco

dan.baumann
Feb 16th, 2005, 04:10 AM
Glad I could help for once :-)