1 package org.csc.phynixx.watchdog;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import java.util.Set;
25
26
27
28
29
30
31 public class WatchdogReference implements IWatchdog {
32
33 private Long id = null;
34
35 public WatchdogReference(Long id) {
36 super();
37 this.id = id;
38 }
39
40
41 public WatchdogReference(IWatchdog wd) {
42 this(wd.getId());
43 }
44
45 public Long getId() {
46 return id;
47 }
48
49
50 Watchdog getWatchdog() {
51 Watchdog wd =
52 WatchdogRegistry.getTheRegistry().findWatchdog(id);
53 if (wd == null) {
54 throw new IllegalStateException("Watchdog is stale and does not exist any longer");
55 }
56 return wd;
57 }
58
59 public boolean isStale() {
60 return WatchdogRegistry.getTheRegistry().findWatchdog(id) == null;
61 }
62
63
64 public void activate() {
65 this.getWatchdog().activate();
66 }
67
68
69 public void deactivate() {
70 this.getWatchdog().deactivate();
71
72 }
73
74
75 public Set<IWatchedCondition> getAliveConditions() {
76 return this.getWatchdog().getAliveConditions();
77 }
78
79
80 public long getCheckInterval() {
81 return this.getWatchdog().getCheckInterval();
82 }
83
84
85 public String[] getConditionInfos() {
86 return this.getWatchdog().getConditionInfos();
87 }
88
89
90 public int getCountRegisteredConditions() {
91 return this.getWatchdog().getCountRegisteredConditions();
92 }
93
94
95 public String getWatchdogInfo() {
96 return this.getWatchdog().getWatchdogInfo();
97 }
98
99
100 public boolean isAlive() {
101 return this.getWatchdog().isAlive();
102 }
103
104
105 public boolean isKilled() {
106 return this.getWatchdog().isKilled();
107 }
108
109
110 public boolean isUseless() {
111 return this.getWatchdog().isUseless();
112 }
113
114
115 public void registerCondition(IWatchedCondition cond) {
116 this.getWatchdog().registerCondition(cond);
117
118 }
119
120
121 public void unregisterCondition(IWatchedCondition cond) {
122 this.getWatchdog().unregisterCondition(cond);
123 }
124
125 }