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 | 0 | public class RunModeServiceExporter extends PropertyConditionalKSBExporter { |
40 | |
|
41 | |
private String runModePropertyName; |
42 | |
private String validRunMode; |
43 | 0 | private static final List<String> runModeHierarchy = new ArrayList<String>(); |
44 | |
static { |
45 | 0 | runModeHierarchy.add(ModuleConfigurer.THIN_RUN_MODE); |
46 | 0 | runModeHierarchy.add(ModuleConfigurer.REMOTE_RUN_MODE); |
47 | 0 | runModeHierarchy.add(ModuleConfigurer.EMBEDDED_RUN_MODE); |
48 | 0 | runModeHierarchy.add(ModuleConfigurer.LOCAL_RUN_MODE); |
49 | 0 | } |
50 | |
|
51 | |
@Override |
52 | |
protected boolean shouldRemoteThisService() throws Exception { |
53 | 0 | if (StringUtils.isBlank(validRunMode)) { |
54 | 0 | throw new ConfigurationException("The validRunMode property was not set."); |
55 | |
} |
56 | 0 | if (!runModeHierarchy.contains(getValidRunMode())) { |
57 | 0 | throw new ConfigurationException("Given validRunMode is not a valid run mode. Value was: " + getValidRunMode()); |
58 | |
} |
59 | 0 | String runModePropertyValue = ConfigContext.getCurrentContextConfig().getProperty(getRunModePropertyName()); |
60 | 0 | if (StringUtils.isBlank(runModePropertyValue)) { |
61 | 0 | throw new ConfigurationException("Given runModePropertyName does not have a value. The runModePropertyName was " + getRunModePropertyName()); |
62 | |
} |
63 | 0 | if (!runModeHierarchy.contains(runModePropertyValue)) { |
64 | 0 | throw new ConfigurationException("Run mode value set on runModePropertyName of '" + getRunModePropertyName() + "' is not a valid run mode. Value was: " + runModePropertyValue); |
65 | |
} |
66 | 0 | List<String> validRunModeSubList = runModeHierarchy.subList(runModeHierarchy.indexOf(getValidRunMode()), runModeHierarchy.size()); |
67 | 0 | return validRunModeSubList.contains(runModePropertyValue) && super.shouldRemoteThisService(); |
68 | |
} |
69 | |
|
70 | |
public String getRunModePropertyName() { |
71 | 0 | return this.runModePropertyName; |
72 | |
} |
73 | |
|
74 | |
public void setRunModePropertyName(String runModePropertyName) { |
75 | 0 | this.runModePropertyName = runModePropertyName; |
76 | 0 | } |
77 | |
|
78 | |
public String getValidRunMode() { |
79 | 0 | return this.validRunMode; |
80 | |
} |
81 | |
|
82 | |
public void setValidRunMode(String validRunMode) { |
83 | 0 | this.validRunMode = validRunMode; |
84 | 0 | } |
85 | |
|
86 | |
} |