1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.impl.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.ken.api.KenApiConstants;
22
23 import javax.sql.DataSource;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.List;
27
28 public class KENConfigurer extends ModuleConfigurer {
29 public static final String KEN_DATASOURCE_OBJ = "ken.datasource";
30 public static final String KCB_DATASOURCE_OBJ = "kcb.datasource";
31
32 private DataSource dataSource;
33
34 public KENConfigurer() {
35 super(KenApiConstants.Namespaces.MODULE_NAME);
36 setValidRunModes(Arrays.asList(RunMode.REMOTE, RunMode.LOCAL));
37 }
38
39 @Override
40 public List<String> getPrimarySpringFiles() {
41 LOG.info("KENConfigurer:getPrimarySpringFiles: getRunMode => " + getRunMode());
42 List<String> springFileLocations = new ArrayList<String>();
43 if (RunMode.REMOTE == getRunMode()) {
44 springFileLocations.add(getDefaultConfigPackagePath() + "KENRemoteSpringBeans.xml");
45 } else if (RunMode.LOCAL == getRunMode()) {
46 springFileLocations.add(getDefaultConfigPackagePath() + "KENLocalSpringBeans.xml");
47 }
48 return springFileLocations;
49 }
50
51 @Override
52 public void addAdditonalToConfig() {
53 configureDataSource();
54 }
55
56 private void configureDataSource() {
57 if (getDataSource() != null) {
58 ConfigContext.getCurrentContextConfig().putObject(KEN_DATASOURCE_OBJ, getDataSource());
59 ConfigContext.getCurrentContextConfig().putObject(KCB_DATASOURCE_OBJ, getDataSource());
60 }
61 }
62
63 public DataSource getDataSource() {
64 return dataSource;
65 }
66
67 public void setDataSource(DataSource dataSource) {
68 this.dataSource = dataSource;
69 }
70 }