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 private DataSource dataSource;
31
32 public KENConfigurer() {
33 super(KenApiConstants.Namespaces.MODULE_NAME);
34 setValidRunModes(Arrays.asList(RunMode.REMOTE, RunMode.LOCAL));
35 }
36
37 @Override
38 public List<String> getPrimarySpringFiles() {
39 List<String> springFileLocations = new ArrayList<String>();
40 if (RunMode.REMOTE == getRunMode()) {
41 springFileLocations.add(getDefaultConfigPackagePath() + "KENRemoteSpringBeans.xml");
42 } else if (RunMode.LOCAL == getRunMode()) {
43 springFileLocations.add(getDefaultConfigPackagePath() + "KENLocalSpringBeans.xml");
44 }
45 return springFileLocations;
46 }
47
48 @Override
49 public void addAdditonalToConfig() {
50 configureDataSource();
51 }
52
53 private void configureDataSource() {
54 if (getDataSource() != null) {
55 ConfigContext.getCurrentContextConfig().putObject(KEN_DATASOURCE_OBJ, getDataSource());
56 }
57 }
58
59 public DataSource getDataSource() {
60 return dataSource;
61 }
62
63 public void setDataSource(DataSource dataSource) {
64 this.dataSource = dataSource;
65 }
66 }