I am using Spring quartz to implement some schedule tasks. My initial configuration works fine, it looks like:
But I need to manage all tasks through UI startup of web application, I wonder if there is some way to pass new parameters to the method. I tried:Code:<bean id="quartzJobDetailSample" class="..." /> <bean id="jobDetailId" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="quartzJobDetailSample" /> <property name="targetMethod" value="methodName"/> <property name="arguments"> <list> <value>initialParam1</value> <value>initialParam2</value> </list> </property> </bean> <bean id="jobTriggerId" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobDetailId" /> <property name="cronExpression" value="0/15 * * * * ?" /> </bean> <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="jobTriggerId" /> </list> </property> </bean>
It turns out the MethodInvokingJobDetailFactoryBean generated a JobDetail instance for the bean with id "jobDetailId", but there's no way to pass arguments to method in JobDetail instance. I know I probably can use DataMap to achieve this, but I don't want to disturb my service layer (here is quartzJobDetailSample class) with any Quartz code if possible.MethodInvokingJobDetailFactoryBean bean = (MethodInvokingJobDetailFactoryBean)getApplication Context().getBean("jobDetailId");
bean.setArguments(new String[]{"1","2"});
If anyone has any idea, please share it. Thanks in advance


Reply With Quote
