1 package org.apache.commons.jelly.tags.quartz;
2
3 /*
4 * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/quartz/JobTag.java,v 1.1 2002/07/25 01:51:20 werken Exp $
5 * $Revision: 1.1 $
6 * $Date: 2002/07/25 01:51:20 $
7 *
8 * ====================================================================
9 *
10 * The Apache Software License, Version 1.1
11 *
12 * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
13 * reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in
24 * the documentation and/or other materials provided with the
25 * distribution.
26 *
27 * 3. The end-user documentation included with the redistribution, if
28 * any, must include the following acknowlegement:
29 * "This product includes software developed by the
30 * Apache Software Foundation (http://www.apache.org/)."
31 * Alternately, this acknowlegement may appear in the software itself,
32 * if and wherever such third-party acknowlegements normally appear.
33 *
34 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
35 * Foundation" must not be used to endorse or promote products derived
36 * from this software without prior written permission. For written
37 * permission, please contact apache@apache.org.
38 *
39 * 5. Products derived from this software may not be called "Apache"
40 * nor may "Apache" appear in their names without prior written
41 * permission of the Apache Group.
42 *
43 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
44 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
47 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
50 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 * ====================================================================
56 *
57 * This software consists of voluntary contributions made by many
58 * individuals on behalf of the Apache Software Foundation. For more
59 * information on the Apache Software Foundation, please see
60 * <http://www.apache.org/>.
61 *
62 */
63
64 import org.apache.commons.jelly.XMLOutput;
65 import org.apache.commons.jelly.MissingAttributeException;
66
67 import org.quartz.Scheduler;
68 import org.quartz.JobDetail;
69 import org.quartz.JobDataMap;
70
71 /*** Defines a schedulable job.
72 *
73 * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
74 */
75 public class JobTag extends QuartzTagSupport
76 {
77 // ------------------------------------------------------------
78 // Instance members
79 // ------------------------------------------------------------
80
81 /*** Group of the job. */
82 private String group;
83
84 /*** Name of the job. */
85 private String name;
86
87 // ------------------------------------------------------------
88 // Constructors
89 // ------------------------------------------------------------
90
91 /*** Construct.
92 */
93 public JobTag()
94 {
95 // intentionally left blank.
96 }
97
98 // ------------------------------------------------------------
99 // Instance methods
100 // ------------------------------------------------------------
101
102 /*** Set the name of this job.
103 *
104 * @param name The name of this job.
105 */
106 public void setName(String name)
107 {
108 this.name = name;
109 }
110
111 /*** Retrieve the name of this job.
112 *
113 * @return The name of this job.
114 */
115 public String getName()
116 {
117 return this.name;
118 }
119
120 /*** Set the group of this job.
121 *
122 * @param group The group of this job.
123 */
124 public void setGroup(String group)
125 {
126 this.group = group;
127 }
128
129 /*** Retrieve the group of this job.
130 *
131 * @return The group of this job.
132 */
133 public String getGroup()
134 {
135 return this.group;
136 }
137
138 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139 // org.apache.commons.jelly.Tag
140 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141
142 /*** Perform this tag.
143 *
144 * @param output Output sink.
145 *
146 * @throws Exception If an error occurs.
147 */
148 public void doTag(XMLOutput output) throws Exception
149 {
150 if ( getName() == null )
151 {
152 throw new MissingAttributeException( "name" );
153 }
154
155 if ( getGroup() == null )
156 {
157 throw new MissingAttributeException( "group" );
158 }
159
160 Scheduler sched = getScheduler();
161
162 JobDetail detail = new JobDetail( getName(),
163 getGroup(),
164 JellyJob.class );
165
166 detail.setDurability( true );
167
168 JobDataMap data = new JobDataMap();
169
170 data.put( "jelly.output",
171 output );
172
173 data.put( "jelly.context",
174 getContext() );
175
176 data.put( "jelly.script",
177 getBody() );
178
179 detail.setJobDataMap( data );
180
181 sched.addJob( detail,
182 true );
183 }
184 }
185
This page was automatically generated by Maven