My task is to dynamically generate reports with the scheduled time specified by the user from the graphical interface.
I use the following code in the application context of my application in spring to generate a 6 AM report daily.
<bean name="scheduleRptJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.secant.qatool.report.scheduler.ScheduleCroneJob"/>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="scheduleRptJob" />
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger"/>
</list>
</property>
</bean>
I am modifying a cron expression dynamically from a controller using the following code. But it does not work.
String time[] = rptScheduleTime.split(":");
String hours = time[0];
String minutes = time[1];
String croneExp = " 00 " + minutes + " " + hours + " * * ? ";
log.debug("CRONE EXP :: " + croneExp);
cronTrigger.clearAllTriggerListeners();
cronTrigger.setCronExpression(croneExp);
Trigger[] triggers = {cronTrigger};
schedulerFactory.stop();
schedulerFactory.setTriggers(triggers);
schedulerFactory.start();
Can someone please help me how to transfer the same work with dynamic time.
Thank,
-Anil Kumar.C
source
share