View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  }