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.kuali.rice.core.api.config.ConfigurationException; |
23 | |
import org.kuali.rice.core.api.config.module.RunMode; |
24 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
25 | |
import org.kuali.rice.ksb.api.bus.support.PropertyConditionalServiceBusExporter; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class RunModeServiceExporter extends PropertyConditionalServiceBusExporter { |
40 | |
|
41 | |
private String runModePropertyName; |
42 | |
private RunMode validRunMode; |
43 | 0 | private static final List<RunMode> runModeHierarchy = new ArrayList<RunMode>(); |
44 | |
static { |
45 | 0 | runModeHierarchy.add(RunMode.THIN); |
46 | 0 | runModeHierarchy.add(RunMode.REMOTE); |
47 | 0 | runModeHierarchy.add(RunMode.EMBEDDED); |
48 | 0 | runModeHierarchy.add(RunMode.LOCAL); |
49 | 0 | } |
50 | |
|
51 | |
@Override |
52 | |
protected boolean shouldRemoteThisService() { |
53 | 0 | if (validRunMode == null) { |
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 | RunMode runModePropertyValue = RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(getRunModePropertyName())); |
60 | |
|
61 | 0 | if (!runModeHierarchy.contains(runModePropertyValue)) { |
62 | 0 | throw new ConfigurationException("Run mode value set on runModePropertyName of '" + getRunModePropertyName() + "' is not a valid run mode. Value was: " + runModePropertyValue); |
63 | |
} |
64 | 0 | List<RunMode> validRunModeSubList = runModeHierarchy.subList(runModeHierarchy.indexOf(getValidRunMode()), runModeHierarchy.size()); |
65 | 0 | return validRunModeSubList.contains(runModePropertyValue) && super.shouldRemoteThisService(); |
66 | |
} |
67 | |
|
68 | |
public String getRunModePropertyName() { |
69 | 0 | return this.runModePropertyName; |
70 | |
} |
71 | |
|
72 | |
public void setRunModePropertyName(String runModePropertyName) { |
73 | 0 | this.runModePropertyName = runModePropertyName; |
74 | 0 | } |
75 | |
|
76 | |
public RunMode getValidRunMode() { |
77 | 0 | return this.validRunMode; |
78 | |
} |
79 | |
|
80 | |
public void setValidRunMode(RunMode validRunMode) { |
81 | 0 | this.validRunMode = validRunMode; |
82 | 0 | } |
83 | |
|
84 | |
} |