1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.batch;
17
18 import java.util.Properties;
19
20 import javax.sql.DataSource;
21
22 import org.kuali.rice.core.api.config.property.ConfigContext;
23 import org.kuali.rice.core.api.util.RiceConstants;
24 import org.kuali.rice.ksb.messaging.quartz.MessageServiceExecutorJobListener;
25 import org.quartz.Scheduler;
26 import org.quartz.SchedulerException;
27 import org.quartz.SchedulerFactory;
28
29
30
31
32
33 public class SchedulerFactoryBean extends org.springframework.scheduling.quartz.SchedulerFactoryBean {
34 private static final Scheduler SCHEDULER_DUMMY = new SchedulerDummy();
35 private boolean useQuartzScheduling;
36 private boolean useJdbcJobstore;
37 private Properties quartzPropertiesReference;
38
39 @Override
40 public void destroy() throws SchedulerException {
41 if (useQuartzScheduling) {
42 super.destroy();
43 }
44 }
45
46 @Override
47 public void afterPropertiesSet() throws Exception {
48 if (useQuartzScheduling) {
49 if (useJdbcJobstore) {
50 quartzPropertiesReference.put("org.quartz.jobStore.useProperties", "false");
51 quartzPropertiesReference.put("org.quartz.jobStore.isClustered", "true");
52 setDataSource((DataSource) ConfigContext.getCurrentContextConfig().getObject(RiceConstants.DATASOURCE_OBJ));
53 setNonTransactionalDataSource((DataSource) ConfigContext.getCurrentContextConfig().getObject(RiceConstants.NON_TRANSACTIONAL_DATASOURCE_OBJ));
54 }
55 setQuartzProperties(quartzPropertiesReference);
56 super.afterPropertiesSet();
57 }
58 }
59
60 @Override
61 public Scheduler getObject() {
62 if (useQuartzScheduling) {
63 return super.getObject();
64 }
65 return SCHEDULER_DUMMY;
66 }
67
68
69
70
71 @Override
72 protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) throws SchedulerException {
73 Scheduler scheduler = super.createScheduler(schedulerFactory, schedulerName);
74 scheduler.addJobListener(new MessageServiceExecutorJobListener());
75 return scheduler;
76 }
77
78
79
80
81
82
83 public void setUseJdbcJobstore(boolean useJdbcJobstore) {
84 this.useJdbcJobstore = useJdbcJobstore;
85 }
86
87
88
89
90
91
92 public void setUseQuartzScheduling(boolean useQuartzScheduling) {
93 this.useQuartzScheduling = useQuartzScheduling;
94 }
95
96
97
98
99
100
101 public void setQuartzPropertiesReference(Properties quartzPropertiesReference) {
102 this.quartzPropertiesReference = quartzPropertiesReference;
103 }
104 }