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