THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
The following class performs the glue between Quartz and Webwork:
Code Block |
---|
package com.trantek.sit.action; import orgcom.opensymphony.quartzxwork.JobActionProxy; import orgcom.opensymphony.quartzxwork.JobExecutionContextActionProxyFactory; import org.quartz.JobExecutionExceptionJob; import webworkorg.actionquartz.ActionContextJobExecutionContext; import webworkorg.dispatcherquartz.GenericDispatcherJobExecutionException; public class WebworkJobWebWorkJob implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { try {try ActionContext.setParameters(context.getJobDetail().getJobDataMap()); { GenericDispatcher dispatcher = new ActionProxy proxy = ActionProxyFactory.getFactory(). GenericDispatcher(createActionProxy("", context.getJobDetail().getName()); dispatcher.prepareValueStack(); , context.getJobDetail().getJobDataMap()); dispatcher.executeAction(); dispatcherproxy.finishexecute(); dispatcher.finalizeContext();} } catch (Exception e) { throw new JobExecutionException(e); } } } |
To schedule webwork actions you simply create a job where
...
Code Block |
---|
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); JobDetail jobDetail = new JobDetail("email.send", scheduler.DEFAULT_GROUP, WebworkJob.class); Map m = jobDetail.getJobDataMap(); m.put("to", "me@bogusdomain.com"); m.put("subject", "quartz test"); m.put("body", "This is a quartz test, Hey ho"); m.put("smtpServer", "smtp.bogusdomain.com"); m.put("from", "quartz@bogusdomain.com"); SimpleTrigger trigger = new SimpleTrigger("myTrigger", scheduler.DEFAULT_GROUP, new Date(), null, 0, 0L); scheduler.deleteJob("email.send", scheduler.DEFAULT_GROUP); scheduler.scheduleJob(jobDetail, trigger); |
This example is based on