View Javadoc

1   /*
2    * $Id: ConsoleLocalHostAlerter.java,v 1.3 2004/03/11 11:33:46 johndavidtaylor
3    * Exp $ Created on Feb 20, 2004 by John Taylor jdt@roe.ac.uk .
4    */
5   package org.abraracourcix.alipes.alerters;
6   import java.net.MalformedURLException;
7   import java.net.URL;
8   import org.abraracourcix.alipes.common.Event;
9   import org.abraracourcix.alipes.listeners.filter.EventFilterListener;
10  import org.abraracourcix.alipes.listeners.logging.ConsoleListener;
11  import org.abraracourcix.alipes.monitors.PollingMonitor;
12  import org.abraracourcix.alipes.monitors.url.URLEvent;
13  import org.abraracourcix.alipes.monitors.url.URLMonitor;
14  /***
15   * 
16   * About as trivial as we can make it. An alerter that watches the local tomcat
17   * inst.
18   * @author jdt
19   */
20  public final class ConsoleLocalHostAlerter {
21      /***
22       * Hide
23       * Constructor
24       * @TODO tidy me
25       */
26      private ConsoleLocalHostAlerter() {}
27      /***
28       * Fire it up
29       * @param args ingored
30       * @throws MalformedURLException whoops
31       * @throws InterruptedException whoops
32       */
33      public static void main(String[] args)
34          throws MalformedURLException, InterruptedException {
35          System.out.println("Hit ctrl-C when you get bored");
36          Event[] events = { URLEvent.GONE_DOWN, URLEvent.GONE_UP };
37          PollingMonitor mon =
38              new URLMonitor(
39                  new EventFilterListener(
40                      new ConsoleListener(),
41                      events,
42                      EventFilterListener.FilterType.INCLUDED),
43                  10,
44                  new URL("http://localhost:8080"));
45          mon.start();
46          Thread.sleep(60 * 10 * 1000);
47      }
48  }
49  /*
50   * $Log: ConsoleLocalHostAlerter.java,v $
51   * Revision 1.1  2004/04/27 10:57:51  johndavidtaylor
52   * changed package name
53   *
54   * Revision 1.1  2004/03/17 21:16:51  johndavidtaylor
55   * Copied across from incubation in beanpeeler
56   *
57   * Revision 1.5  2004/03/14 18:49:14  johndavidtaylor
58   * corrected comments
59   *
60   * Revision 1.4  2004/03/11 15:46:34  johndavidtaylor
61   * Applied coding standards
62   * Revision 1.3 2004/03/11 11:33:46
63   * johndavidtaylor Refactored the way that the PollingMonitor worked.
64   * Previously it got started in its ctor, but this allowed access to subclass
65   * resources that hadn't yet been initialised. Bad. Now needs to be started
66   * explicitly post-construction.
67   * 
68   * Revision 1.2 2004/03/08 20:16:44 johndavidtaylor refactored to new package
69   * name
70   * 
71   * Revision 1.1 2004/03/08 19:58:24 johndavidtaylor Initial commit -transfer
72   * from previous repository
73   * 
74   * Revision 1.1 2004/03/02 23:04:37 jdt new
75   *  
76   */