View Javadoc

1   /*
2    * $Id: AbstractMonitor.java,v 1.2 2004/04/27 11:02:06 johndavidtaylor Exp $ 
3    * Created on Feb 19, 2004 by John Taylor jdt@roe.ac.uk .
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   * $Log: AbstractMonitor.java,v $
52   * Revision 1.2  2004/04/27 11:02:06  johndavidtaylor
53   * javadoc
54   *
55   * Revision 1.1  2004/03/17 21:18:02  johndavidtaylor
56   * Copied across from incubation in beanpeeler
57   *
58   * Revision 1.5  2004/03/14 18:49:15  johndavidtaylor
59   * corrected comments
60   *
61   * Revision 1.4  2004/03/14 00:44:22  johndavidtaylor
62   * Added ListenerException
63   *
64   * Revision 1.3  2004/03/11 15:46:34  johndavidtaylor
65   * Applied coding standards
66   *
67   * Revision 1.2  2004/03/08 20:16:45  johndavidtaylor
68   * refactored to new package name
69   *
70   * Revision 1.1  2004/03/08 19:58:25  johndavidtaylor
71   * Initial commit -transfer  from previous repository
72   *
73   * Revision 1.1  2004/03/02 23:04:37  jdt
74   * new
75   *
76   */