1 package org.apache.commons.jelly.tags.quartz;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.commons.jelly.JellyContext;
20 import org.apache.commons.jelly.Script;
21 import org.apache.commons.jelly.XMLOutput;
22
23 import org.quartz.Job;
24 import org.quartz.JobDetail;
25 import org.quartz.JobDataMap;
26 import org.quartz.JobExecutionContext;
27 import org.quartz.JobExecutionException;
28
29 /*** Implementation of a quart <code>Job</code> to execute jellyscript.
30 *
31 * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
32 */
33 public class JellyJob implements Job
34 {
35
36
37
38
39 /*** Construct.
40 */
41 public JellyJob()
42 {
43
44 }
45
46
47
48
49
50
51
52
53
54 /*** Execute this job.
55 *
56 * @param jobContext Job context data.
57 *
58 * @throws JobExecutionException If an error occurs during job execution.
59 */
60 public void execute(JobExecutionContext jobContext) throws JobExecutionException
61 {
62
63 JobDetail detail = jobContext.getJobDetail();
64
65 JobDataMap data = detail.getJobDataMap();
66
67 Script script = (Script) data.get( "jelly.script" );
68
69 JellyContext jellyContext = (JellyContext) data.get( "jelly.context" );
70
71 XMLOutput output = (XMLOutput) data.get( "jelly.output" );
72
73 try
74 {
75 script.run( jellyContext,
76 output );
77 output.flush();
78 }
79 catch (Exception e)
80 {
81 e.printStackTrace();
82 throw new JobExecutionException( e,
83 false );
84 }
85 }
86 }