summaryrefslogtreecommitdiff
path: root/same
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-13 11:17:08 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-13 11:17:08 +0100
commit2c65e30cc9b54e61fbe3617b67dd462a90ece36c (patch)
treedc32f81f3551b21a0fede5b43dcbbc8d2bedb0fa /same
parent67c7a243f41c759abd7b38e712e49cd3e1221772 (diff)
Add MasterServiceProxy.
This class can be used to enable and disable a master.
Diffstat (limited to 'same')
-rw-r--r--same/src/main/java/com/orbekk/same/MasterServiceProxy.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/same/src/main/java/com/orbekk/same/MasterServiceProxy.java b/same/src/main/java/com/orbekk/same/MasterServiceProxy.java
new file mode 100644
index 0000000..0532d86
--- /dev/null
+++ b/same/src/main/java/com/orbekk/same/MasterServiceProxy.java
@@ -0,0 +1,45 @@
+package com.orbekk.same;
+
+public class MasterServiceProxy implements MasterService {
+ public static class MasterDeactivatedException extends Exception {
+ public MasterDeactivatedException() {
+ }
+ }
+
+ private MasterService masterService = null;
+
+ public MasterServiceProxy() {
+ }
+
+ public MasterServiceProxy(MasterService masterService) {
+ this.masterService = masterService;
+ }
+
+ public MasterService getService() {
+ return masterService;
+ }
+
+ public void setService(MasterService masterService) {
+ this.masterService = masterService;
+ }
+
+ @Override
+ public void joinNetworkRequest(String clientUrl) throws Exception {
+ if (masterService != null) {
+ masterService.joinNetworkRequest(clientUrl);
+ } else {
+ throw new MasterDeactivatedException();
+ }
+ }
+
+ @Override
+ public boolean updateStateRequest(String component, String newData, long revision)
+ throws Exception {
+ if (masterService != null) {
+ return masterService.updateStateRequest(component, newData, revision);
+ } else {
+ throw new MasterDeactivatedException();
+ }
+ }
+
+}