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 List<String> springFileLocations = new ArrayList<String>();
53 if (RunMode.THIN == getRunMode()) {
54 springFileLocations.add(getDefaultConfigPackagePath() + "KimThinSpringBeans.xml");
55 } else if (RunMode.REMOTE == getRunMode()) {
56 springFileLocations.add(getDefaultConfigPackagePath() + "KimRemoteSpringBeans.xml");
57 } else if (RunMode.EMBEDDED == getRunMode()) {
58 springFileLocations.add(getDefaultConfigPackagePath() + "KimEmbeddedSpringBeans.xml");
59 } else if (RunMode.LOCAL == getRunMode()) {
60 springFileLocations.add(getDefaultConfigPackagePath() + "KimLocalSpringBeans.xml");
61 }
62 return springFileLocations;
63 }
64
65 @Override
66 public void addAdditonalToConfig() {
67 configureDataSource();
68 }
69
70 private void configureDataSource() {
71 if (getDataSource() != null) {
72 ConfigContext.getCurrentContextConfig().putObject(KIM_DATASOURCE_OBJ, getDataSource());
73 }
74 }
75
76 public DataSource getDataSource() {
77 return dataSource;
78 }
79
80 public void setDataSource(DataSource dataSource) {
81 this.dataSource = dataSource;
82 }
83 @Override
84 public boolean hasWebInterface() {
85 return true;
86 }
87
88 @Override
89 protected WebModuleConfiguration loadWebModule() {
90 WebModuleConfiguration configuration = super.loadWebModule();
91 configuration.setWebSpringFiles(Arrays.asList(KIM_UI_SPRING_BEANS_PATH));
92 return configuration;
93 }
94 }