1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.rawdata.logging;
19
20 import java.util.LinkedList;
21 import java.util.List;
22
23 import org.apache.log4j.Logger;
24 import org.eclipse.core.runtime.Assert;
25
26 import pl.edu.agh.cast.model.base.BasePlugin;
27
28
29
30
31
32
33 public abstract class AbstractRawDataMonitorable implements IRawDataMonitorable {
34
35 private static Logger log = BasePlugin.getLogger();
36
37 private List<IRawDataObserver> observers;
38
39
40
41
42 public AbstractRawDataMonitorable() {
43 observers = new LinkedList<IRawDataObserver>();
44 }
45
46
47
48
49
50
51
52
53 public void registerObserver(IRawDataObserver observer) {
54 Assert.isNotNull(observer, "Cannot register null value register");
55 if (!observers.contains(observer)) {
56 observers.add(observer);
57 log.debug("The following observer has been registered: "
58 + observer.toString());
59 }
60
61 }
62
63
64
65
66
67
68
69
70 public void unregisterObserver(IRawDataObserver observer) {
71 Assert.isNotNull(observer, "Cannot unregister null value register");
72 observers.remove(observer);
73 log.debug("The following observer has been unregistered: "
74 + observer.toString());
75
76 }
77
78 protected List<IRawDataObserver> getObservers() {
79 return observers;
80 }
81
82 }