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