01: package org.sakaiproject.component.app.scheduler.test;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05: import org.quartz.Job;
06: import org.quartz.JobExecutionContext;
07: import org.quartz.JobExecutionException;
08: import org.sakaiproject.api.app.scheduler.ScheduledInvocationManager;
09: import org.sakaiproject.time.api.TimeService;
10:
11: public class ScheduledInvocationTestJob implements Job {
12:
13: private static final Log LOG = LogFactory
14: .getLog(ScheduledInvocationTestJob.class);
15:
16: /** Dependency: ScheduledInvocationManager */
17: protected ScheduledInvocationManager m_sim = null;
18:
19: public void setSim(ScheduledInvocationManager service) {
20: m_sim = service;
21: }
22:
23: /** Dependency: TimeService */
24: protected TimeService m_timeService = null;
25:
26: public void setTimeService(TimeService service) {
27: m_timeService = service;
28: }
29:
30: public void execute(JobExecutionContext arg0)
31: throws JobExecutionException {
32:
33: LOG.info("SimTester: Creating a delayed invocation");
34: String uuid = m_sim.createDelayedInvocation(m_timeService
35: .newTime(), "scheduledInvocationTestCommand",
36: "Hello World!");
37:
38: try {
39: Thread.sleep(30000);
40: } catch (InterruptedException e) {
41: // TODO Auto-generated catch block
42: e.printStackTrace();
43: }
44:
45: LOG.info("SimTester: Deleting invocation [" + uuid + "]");
46: m_sim.deleteDelayedInvocation(uuid);
47:
48: LOG.info("SimTester: Creating another delayed invocation");
49: uuid = m_sim.createDelayedInvocation(m_timeService.newTime(),
50: "scheduledInvocationTestCommand", "Hello World!");
51:
52: }
53:
54: }
|