1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.quartz;
17
18 import org.kuali.rice.core.api.config.property.ConfigContext;
19 import org.kuali.rice.ksb.util.KSBConstants;
20 import org.springframework.beans.factory.config.AbstractFactoryBean;
21
22 import java.util.Properties;
23
24
25
26
27
28
29
30
31 public class QuartzConfigPropertiesFactoryBean extends AbstractFactoryBean {
32
33 private static final String QUARTZ_PREFIX = "ksb.org.quartz";
34 private static final String QUARTZ_IS_CLUSTERED = QUARTZ_PREFIX + ".jobStore.isClustered";
35 private static final String QUARTZ_TABLE_PREFIX = QUARTZ_PREFIX + ".jobStore.tablePrefix";
36
37
38 private static final String QUARTZ_DRIVER_DELEGATE_CLASS = QUARTZ_PREFIX + ".jobStore.driverDelegateClass";
39
40 @Override
41 protected Object createInstance() throws Exception {
42 Properties properties = new Properties();
43 Properties configProps = ConfigContext.getCurrentContextConfig().getProperties();
44 boolean useQuartzDatabase = Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.USE_QUARTZ_DATABASE));
45 for (Object keyObj : configProps.keySet()) {
46 if (keyObj instanceof String) {
47 String key = (String)keyObj;
48 if (key.startsWith(QUARTZ_PREFIX) && !propertyShouldBeFiltered(useQuartzDatabase, key)) {
49 properties.put(key.substring(4), configProps.get(key));
50 }
51 }
52 }
53 return properties;
54 }
55
56
57
58
59
60
61
62 protected boolean propertyShouldBeFiltered(boolean useQuartzDatabase, String propertyName) {
63 if (!useQuartzDatabase) {
64 if (propertyName.startsWith(QUARTZ_TABLE_PREFIX) || propertyName.startsWith(QUARTZ_IS_CLUSTERED) || propertyName.startsWith(QUARTZ_DRIVER_DELEGATE_CLASS)) {
65 return true;
66 }
67 }
68 return false;
69 }
70
71
72 @Override
73 public Class getObjectType() {
74 return Properties.class;
75 }
76
77 }