1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.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.config.module.ModuleConfigurer;
24 import org.kuali.rice.core.framework.config.module.WebModuleConfiguration;
25 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
26 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
27 import org.kuali.rice.core.framework.resourceloader.RiceResourceLoaderFactory;
28 import org.kuali.rice.kew.api.KewApiConstants;
29 import org.kuali.rice.kew.lifecycle.EmbeddedLifeCycle;
30 import org.kuali.rice.kew.plugin.PluginRegistry;
31 import org.kuali.rice.kew.plugin.PluginRegistryFactory;
32 import org.kuali.rice.kew.resourceloader.CoreResourceLoader;
33 import org.kuali.rice.kew.api.KewApiConstants.ClientProtocol;
34
35 import javax.sql.DataSource;
36 import java.util.ArrayList;
37 import java.util.Arrays;
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 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 public KEWConfigurer() {
67 super(KewApiConstants.Namespaces.MODULE_NAME);
68 setValidRunModes(Arrays.asList(RunMode.THIN, RunMode.REMOTE, RunMode.EMBEDDED, RunMode.LOCAL));
69 }
70
71 @Override
72 public List<String> getPrimarySpringFiles() {
73 List<String> springFileLocations = new ArrayList<String>();
74 if (RunMode.THIN == getRunMode()) {
75 springFileLocations.add(getDefaultConfigPackagePath() + "KewThinSpringBeans.xml");
76 } else if (RunMode.REMOTE == getRunMode()) {
77 springFileLocations.add(getDefaultConfigPackagePath() + "KewRemoteSpringBeans.xml");
78 } else if (RunMode.EMBEDDED == getRunMode()) {
79 springFileLocations.add(getDefaultConfigPackagePath() + "KewEmbeddedSpringBeans.xml");
80 } else if (RunMode.LOCAL == getRunMode()) {
81 springFileLocations.add(getDefaultConfigPackagePath() + "KewLocalSpringBeans.xml");
82 }
83 return springFileLocations;
84 }
85
86 @Override
87 public List<Lifecycle> loadLifecycles() throws Exception {
88
89 List<Lifecycle> lifecycles = new LinkedList<Lifecycle>();
90 if ( !getRunMode().equals( RunMode.REMOTE ) ) {
91 lifecycles.add(createEmbeddedLifeCycle());
92 }
93 return lifecycles;
94 }
95
96
97
98
99
100
101
102 private Lifecycle createEmbeddedLifeCycle() throws Exception {
103 return new EmbeddedLifeCycle();
104 }
105
106 @Override
107 public void addAdditonalToConfig() {
108 configureDataSource();
109 }
110
111 private void configureDataSource() {
112 if (getDataSource() != null) {
113 ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource());
114 }
115 }
116
117 @Override
118 public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception {
119 List<ResourceLoader> resourceLoaders = new ArrayList<ResourceLoader>();
120 String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled");
121 if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) {
122
123 PluginRegistry registry = new PluginRegistryFactory().createPluginRegistry();
124 registry.start();
125 resourceLoaders.add(registry);
126 }
127 return resourceLoaders;
128 }
129
130 public DataSource getDataSource() {
131 return dataSource;
132 }
133
134 public void setDataSource(DataSource dataSource) {
135 this.dataSource = dataSource;
136 }
137
138 @Override
139 public boolean hasWebInterface() {
140 return true;
141 }
142
143 @Override
144 protected WebModuleConfiguration loadWebModule() {
145 WebModuleConfiguration configuration = super.loadWebModule();
146 configuration.setWebSpringFiles(Arrays.asList(getDefaultConfigPackagePath() + "KewWebSpringBeans.xml"));
147 return configuration;
148 }
149 }