1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.config; |
18 | |
|
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.kuali.rice.core.api.config.module.RunMode; |
21 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
22 | |
import org.kuali.rice.core.api.lifecycle.Lifecycle; |
23 | |
import org.kuali.rice.core.api.resourceloader.ResourceLoader; |
24 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
25 | |
import org.kuali.rice.core.impl.config.module.ModuleConfigurer; |
26 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
27 | |
import org.kuali.rice.core.api.resourceloader.ResourceLoader; |
28 | |
import org.kuali.rice.core.impl.resourceloader.RiceResourceLoaderFactory; |
29 | |
import org.kuali.rice.core.impl.resourceloader.RiceResourceLoaderFactory; |
30 | |
import org.kuali.rice.kew.lifecycle.EmbeddedLifeCycle; |
31 | |
import org.kuali.rice.kew.plugin.PluginRegistry; |
32 | |
import org.kuali.rice.kew.plugin.PluginRegistryFactory; |
33 | |
import org.kuali.rice.kew.resourceloader.CoreResourceLoader; |
34 | |
import org.kuali.rice.kew.util.KEWConstants.ClientProtocol; |
35 | |
|
36 | |
import javax.sql.DataSource; |
37 | |
import java.util.ArrayList; |
38 | |
import java.util.Collection; |
39 | |
import java.util.Collections; |
40 | |
import java.util.LinkedList; |
41 | |
import java.util.List; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | 0 | public class KEWConfigurer extends ModuleConfigurer { |
61 | |
|
62 | |
public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource"; |
63 | |
|
64 | |
private DataSource dataSource; |
65 | |
|
66 | |
@Override |
67 | |
public List<String> getPrimarySpringFiles() { |
68 | |
final List<String> springFileLocations; |
69 | 0 | if (RunMode.REMOTE.equals(getRunMode()) || RunMode.THIN.equals(getRunMode()) || |
70 | |
ClientProtocol.WEBSERVICE.equals(getClientProtocol())) { |
71 | 0 | springFileLocations = Collections.emptyList(); |
72 | |
} else { |
73 | 0 | springFileLocations = getEmbeddedSpringFileLocation(); |
74 | |
} |
75 | |
|
76 | 0 | return springFileLocations; |
77 | |
} |
78 | |
|
79 | |
private List<String> getEmbeddedSpringFileLocation(){ |
80 | 0 | final List<String> springFileLocations = new ArrayList<String>(); |
81 | 0 | springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWSpringBeans.xml"); |
82 | |
|
83 | 0 | if ( isExposeServicesOnBus() ) { |
84 | 0 | if (isSetSOAPServicesAsDefault()) { |
85 | 0 | springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWServiceBusSOAPDefaultSpringBeans.xml"); |
86 | |
} else { |
87 | 0 | springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWServiceBusSpringBeans.xml"); |
88 | |
} |
89 | |
} |
90 | |
|
91 | 0 | if (OrmUtils.isJpaEnabled("rice.kew")) { |
92 | 0 | springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWJPASpringBeans.xml"); |
93 | |
} |
94 | |
else { |
95 | 0 | springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWOJBSpringBeans.xml"); |
96 | |
} |
97 | |
|
98 | 0 | return springFileLocations; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public List<Lifecycle> loadLifecycles() throws Exception { |
103 | |
|
104 | 0 | List<Lifecycle> lifecycles = new LinkedList<Lifecycle>(); |
105 | 0 | if ( getRunMode().equals( RunMode.THIN ) ) { |
106 | 0 | lifecycles.add(createThinClientLifecycle()); |
107 | 0 | } else if ( !getRunMode().equals( RunMode.REMOTE ) ) { |
108 | 0 | lifecycles.add(createEmbeddedLifeCycle()); |
109 | |
} |
110 | 0 | return lifecycles; |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
private Lifecycle createEmbeddedLifeCycle() throws Exception { |
120 | 0 | return new EmbeddedLifeCycle(); |
121 | |
} |
122 | |
|
123 | |
private Lifecycle createThinClientLifecycle() throws Exception { |
124 | 0 | return new ThinClientLifecycle(); |
125 | |
} |
126 | |
|
127 | |
@Override |
128 | |
public void addAdditonalToConfig() { |
129 | 0 | configureDataSource(); |
130 | 0 | } |
131 | |
|
132 | |
private void configureDataSource() { |
133 | 0 | if (getDataSource() != null) { |
134 | 0 | ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource()); |
135 | |
} |
136 | 0 | } |
137 | |
|
138 | |
@Override |
139 | |
public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception { |
140 | |
|
141 | 0 | PluginRegistry registry = null; |
142 | 0 | String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled"); |
143 | 0 | if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) { |
144 | 0 | registry = new PluginRegistryFactory().createPluginRegistry(); |
145 | |
} |
146 | |
|
147 | 0 | final Collection<ResourceLoader> rls = new ArrayList<ResourceLoader>(); |
148 | 0 | for (ResourceLoader rl : RiceResourceLoaderFactory.getSpringResourceLoaders()) { |
149 | 0 | CoreResourceLoader coreResourceLoader = |
150 | |
new CoreResourceLoader(rl, registry); |
151 | 0 | coreResourceLoader.start(); |
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | 0 | GlobalResourceLoader.addResourceLoader(coreResourceLoader); |
158 | |
|
159 | |
|
160 | 0 | if (registry != null) { |
161 | 0 | registry.start(); |
162 | |
|
163 | |
|
164 | |
} |
165 | 0 | rls.add(coreResourceLoader); |
166 | 0 | } |
167 | |
|
168 | 0 | return rls; |
169 | |
} |
170 | |
|
171 | |
private ClientProtocol getClientProtocol() { |
172 | 0 | return ClientProtocol.valueOf(ConfigContext.getCurrentContextConfig().getProperty("client.protocol")); |
173 | |
} |
174 | |
|
175 | |
public DataSource getDataSource() { |
176 | 0 | return dataSource; |
177 | |
} |
178 | |
|
179 | |
public void setDataSource(DataSource dataSource) { |
180 | 0 | this.dataSource = dataSource; |
181 | 0 | } |
182 | |
} |