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 org.kuali.core.service.DateTimeService;
19: import org.quartz.CronTrigger;
20: import org.quartz.SimpleTrigger;
21: import org.quartz.Trigger;
22: import org.springframework.beans.factory.BeanNameAware;
23:
24: public abstract class TriggerDescriptor implements BeanNameAware {
25: private String name;
26: private String group;
27: private String jobName;
28: private DateTimeService dateTimeService;
29: private boolean testMode = false;
30:
31: protected abstract void completeTriggerDescription(Trigger trigger);
32:
33: public Trigger getTrigger() {
34: Trigger trigger = null;
35: if (getClass().equals(SimpleTriggerDescriptor.class)) {
36: trigger = new SimpleTrigger(name, group);
37: } else {
38: trigger = new CronTrigger(name, group);
39: }
40: trigger.setJobName(jobName);
41: trigger.setJobGroup(group);
42: trigger.setStartTime(dateTimeService.getCurrentDate());
43: completeTriggerDescription(trigger);
44: return trigger;
45: }
46:
47: /**
48: * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
49: */
50: public void setBeanName(String name) {
51: this .name = name;
52: }
53:
54: /**
55: * Sets the group attribute value.
56: *
57: * @param group The group to set.
58: */
59: public void setGroup(String group) {
60: this .group = group;
61: }
62:
63: /**
64: * Sets the jobName attribute value.
65: *
66: * @param jobName The jobName to set.
67: */
68: public void setJobName(String jobName) {
69: this .jobName = jobName;
70: }
71:
72: protected String getJobName() {
73: return jobName;
74: }
75:
76: /**
77: * Sets the dateTimeService attribute value.
78: *
79: * @param dateTimeService The dateTimeService to set.
80: */
81: public void setDateTimeService(DateTimeService dateTimeService) {
82: this .dateTimeService = dateTimeService;
83: }
84:
85: protected DateTimeService getDateTimeService() {
86: return dateTimeService;
87: }
88:
89: public boolean isTestMode() {
90: return testMode;
91: }
92:
93: public void setTestMode(boolean testMode) {
94: this.testMode = testMode;
95: }
96: }
|