KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > admin > CompositeStatisticsListener


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool.admin;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.logicalcobwebs.proxool.util.AbstractListenerContainer;
11
12 /**
13  * A {@link StatisticsListenerIF} that keeps a list of <code>StatisticsListenerIF</code>s
14  * and notifies them in a thread safe manner.
15  * It also implements {@link org.logicalcobwebs.proxool.util.ListenerContainerIF ListenerContainerIF}
16  * which provides methods for
17  * {@link org.logicalcobwebs.proxool.util.ListenerContainerIF#addListener(Object) adding} and
18  * {@link org.logicalcobwebs.proxool.util.ListenerContainerIF#removeListener(Object) removing} listeners.
19  *
20  * @version $Revision: 1.5 $, $Date: 2006/01/18 14:39:57 $
21  * @author Christian Nedregaard (christian_nedregaard@email.com)
22  * @author $Author: billhorsman $ (current maintainer)
23  * @since Proxool 0.7
24  */

25 public class CompositeStatisticsListener extends AbstractListenerContainer implements StatisticsListenerIF {
26     static final Log LOG = LogFactory.getLog(CompositeStatisticsListener.class);
27
28     /**
29      * @see StatisticsListenerIF#statistics(String, StatisticsIF)
30      */

31     public void statistics(String JavaDoc alias, StatisticsIF statistics)
32     {
33         Object JavaDoc[] listeners = getListeners();
34         
35         for(int i=0; i<listeners.length; i++) {
36             try {
37                 StatisticsListenerIF statisticsListener = (StatisticsListenerIF) listeners[i];
38                 statisticsListener.statistics(alias, statistics);
39             }
40             catch (RuntimeException JavaDoc re) {
41                 LOG.warn("RuntimeException received from listener "+listeners[i]+" when dispatching statistics event", re);
42             }
43         }
44     }
45 }
46
47 /*
48  Revision history:
49  $Log: CompositeStatisticsListener.java,v $
50  Revision 1.5 2006/01/18 14:39:57 billhorsman
51  Unbundled Jakarta's Commons Logging.
52
53  Revision 1.4 2004/03/16 08:48:32 brenuart
54  Changes in the AbstractListenerContainer:
55  - provide more efficient concurrent handling;
56  - better handling of RuntimeException thrown by external listeners.
57
58  Revision 1.3 2003/03/10 15:26:51 billhorsman
59  refactoringn of concurrency stuff (and some import
60  optimisation)
61
62  Revision 1.2 2003/03/03 11:11:59 billhorsman
63  fixed licence
64
65  Revision 1.1 2003/02/19 23:36:51 billhorsman
66  renamed monitor package to admin
67
68  Revision 1.2 2003/02/07 17:20:17 billhorsman
69  checkstyle
70
71  Revision 1.1 2003/02/07 01:49:04 chr32
72  Initial revition.
73
74 */
Popular Tags