01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.kfs.batch;
17:
18: import java.text.ParseException;
19:
20: import org.quartz.CronTrigger;
21: import org.quartz.Trigger;
22:
23: public class CronTriggerDescriptor extends TriggerDescriptor {
24: private String cronExpression;
25:
26: /**
27: * @see org.kuali.kfs.batch.TriggerDescriptor#completeTriggerDescription(org.quartz.Trigger)
28: */
29: protected void completeTriggerDescription(Trigger trigger) {
30: // prevent setting of the trigger information in test mode
31: try {
32: ((CronTrigger) trigger).setTimeZone(getDateTimeService()
33: .getCurrentCalendar().getTimeZone());
34: if (!isTestMode()) {
35: ((CronTrigger) trigger)
36: .setCronExpression(cronExpression);
37: } else {
38: ((CronTrigger) trigger)
39: .setCronExpression("0 59 23 31 12 ? 2099");
40: }
41: } catch (ParseException e) {
42: throw new RuntimeException(
43: "Caught exception while trying to set the cronExpression attribute of a CronTrigger: "
44: + getJobName(), e);
45: }
46: }
47:
48: /**
49: * Sets the cronExpression attribute value.
50: *
51: * @param cronExpression The cronExpression to set.
52: */
53: public void setCronExpression(String cronExpression) {
54: this.cronExpression = cronExpression;
55: }
56: }
|