1
2
3
4
5 package org.abraracourcix.alipes.monitors;
6 import org.abraracourcix.alipes.common.Event;
7 import org.abraracourcix.alipes.listeners.Listener;
8 import org.abraracourcix.alipes.listeners.ListenerException;
9 /***
10 *
11 * Does most of the grunt work of a monitor, signalling the listeners. Subclasses need to implement the pole
12 * method, and should call eventOccurred when they have something to
13 * say.
14 * @author jdt
15 * *
16 */
17 public abstract class AbstractMonitor implements Monitor {
18 /***
19 * Commons-logging logger
20 */
21 private static org.apache.commons.logging.Log log =
22 org.apache.commons.logging.LogFactory.getLog(AbstractMonitor.class);
23 /***
24 * Who's listening?
25 */
26 private Listener listener;
27 /***
28 * Constructor
29 * @param listener who's listening to this monitor?
30 */
31 public AbstractMonitor(final Listener listener) {
32 this.listener = listener;
33 }
34 /***
35 * Subclasses can call this to signal to the listener
36 * @param event what happened
37 * @param resource to whom?
38 * @throws ListenerException whoopsie - the Listener threw something
39 */
40 protected final void signalListener(final Event event, final Object resource) throws ListenerException {
41 log.debug(
42 "Signalling listeners of event="
43 + event
44 + ", resource="
45 + resource);
46 listener.eventOccurred(event, resource);
47 }
48
49 }
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76