KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Properties JavaDoc;
9
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 implements ProxoolListenerIF {
28     static final Log LOG = LogFactory.getLog(CompositeProxoolListener.class);
29
30     /**
31      * @see ProxoolListenerIF#onRegistration(ConnectionPoolDefinitionIF, Properties)
32      */

33     public void onRegistration( ConnectionPoolDefinitionIF connectionPoolDefinition,
34                                 Properties JavaDoc completeInfo)
35     {
36         Object JavaDoc[] listeners = getListeners();
37         
38         for(int i=0; i<listeners.length; i++) {
39             try {
40                 ProxoolListenerIF proxoolListener = (ProxoolListenerIF) listeners[i];
41                 proxoolListener.onRegistration(connectionPoolDefinition, (Properties JavaDoc) completeInfo.clone());
42             }
43             catch (RuntimeException JavaDoc re) {
44                 LOG.warn("RuntimeException received from listener "+listeners[i]+" when dispatching onRegistration event", re);
45             }
46         }
47     }
48
49     /**
50      * @see ProxoolListenerIF#onShutdown(String)
51      */

52     public void onShutdown(String JavaDoc alias)
53     {
54         Object JavaDoc[] listeners = getListeners();
55         
56         for(int i=0; i<listeners.length; i++) {
57             try {
58                 ProxoolListenerIF proxoolListener = (ProxoolListenerIF) listeners[i];
59                 proxoolListener.onShutdown(alias);
60             }
61             catch (RuntimeException JavaDoc re) {
62                 LOG.warn("RuntimeException received from listener "+listeners[i]+" when dispatching onShutdown event", re);
63             }
64         }
65     }
66 }
67
68 /*
69  Revision history:
70  $Log: CompositeProxoolListener.java,v $
71  Revision 1.6 2006/01/18 14:40:01 billhorsman
72  Unbundled Jakarta's Commons Logging.
73
74  Revision 1.5 2004/03/16 08:48:32 brenuart
75  Changes in the AbstractListenerContainer:
76  - provide more efficient concurrent handling;
77  - better handling of RuntimeException thrown by external listeners.
78
79  Revision 1.4 2003/03/10 15:26:44 billhorsman
80  refactoringn of concurrency stuff (and some import
81  optimisation)
82
83  Revision 1.3 2003/03/03 11:11:56 billhorsman
84  fixed licence
85
86  Revision 1.2 2003/02/26 16:05:52 billhorsman
87  widespread changes caused by refactoring the way we
88  update and redefine pool definitions.
89
90  Revision 1.1 2003/02/24 01:15:05 chr32
91  Init rev.
92
93
94 */
Popular Tags