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.kew.api.KewApiConstants;
26 import org.kuali.rice.kew.lifecycle.StandaloneLifeCycle;
27 import org.kuali.rice.kew.plugin.PluginRegistry;
28 import org.kuali.rice.kew.plugin.PluginRegistryFactory;
29
30 import javax.sql.DataSource;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.Collection;
34 import java.util.LinkedList;
35 import java.util.List;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public class KEWConfigurer extends ModuleConfigurer {
54
55 public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource";
56
57 private DataSource dataSource;
58
59 public KEWConfigurer() {
60 super(KewApiConstants.Namespaces.MODULE_NAME);
61 setValidRunModes(Arrays.asList(RunMode.THIN, RunMode.REMOTE, RunMode.EMBEDDED, RunMode.LOCAL));
62 }
63
64 @Override
65 public List<String> getPrimarySpringFiles() {
66 LOG.info("KEWConfigurer:getPrimarySpringFiles: getRunMode => " + getRunMode());
67 List<String> springFileLocations = new ArrayList<String>();
68 if (RunMode.THIN == getRunMode()) {
69 springFileLocations.add(getDefaultConfigPackagePath() + "KewThinSpringBeans.xml");
70 } else if (RunMode.REMOTE == getRunMode()) {
71 springFileLocations.add(getDefaultConfigPackagePath() + "KewRemoteSpringBeans.xml");
72 } else if (RunMode.EMBEDDED == getRunMode()) {
73 springFileLocations.add(getDefaultConfigPackagePath() + "KewEmbeddedSpringBeans.xml");
74 } else if (RunMode.LOCAL == getRunMode()) {
75 springFileLocations.add(getDefaultConfigPackagePath() + "KewLocalSpringBeans.xml");
76 }
77 return springFileLocations;
78 }
79
80 @Override
81 public List<Lifecycle> loadLifecycles() throws Exception {
82 List<Lifecycle> lifecycles = new LinkedList<Lifecycle>();
83 if (getRunMode().equals(RunMode.LOCAL)) {
84 lifecycles.add(createStandaloneLifeCycle());
85 }
86 return lifecycles;
87 }
88
89
90
91
92
93
94
95
96
97 private Lifecycle createStandaloneLifeCycle() throws Exception {
98 return new StandaloneLifeCycle();
99 }
100
101 @Override
102 public void addAdditonalToConfig() {
103 configureDataSource();
104 }
105
106 private void configureDataSource() {
107 if (getDataSource() != null) {
108 ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource());
109 }
110 }
111
112 @Override
113 public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception {
114 List<ResourceLoader> resourceLoaders = new ArrayList<ResourceLoader>();
115 String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled");
116 if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) {
117
118 PluginRegistry registry = new PluginRegistryFactory().createPluginRegistry();
119 registry.start();
120 resourceLoaders.add(registry);
121 }
122 return resourceLoaders;
123 }
124
125 public DataSource getDataSource() {
126 return dataSource;
127 }
128
129 public void setDataSource(DataSource dataSource) {
130 this.dataSource = dataSource;
131 }
132
133 @Override
134 public boolean hasWebInterface() {
135 return true;
136 }
137
138 @Override
139 protected WebModuleConfiguration loadWebModule() {
140 WebModuleConfiguration configuration = super.loadWebModule();
141 configuration.setWebSpringFiles(Arrays.asList(getDefaultConfigPackagePath() + "KewWebSpringBeans.xml"));
142 return configuration;
143 }
144 }