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
54 public class KEWConfigurer extends ModuleConfigurer {
55
56 public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource";
57
58 private DataSource dataSource;
59
60 public KEWConfigurer() {
61 super(KewApiConstants.Namespaces.MODULE_NAME);
62 setValidRunModes(Arrays.asList(RunMode.THIN, RunMode.REMOTE, RunMode.EMBEDDED, RunMode.LOCAL));
63 }
64
65 @Override
66 public List<String> getPrimarySpringFiles() {
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
83 List<Lifecycle> lifecycles = new LinkedList<Lifecycle>();
84 if ( getRunMode().equals( RunMode.LOCAL ) ) {
85 lifecycles.add(createStandaloneLifeCycle());
86 }
87 return lifecycles;
88 }
89
90
91
92
93
94
95
96 private Lifecycle createStandaloneLifeCycle() throws Exception {
97 return new StandaloneLifeCycle();
98 }
99
100 @Override
101 public void addAdditonalToConfig() {
102 configureDataSource();
103 }
104
105 private void configureDataSource() {
106 if (getDataSource() != null) {
107 ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource());
108 }
109 }
110
111 @Override
112 public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception {
113 List<ResourceLoader> resourceLoaders = new ArrayList<ResourceLoader>();
114 String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled");
115 if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) {
116
117 PluginRegistry registry = new PluginRegistryFactory().createPluginRegistry();
118 registry.start();
119 resourceLoaders.add(registry);
120 }
121 return resourceLoaders;
122 }
123
124 public DataSource getDataSource() {
125 return dataSource;
126 }
127
128 public void setDataSource(DataSource dataSource) {
129 this.dataSource = dataSource;
130 }
131
132 @Override
133 public boolean hasWebInterface() {
134 return true;
135 }
136
137 @Override
138 protected WebModuleConfiguration loadWebModule() {
139 WebModuleConfiguration configuration = super.loadWebModule();
140 configuration.setWebSpringFiles(Arrays.asList(getDefaultConfigPackagePath() + "KewWebSpringBeans.xml"));
141 return configuration;
142 }
143 }