summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/same/MasterServiceProxy.java
blob: 0532d86d671f654ba3d6bd9c841b7ad7324f1580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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();
        }
    }
    
}