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