KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > CompositeStateListener


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;
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 StateListenerIF} that keeps a list of <code>StateListenerIF</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.6 $, $Date: 2006/01/18 14:40:01 $
21  * @author Christian Nedregaard (christian_nedregaard@email.com)
22  * @author $Author: billhorsman $ (current maintainer)
23  * @since Proxool 0.7
24  */

25 public class CompositeStateListener extends AbstractListenerContainer implements StateListenerIF {
26     static final Log LOG = LogFactory.getLog(CompositeStateListener.class);
27
28     /**
29      * @see StateListenerIF#upStateChanged(int)
30      */

31     public void upStateChanged(int upState)
32     {
33         Object JavaDoc[] listeners = getListeners();
34         
35         for(int i=0; i<listeners.length; i++) {
36             try {
37                 StateListenerIF stateListener = (StateListenerIF) listeners[i];
38                 stateListener.upStateChanged(upState);
39             }
40             catch (RuntimeException JavaDoc re) {
41                 LOG.warn("RuntimeException received from listener "+listeners[i]+" when dispatching upStateChanged event", re);
42             }
43         }
44     }
45 }
46
47 /*
48  Revision history:
49  $Log: CompositeStateListener.java,v $
50  Revision 1.6 2006/01/18 14:40:01 billhorsman
51  Unbundled Jakarta's Commons Logging.
52
53  Revision 1.5 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.4 2003/03/10 15:26:44 billhorsman
59  refactoringn of concurrency stuff (and some import
60  optimisation)
61
62  Revision 1.3 2003/03/03 11:11:56 billhorsman
63  fixed licence
64
65  Revision 1.2 2003/02/07 17:20:15 billhorsman
66  checkstyle
67
68  Revision 1.1 2003/02/07 01:47:17 chr32
69  Initial revition.
70
71 */
Popular Tags