1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.monitor;
24
25 import de.bea.domingo.DNotesMonitor;
26
27 /***
28 * Base class for all monitor enabled classes.
29 *
30 * <p>As default, the associated monitor is a <code>NullMonitor</code> that
31 * simply does nothing. To monitor events the application should either set a
32 * ConsoleMonitor or implement itself the <code>Monitor</code> interface set an
33 * instance of this class with the <code>setMonitor</code> method.</p>
34 *
35 * @see de.bea.domingo.DNotesMonitor
36 * @see de.bea.domingo.monitor.NullMonitor
37 * @see de.bea.domingo.monitor.ConsoleMonitor
38 * @see de.bea.domingo.monitor.MonitorEnabled#setMonitor(de.bea.domingo.DNotesMonitor)
39 *
40 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
41 */
42 public abstract class AbstractMonitorEnabled implements MonitorEnabled {
43
44 /*** Default monitor. */
45 private static final DNotesMonitor DEFAULT_MONITOR = NullMonitor.getInstance();
46
47 /*** Reference to current monitor. */
48 private DNotesMonitor monitor = DEFAULT_MONITOR;
49
50 /***
51 * Constructor.
52 */
53 public AbstractMonitorEnabled() {
54 super();
55 }
56
57 /***
58 * Constructor.
59 *
60 * @param theMonitor the monitor
61 */
62 public AbstractMonitorEnabled(final DNotesMonitor theMonitor) {
63 super();
64 setMonitor(theMonitor);
65 }
66
67 /***
68 * {@inheritDoc}
69 * @see de.bea.domingo.monitor.MonitorEnabled#getMonitor()
70 */
71 public final DNotesMonitor getMonitor() {
72 return monitor;
73 }
74
75 /***
76 * {@inheritDoc}
77 * @see de.bea.domingo.monitor.MonitorEnabled#setMonitor(de.bea.domingo.DNotesMonitor)
78 */
79 public final void setMonitor(final DNotesMonitor theMonitor) {
80 if (monitor != null) {
81 this.monitor = theMonitor;
82 }
83 }
84 }