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 java.util.Properties;
09:
10: import org.apache.commons.logging.Log;
11: import org.apache.commons.logging.LogFactory;
12: import org.logicalcobwebs.proxool.util.AbstractListenerContainer;
13:
14: /**
15: * A {@link ProxoolListenerIF} that keeps a list of <code>ProxoolListenerIF</code>s
16: * and notifies them in a thread safe manner.
17: * It also implements {@link org.logicalcobwebs.proxool.util.ListenerContainerIF ListenerContainerIF}
18: * which provides methods for
19: * {@link org.logicalcobwebs.proxool.util.ListenerContainerIF#addListener(Object) adding} and
20: * {@link org.logicalcobwebs.proxool.util.ListenerContainerIF#removeListener(Object) removing} listeners.
21: *
22: * @version $Revision: 1.6 $, $Date: 2006/01/18 14:40:01 $
23: * @author Christian Nedregaard (christian_nedregaard@email.com)
24: * @author $Author: billhorsman $ (current maintainer)
25: * @since Proxool 0.8
26: */
27: public class CompositeProxoolListener extends AbstractListenerContainer
28: implements ProxoolListenerIF {
29: static final Log LOG = LogFactory
30: .getLog(CompositeProxoolListener.class);
31:
32: /**
33: * @see ProxoolListenerIF#onRegistration(ConnectionPoolDefinitionIF, Properties)
34: */
35: public void onRegistration(
36: ConnectionPoolDefinitionIF connectionPoolDefinition,
37: Properties completeInfo) {
38: Object[] listeners = getListeners();
39:
40: for (int i = 0; i < listeners.length; i++) {
41: try {
42: ProxoolListenerIF proxoolListener = (ProxoolListenerIF) listeners[i];
43: proxoolListener.onRegistration(
44: connectionPoolDefinition,
45: (Properties) completeInfo.clone());
46: } catch (RuntimeException re) {
47: LOG.warn("RuntimeException received from listener "
48: + listeners[i]
49: + " when dispatching onRegistration event", re);
50: }
51: }
52: }
53:
54: /**
55: * @see ProxoolListenerIF#onShutdown(String)
56: */
57: public void onShutdown(String alias) {
58: Object[] listeners = getListeners();
59:
60: for (int i = 0; i < listeners.length; i++) {
61: try {
62: ProxoolListenerIF proxoolListener = (ProxoolListenerIF) listeners[i];
63: proxoolListener.onShutdown(alias);
64: } catch (RuntimeException re) {
65: LOG.warn("RuntimeException received from listener "
66: + listeners[i]
67: + " when dispatching onShutdown event", re);
68: }
69: }
70: }
71: }
72:
73: /*
74: Revision history:
75: $Log: CompositeProxoolListener.java,v $
76: Revision 1.6 2006/01/18 14:40:01 billhorsman
77: Unbundled Jakarta's Commons Logging.
78:
79: Revision 1.5 2004/03/16 08:48:32 brenuart
80: Changes in the AbstractListenerContainer:
81: - provide more efficient concurrent handling;
82: - better handling of RuntimeException thrown by external listeners.
83:
84: Revision 1.4 2003/03/10 15:26:44 billhorsman
85: refactoringn of concurrency stuff (and some import
86: optimisation)
87:
88: Revision 1.3 2003/03/03 11:11:56 billhorsman
89: fixed licence
90:
91: Revision 1.2 2003/02/26 16:05:52 billhorsman
92: widespread changes caused by refactoring the way we
93: update and redefine pool definitions.
94:
95: Revision 1.1 2003/02/24 01:15:05 chr32
96: Init rev.
97:
98:
99: */
|