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.util.Properties;
19:
20: import javax.sql.DataSource;
21:
22: import org.quartz.Scheduler;
23: import org.quartz.SchedulerException;
24:
25: /**
26: * This class wraps the spring version to allow deploy time determinination of whether to actually create a scheduler and whether to
27: * use the jdbc or ram job store.
28: */
29: public class SchedulerFactoryBean extends
30: org.springframework.scheduling.quartz.SchedulerFactoryBean {
31: private static final Scheduler SCHEDULER_DUMMY = new SchedulerDummy();
32: private boolean useQuartzScheduling;
33: private boolean useJdbcJobstore;
34: private DataSource dataSourceReference;
35: private Properties quartzPropertiesReference;
36:
37: @Override
38: public void destroy() throws SchedulerException {
39: if (useQuartzScheduling) {
40: super .destroy();
41: }
42: }
43:
44: public void afterPropertiesSet() throws Exception {
45: if (useQuartzScheduling) {
46: if (useJdbcJobstore) {
47: quartzPropertiesReference.put(
48: "org.quartz.jobStore.useProperties", "false");
49: setDataSource(dataSourceReference);
50: }
51: setQuartzProperties(quartzPropertiesReference);
52: super .afterPropertiesSet();
53: }
54: }
55:
56: public Object getObject() {
57: if (useQuartzScheduling) {
58: return super .getObject();
59: }
60: return SCHEDULER_DUMMY;
61: }
62:
63: /**
64: * Sets the dataSourceReference attribute value.
65: *
66: * @param dataSourceReference The dataSourceReference to set.
67: */
68: public void setDataSourceReference(DataSource dataSourceReference) {
69: this .dataSourceReference = dataSourceReference;
70: }
71:
72: /**
73: * Sets the useJdbcJobstore attribute value.
74: *
75: * @param useJdbcJobstore The useJdbcJobstore to set.
76: */
77: public void setUseJdbcJobstore(boolean useJdbcJobstore) {
78: this .useJdbcJobstore = useJdbcJobstore;
79: }
80:
81: /**
82: * Sets the useQuartzScheduling attribute value.
83: *
84: * @param useQuartzScheduling The useQuartzScheduling to set.
85: */
86: public void setUseQuartzScheduling(boolean useQuartzScheduling) {
87: this .useQuartzScheduling = useQuartzScheduling;
88: }
89:
90: /**
91: * Sets the quartzPropertiesReference attribute value.
92: *
93: * @param quartzPropertiesReference The quartzPropertiesReference to set.
94: */
95: public void setQuartzPropertiesReference(
96: Properties quartzPropertiesReference) {
97: this.quartzPropertiesReference = quartzPropertiesReference;
98: }
99: }
|