Using Spring Quartz
From Skyway Wiki
To add Spring's Quartz Job Scheduling support into your Skyway generated project, follow these steps:
- Add the quartz jar to your build path. (e.g. quartz-1.6.4.jar) Quartz downloads
- Create a Skyway Service and set the scope to singleton. (Spring Bean Configuration tab)
- Add the following configuration to the resources/[ProjectName]-web-context.xml file
- <bean id="methodInvokingJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <property name="targetObject" ref="[QuartzService]" />
- <property name="targetMethod" value="[quartzOperation]" />
- </bean>
- <bean id="skywayTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
- <property name="jobDetail" ref="methodInvokingJob" />
- <property name="startDelay" value="0" />
- <property name="repeatInterval" value="10000" />
- </bean>
- <bean id="skywayScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="skywayTrigger" />
- </list>
- </property>
- </bean>
Where [QuartzService] is the name of your Skyway Service, and [quartzOperation] is the name of your Skyway Operation (first letter is lower case)
If you want to control the Trigger properties from a database, sub-class the trigger bean and call a Skyway Operation to handle the rest, like so: (NOTE: This example uses the CronTriggerBean instead of SimpleTriggerBean)
public class ConfigurableCronTriggerBean extends CronTriggerBean
{
@Resource(name = "ConfigService")
protected ConfigService configService;
public void setCronExpression(String cronExpression) throws ParseException
{
try {
String configCronExpression = null;
// Skyway generated service that uses a named query to get the cron Expression from the DB
configCronExpression = configService.loadCronExpression();
super.setCronExpression(configCronExpression);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Resources:

