01: /*
02: * This software is released under a licence similar to the Apache Software Licence.
03: * See org.logicalcobwebs.proxool.package.html for details.
04: * The latest version is available at http://proxool.sourceforge.net
05: */
06: package org.logicalcobwebs.proxool;
07:
08: import org.apache.commons.logging.Log;
09: 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
26: implements StateListenerIF {
27: static final Log LOG = LogFactory
28: .getLog(CompositeStateListener.class);
29:
30: /**
31: * @see StateListenerIF#upStateChanged(int)
32: */
33: public void upStateChanged(int upState) {
34: Object[] listeners = getListeners();
35:
36: for (int i = 0; i < listeners.length; i++) {
37: try {
38: StateListenerIF stateListener = (StateListenerIF) listeners[i];
39: stateListener.upStateChanged(upState);
40: } catch (RuntimeException re) {
41: LOG.warn("RuntimeException received from listener "
42: + listeners[i]
43: + " when dispatching upStateChanged event", re);
44: }
45: }
46: }
47: }
48:
49: /*
50: Revision history:
51: $Log: CompositeStateListener.java,v $
52: Revision 1.6 2006/01/18 14:40:01 billhorsman
53: Unbundled Jakarta's Commons Logging.
54:
55: Revision 1.5 2004/03/16 08:48:32 brenuart
56: Changes in the AbstractListenerContainer:
57: - provide more efficient concurrent handling;
58: - better handling of RuntimeException thrown by external listeners.
59:
60: Revision 1.4 2003/03/10 15:26:44 billhorsman
61: refactoringn of concurrency stuff (and some import
62: optimisation)
63:
64: Revision 1.3 2003/03/03 11:11:56 billhorsman
65: fixed licence
66:
67: Revision 1.2 2003/02/07 17:20:15 billhorsman
68: checkstyle
69:
70: Revision 1.1 2003/02/07 01:47:17 chr32
71: Initial revition.
72:
73: */
|