1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.edl.impl.config;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.config.module.RunMode;
20 import org.kuali.rice.core.api.config.property.ConfigContext;
21 import org.kuali.rice.core.api.lifecycle.Lifecycle;
22 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
23 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
24 import org.kuali.rice.core.impl.config.module.ModuleConfigurer;
25 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
26 import org.kuali.rice.core.impl.resourceloader.RiceResourceLoaderFactory;
27 import org.kuali.rice.kew.lifecycle.EmbeddedLifeCycle;
28 import org.kuali.rice.kew.plugin.PluginRegistry;
29 import org.kuali.rice.kew.plugin.PluginRegistryFactory;
30 import org.kuali.rice.kew.resourceloader.CoreResourceLoader;
31 import org.kuali.rice.kew.api.KewApiConstants.ClientProtocol;
32
33 import javax.sql.DataSource;
34 import java.util.ArrayList;
35 import java.util.Collection;
36 import java.util.Collections;
37 import java.util.LinkedList;
38 import java.util.List;
39
40
41
42
43
44
45
46 public class EDLConfigurer extends ModuleConfigurer {
47
48 public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource";
49
50 private DataSource dataSource;
51
52 @Override
53 public List<String> getPrimarySpringFiles() {
54 final List<String> springFileLocations;
55
56
57
58
59 springFileLocations = getEmbeddedSpringFileLocation();
60
61
62 return springFileLocations;
63 }
64
65 private List<String> getEmbeddedSpringFileLocation(){
66 final List<String> springFileLocations = new ArrayList<String>();
67 springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLSpringBeans.xml");
68
69
70
71
72
73
74
75
76
77
78
79
80
81 springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLOJBSpringBeans.xml");
82
83
84 return springFileLocations;
85 }
86
87 @Override
88 public void addAdditonalToConfig() {
89 configureDataSource();
90 }
91
92 private void configureDataSource() {
93 if (getDataSource() != null) {
94 ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource());
95 }
96 }
97
98 @Override
99 public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception {
100
101 PluginRegistry registry = null;
102 String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled");
103 if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) {
104 registry = new PluginRegistryFactory().createPluginRegistry();
105 }
106
107 final Collection<ResourceLoader> rls = new ArrayList<ResourceLoader>();
108 for (ResourceLoader rl : RiceResourceLoaderFactory.getSpringResourceLoaders()) {
109 CoreResourceLoader coreResourceLoader =
110 new CoreResourceLoader(rl, registry);
111 coreResourceLoader.start();
112
113
114
115
116
117 GlobalResourceLoader.addResourceLoader(coreResourceLoader);
118
119
120 if (registry != null) {
121 registry.start();
122
123
124 }
125 rls.add(coreResourceLoader);
126 }
127
128 return rls;
129 }
130
131 private ClientProtocol getClientProtocol() {
132 return ClientProtocol.valueOf(ConfigContext.getCurrentContextConfig().getProperty("client.protocol"));
133 }
134
135 public DataSource getDataSource() {
136 return dataSource;
137 }
138
139 public void setDataSource(DataSource dataSource) {
140 this.dataSource = dataSource;
141 }
142 }