您好,我希望我的应用程序的用户通过IHM选择一个表达式并配置一个服务实际上我每小时配置一次石英它运行良好但当我试图让用户配置执行该作业的时间事情的数量,我用这个代码:
public void collectorCronScheduling(String expression) {
try {
triggerBean.setCronExpression(expression);
triggerBean.validate();
System.out.println("cron expression modifiée");
schedulerFactoryBean.start();
System.out.println("scheduler started");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SchedulerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public CronTriggerBean getTriggerBean() {
return triggerBean;
}
public void setTriggerBean(CronTriggerBean triggerBean) {
this.triggerBean = triggerBean;
}
public SchedulerFactoryBean getSchedulerFactoryBean() {
return schedulerFactoryBean;
}
public void setSchedulerFactoryBean(
SchedulerFactoryBean schedulerFactoryBean) {
this.schedulerFactoryBean = schedulerFactoryBean;
}
这是applicationContext.xml
<bean id="collectorTicketServiceImplJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="collectorTicketServiceImpl" />
<property name="targetMethod" value="ExtractTicketFromMail" />
</bean>
<bean id="collectorTicketServiceImplTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="collectorTicketServiceImplJob" />
<property name="cronExpression" value="0 0/30 * * * ?" />
</bean>
<bean id="collectorTicketServiceImplTriggerSchedular"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="collectorTicketServiceImplTrigger" />
</list>
</property>
</bean>