1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.config;
17
18 import org.kuali.rice.core.api.config.module.RunMode;
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.core.framework.config.module.ModuleConfigurer;
21 import org.kuali.rice.core.framework.config.module.WebModuleConfiguration;
22 import org.kuali.rice.kim.api.KimApiConstants;
23
24 import javax.sql.DataSource;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28
29
30
31
32
33
34
35 public class KIMConfigurer extends ModuleConfigurer {
36 public static final String KIM_DATASOURCE_OBJ = "kim.datasource";
37 private static final String KIM_UI_SPRING_BEANS_PATH = "classpath:org/kuali/rice/kim/impl/config/KimWebSpringBeans.xml";
38 private DataSource dataSource;
39
40 public KIMConfigurer() {
41 super(KimApiConstants.Namespaces.MODULE_NAME);
42 setValidRunModes(Arrays.asList(RunMode.THIN, RunMode.REMOTE, RunMode.EMBEDDED, RunMode.LOCAL));
43 }
44
45 @Override
46 protected String getDefaultConfigPackagePath() {
47 return "classpath:org/kuali/rice/kim/impl/config/";
48 }
49
50 @Override
51 public List<String> getPrimarySpringFiles() {
52 LOG.info("KIMConfigurer:getPrimarySpringFiles: getRunMode => " + getRunMode());
53 List<String> springFileLocations = new ArrayList<String>();
54 if (RunMode.THIN == getRunMode()) {
55 springFileLocations.add(getDefaultConfigPackagePath() + "KimThinSpringBeans.xml");
56 } else if (RunMode.REMOTE == getRunMode()) {
57 springFileLocations.add(getDefaultConfigPackagePath() + "KimRemoteSpringBeans.xml");
58 } else if (RunMode.EMBEDDED == getRunMode()) {
59 springFileLocations.add(getDefaultConfigPackagePath() + "KimEmbeddedSpringBeans.xml");
60 } else if (RunMode.LOCAL == getRunMode()) {
61 springFileLocations.add(getDefaultConfigPackagePath() + "KimLocalSpringBeans.xml");
62 }
63 return springFileLocations;
64 }
65
66 @Override
67 public void addAdditonalToConfig() {
68 configureDataSource();
69 }
70
71 private void configureDataSource() {
72 if (getDataSource() != null) {
73 ConfigContext.getCurrentContextConfig().putObject(KIM_DATASOURCE_OBJ, getDataSource());
74 }
75 }
76
77 public DataSource getDataSource() {
78 return dataSource;
79 }
80
81 public void setDataSource(DataSource dataSource) {
82 this.dataSource = dataSource;
83 }
84
85 @Override
86 public boolean hasWebInterface() {
87 return true;
88 }
89
90 @Override
91 protected WebModuleConfiguration loadWebModule() {
92 WebModuleConfiguration configuration = super.loadWebModule();
93 configuration.setWebSpringFiles(Arrays.asList(KIM_UI_SPRING_BEANS_PATH));
94 return configuration;
95 }
96 }