1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.messaging;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.rice.core.config.ConfigContext;
24 import org.kuali.rice.core.config.ConfigurationException;
25 import org.kuali.rice.core.config.ModuleConfigurer;
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class RunModeServiceExporter extends PropertyConditionalKSBExporter {
40
41 private String runModePropertyName;
42 private String validRunMode;
43 private static final List<String> runModeHierarchy = new ArrayList<String>();
44 static {
45 runModeHierarchy.add(ModuleConfigurer.THIN_RUN_MODE);
46 runModeHierarchy.add(ModuleConfigurer.REMOTE_RUN_MODE);
47 runModeHierarchy.add(ModuleConfigurer.EMBEDDED_RUN_MODE);
48 runModeHierarchy.add(ModuleConfigurer.LOCAL_RUN_MODE);
49 }
50
51 @Override
52 protected boolean shouldRemoteThisService() throws Exception {
53 if (StringUtils.isBlank(validRunMode)) {
54 throw new ConfigurationException("The validRunMode property was not set.");
55 }
56 if (!runModeHierarchy.contains(getValidRunMode())) {
57 throw new ConfigurationException("Given validRunMode is not a valid run mode. Value was: " + getValidRunMode());
58 }
59 String runModePropertyValue = ConfigContext.getCurrentContextConfig().getProperty(getRunModePropertyName());
60 if (StringUtils.isBlank(runModePropertyValue)) {
61 throw new ConfigurationException("Given runModePropertyName does not have a value. The runModePropertyName was " + getRunModePropertyName());
62 }
63 if (!runModeHierarchy.contains(runModePropertyValue)) {
64 throw new ConfigurationException("Run mode value set on runModePropertyName of '" + getRunModePropertyName() + "' is not a valid run mode. Value was: " + runModePropertyValue);
65 }
66 List<String> validRunModeSubList = runModeHierarchy.subList(runModeHierarchy.indexOf(getValidRunMode()), runModeHierarchy.size());
67 return validRunModeSubList.contains(runModePropertyValue) && super.shouldRemoteThisService();
68 }
69
70 public String getRunModePropertyName() {
71 return this.runModePropertyName;
72 }
73
74 public void setRunModePropertyName(String runModePropertyName) {
75 this.runModePropertyName = runModePropertyName;
76 }
77
78 public String getValidRunMode() {
79 return this.validRunMode;
80 }
81
82 public void setValidRunMode(String validRunMode) {
83 this.validRunMode = validRunMode;
84 }
85
86 }