KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > dbm > ConnectionManager


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ConnectionManager.java,v 1.78 2005/07/28 07:52:27 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas.dbm;
28
29 import java.io.Serializable JavaDoc;
30 import java.sql.Connection JavaDoc;
31 import java.sql.SQLException JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Map JavaDoc;
34
35 import javax.naming.NamingException JavaDoc;
36 import javax.naming.Reference JavaDoc;
37 import javax.naming.Referenceable JavaDoc;
38 import javax.naming.StringRefAddr JavaDoc;
39 import javax.sql.ConnectionEvent JavaDoc;
40 import javax.sql.ConnectionEventListener JavaDoc;
41 import javax.sql.DataSource JavaDoc;
42 import javax.sql.XAConnection JavaDoc;
43 import javax.transaction.RollbackException JavaDoc;
44 import javax.transaction.SystemException JavaDoc;
45 import javax.transaction.Transaction JavaDoc;
46 import javax.transaction.xa.XAResource JavaDoc;
47
48 import org.objectweb.jonas.common.Log;
49 import org.objectweb.jonas.jdbc_xa.XADataSourceImpl;
50 import org.objectweb.jonas.jtm.TransactionService;
51 import org.objectweb.jonas.service.ServiceManager;
52 import org.objectweb.transaction.jta.ResourceManagerEventListener;
53 import org.objectweb.transaction.jta.TransactionManager;
54 import org.objectweb.util.monolog.api.BasicLevel;
55 import org.objectweb.util.monolog.api.Logger;
56
57 /**
58  * JOnAS generic implementation of DataSource to manage an underlying
59  * JDBC-XA driver (XADataSource, XAConnection, XAResource, ...)
60  * This class acts as a factory for Connection objects.
61  * Its main goal is to manage a pool of XAConnection objects, to avoid
62  * closing the actual Connection on DBMS, and to deal with distributed
63  * transactions.
64  * This DataSource is registered in JNDI (=> implements Referenceable)
65  *
66  * @author Philippe Durieux
67  * <p>
68  * Contributor(s):
69  * <p>
70  * 00/01/08 Markus Fritz make connection pooling thread safe (with same tx)
71  * introduce MaxAge for connections
72  * optimize pooling
73  * add some 'paranoia code': test conns before returning them from the pool.
74  * <p>
75  * 00/18/04 Jun Inamori (j-office@osa.att.ne.jp)
76  * For closing correctly all connections at server shutdown.
77  * <p>01/11/06 Christophe Ney cney@batisseurs.com for Lutris Technologies
78  * Added ResourceManagerListener mechanism.
79  * <p>02/01/15 Dean Jennings - Map instead of Hashtable for cmList
80  * <p>Adriana Danes
81  * <p>03/01/13 - Manage datasource name additionally to the jndi name for the datasource using this ConnectionManager
82  * <p>03/04/08 - ConnectionManager extends ReconfigDispatcher in order to send reconfiguration Notifications to ReconfigManager
83  * <p>03/05/23 - Introduce pool size configuration
84  * <p>04/09/20 - Remove ReconfigDispatcher inheritance; management features moved to new MBeans (JSR77 JDBCDataSource, JDBCDriver)
85  */

86 public class ConnectionManager
87     implements DataSource JavaDoc,
88                Referenceable JavaDoc,
89                Serializable JavaDoc,
90                ConnectionEventListener JavaDoc {
91
92     private Logger logger = null;
93
94     // The static table of all the ConnectionManager objects
95
// Each ResourceManager has its own ConnectionManager (i.e. DataSource)
96
private static Map JavaDoc cmList = new HashMap JavaDoc();
97
98     /**
99      * TransactionManager object
100      * @serial
101      */

102     private TransactionManager tm = null;
103
104     /**
105      * underlaying XA DataSource
106      * @serial
107      */

108     private XADataSourceImpl xads = null;
109
110     /**
111      * The pool of XAConnections managed by this Connection Manager
112      * @serial
113      */

114     private Pool pool = null;
115
116     /**
117      * @return The pool associated to this datasource
118      */

119     public Pool getPool() {
120         return pool;
121     }
122
123     // ----------------------------------------------------------
124
// properties
125
// ----------------------------------------------------------
126

127     /**
128      * @serial for JNDI
129      */

130     private String JavaDoc dSName = null;
131
132     /**
133      * @serial datasource name
134      */

135     private String JavaDoc datasourceName;
136
137     /**
138      * @serial url for database
139      */

140     private String JavaDoc url = null;
141     /**
142      * @serial JDBC driver Class
143      */

144     private String JavaDoc className = null;
145     /**
146      * @serial default user
147      */

148     private String JavaDoc userName = null;
149     /**
150      * @serial default passwd
151      */

152     private String JavaDoc password = null;
153
154     /**
155      * @serial
156      */

157     private int isolationLevel = -1;
158     private String JavaDoc isolationStr = null;
159
160     /**
161      * @serial
162      */

163     private String JavaDoc currentMapperName = null;
164
165     /**
166      * Name of the client (client case)
167      * TODO : must be removed. A client can lookup a datasource
168      */

169     private boolean isClient = false;
170
171     /**
172      * MBean variable
173      */

174     private String JavaDoc xaName = null;
175     private String JavaDoc dsDescription = null;
176
177     private static ResourceManagerEventListener rmListener = null;
178
179     // -----------------------------------------------------------------
180
// Constructors
181
// -----------------------------------------------------------------
182

183     /**
184      * Constructor for Factory
185      */

186     public ConnectionManager() throws Exception JavaDoc {
187
188         // Set the TransactionManager
189
// Modified for use with the gcj compiler
190
ServiceManager sm = ServiceManager.getInstance();
191         TransactionService ts = (TransactionService) sm.getTransactionService();
192         tm = ts.getTransactionManager();
193
194
195         // set the Transaction Manager as being the listener for this RM
196
setRMEListener(tm);
197
198         // Create the underlaying JDBC-XA driver
199
// We do not use JNDI here. (should we do ?)
200
// AD : do this before the Pool creation in order to allow the Pool constructor to access xads
201
xads = new XADataSourceImpl();
202     }
203
204     /**
205      * Constructor for the client case
206      * @param isClient true if this is the client case
207      * TODO : must be removed. A client can lookup a datasource
208      */

209     public ConnectionManager(boolean isClient) throws Exception JavaDoc {
210         this.isClient = isClient;
211         xads = new XADataSourceImpl();
212     }
213
214     /**
215      * This manager is in the client case or not ?
216      * @return boolean true if this is the client case
217      * TODO : must be removed. A client can lookup a datasource
218      */

219     public boolean isClientCase() {
220         return isClient;
221     }
222
223     // -----------------------------------------------------------------
224
// Properties
225
// -----------------------------------------------------------------
226

227     public void setRMEListener(ResourceManagerEventListener rmel) {
228         rmListener = rmel;
229     }
230
231     /**
232      * @return Jndi name of the datasource
233      */

234     public String JavaDoc getDSName() {
235         return dSName;
236     }
237
238     /**
239      * @param s Jndi name for the datasource
240      */

241     public void setDSName(String JavaDoc s) {
242         dSName = s;
243         logger = Log.getLogger(Log.JONAS_DBM_PREFIX + "." + dSName);
244         try {
245             pool = new Pool(this, xads, logger);
246         } catch (Exception JavaDoc e) {
247             logger.log(BasicLevel.ERROR, "Cannot create Pool: " + e);
248         }
249         xads.setDataSourceName(s); // for getRMID!
250
// Add it to the list
251
cmList.put(s, this);
252     }
253
254     public String JavaDoc getUrl() {
255         return url;
256     }
257     public void setUrl(String JavaDoc s) {
258         url = s;
259         // Forward it to JDBC-XA driver
260
xads.setUrl(s);
261     }
262
263     public String JavaDoc getClassName() {
264         return className;
265     }
266     public void setClassName(String JavaDoc s) throws ClassNotFoundException JavaDoc {
267         className = s;
268         // Forward it to JDBC-XA driver
269
xads.setClassName(s);
270     }
271
272     public String JavaDoc getUserName() {
273         return userName;
274     }
275     public void setUserName(String JavaDoc s) {
276         userName = s;
277         // Forward it to JDBC-XA driver
278
xads.setUserName(s);
279     }
280
281     public String JavaDoc getPassword() {
282         return password;
283     }
284     public void setPassword(String JavaDoc s) {
285         password = s;
286         // Forward it to JDBC-XA driver
287
xads.setPassword(s);
288     }
289
290     public void setTransactionIsolation(String JavaDoc level) {
291         if (logger.isLoggable(BasicLevel.DEBUG)) {
292             logger.log(BasicLevel.DEBUG, level);
293         }
294         if (level.equals("serializable")) {
295             isolationLevel = Connection.TRANSACTION_SERIALIZABLE;
296         } else if (level.equals("none")) {
297             isolationLevel = Connection.TRANSACTION_NONE;
298         } else if (level.equals("read_committed")) {
299             isolationLevel = Connection.TRANSACTION_READ_COMMITTED;
300         } else if (level.equals("read_uncommitted")) {
301             isolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
302         } else if (level.equals("repeatable_read")) {
303             isolationLevel = Connection.TRANSACTION_REPEATABLE_READ;
304         } else {
305             isolationStr = "default";
306             return;
307         }
308         // Forward it to JDBC-XA driver
309
isolationStr = level;
310         xads.setTransactionIsolation(isolationLevel);
311     }
312
313     public String JavaDoc getTransactionIsolation() {
314         if (logger.isLoggable(BasicLevel.DEBUG)) {
315             logger.log(BasicLevel.DEBUG, isolationStr);
316         }
317         return isolationStr;
318     }
319
320     public void setMapperName(String JavaDoc mappername) {
321         currentMapperName = mappername;
322     }
323
324     public String JavaDoc getMapperName() {
325         return currentMapperName;
326     }
327
328     /**
329      * Configure the Connection pool. Called by the Container at init.
330      * Configuration can be set in datasource.properties files.
331      * @param connchecklevel JDBC connection checking level
332      * @param connmaxage JDBC connection maximum age
333      * @param maxopentime JDBC connection maximum open time
334      * @param connteststmt SQL query for test statement
335      * @param minconpool Min size for the connection pool
336      * @param maxconpool Max size for the connection pool
337      * @param maxwaittime Max time to wait for a connection (in seconds)
338      * @param maxwaiters Max nb of waiters for a connection
339      * @param samplingperiod sampling period in sec.
340      * @throw ServiceException if could not create the initial items in the pool
341      */

342     public void poolConfigure(String JavaDoc connchecklevel,
343                               String JavaDoc connmaxage,
344                               String JavaDoc maxopentime,
345                               String JavaDoc connteststmt,
346                               String JavaDoc minconpool,
347                               String JavaDoc maxconpool,
348                               String JavaDoc maxwaittime,
349                               String JavaDoc maxwaiters,
350                               String JavaDoc samplingperiod) {
351
352         // Configure pool
353
pool.setCheckLevel((new Integer JavaDoc(connchecklevel)).intValue());
354         // set con max age BEFORE min/max pool size.
355
pool.setMaxAge((new Integer JavaDoc(connmaxage)).intValue());
356         pool.setMaxOpenTime((new Integer JavaDoc(maxopentime)).intValue());
357         pool.setTestStatement(connteststmt);
358         pool.setPoolMin((new Integer JavaDoc(minconpool)).intValue());
359         pool.setPoolMax((new Integer JavaDoc(maxconpool)).intValue());
360         pool.setMaxWaitTime((new Integer JavaDoc(maxwaittime)).intValue());
361         pool.setMaxWaiters((new Integer JavaDoc(maxwaiters)).intValue());
362         pool.setSamplingPeriod((new Integer JavaDoc(samplingperiod)).intValue());
363         if (logger.isLoggable(BasicLevel.DEBUG)) {
364             logger.log(BasicLevel.DEBUG, "ConnectionManager configured with:");
365             logger.log(BasicLevel.DEBUG, " jdbcConnCheckLevel = " + connchecklevel);
366             logger.log(BasicLevel.DEBUG, " jdbcConnMaxAge = " + connmaxage);
367             logger.log(BasicLevel.DEBUG, " jdbcMaxOpenTime = " + maxopentime);
368             logger.log(BasicLevel.DEBUG, " jdbcTestStmt = " + connteststmt);
369             logger.log(BasicLevel.DEBUG, " minConPool = " + pool.getPoolMin());
370             logger.log(BasicLevel.DEBUG, " maxConPool = " + pool.getPoolMax());
371             logger.log(BasicLevel.DEBUG, " maxWaitTime = " + pool.getMaxWaitTime());
372             logger.log(BasicLevel.DEBUG, " maxWaiters = " + pool.getMaxWaiters());
373             logger.log(BasicLevel.DEBUG, " samplingPeriod = " + pool.getSamplingPeriod());
374         }
375     }
376
377     // -----------------------------------------------------------------
378
// DataSource implementation
379
// -----------------------------------------------------------------
380

381     /**
382      * Attempt to establish a database connection.
383      *
384      * @return a Connection to the database
385      *
386      * @exception java.sql.SQLException - if a database-access error occurs.
387      */

388     public Connection JavaDoc getConnection() throws SQLException JavaDoc {
389         return getConnection(userName, password);
390     }
391
392     /**
393      * Attempt to establish a database connection.
394      *
395      * @param user - the database user on whose behalf the Connection is being made
396      * @param password - the user's password
397      *
398      * @return a Connection to the database
399      *
400      * @exception SQLException - if a database-access error occurs.
401      */

402     public Connection JavaDoc getConnection(String JavaDoc username, String JavaDoc password) throws SQLException JavaDoc {
403         XAConnection JavaDoc xac = null;
404         Transaction JavaDoc tx = null;
405         try {
406             tx = tm.getTransaction();
407         } catch (NullPointerException JavaDoc n) {
408             // current is null: we are not in a JOnAS Server.
409
logger.log(BasicLevel.ERROR, "ConnectionManager: should not be used outside a JOnAS Server", n);
410         } catch (SystemException JavaDoc e) {
411             logger.log(BasicLevel.ERROR, "ConnectionManager: getTransaction failed", e);
412         }
413         if (logger.isLoggable(BasicLevel.DEBUG)) {
414             logger.log(BasicLevel.DEBUG, "Tx = " + tx);
415         }
416
417         // Check if available XAConnection in the pool for this user
418
PoolItem pi = pool.openConnection(username, tx);
419         // get the xac associated to the new PoolItem
420
xac = pi.getXACon();
421
422         Connection JavaDoc ret = xac.getConnection();
423         // Enlist XAResource if we are actually in a transaction
424
if (tx != null) {
425             if (pi.getOpenCount() == 1) { // Only if first/only thread
426
try {
427                     if (logger.isLoggable(BasicLevel.DEBUG)) {
428                         logger.log(BasicLevel.DEBUG, "enlist XAResource on " + tx);
429                     }
430                     tx.enlistResource(xac.getXAResource());
431                     // We are inside a transaction: no autocommit!
432
ret.setAutoCommit(false);
433                 } catch (RollbackException JavaDoc e) {
434                     // Although tx has been marked to be rolled back,
435
// XAResource has been correctly enlisted.
436
logger.log(BasicLevel.WARN, "XAResource enlisted, but tx is marked rollback", e);
437                 } catch (IllegalStateException JavaDoc e) {
438                     // In case tx is committed, no need to register resource!
439
ret.setAutoCommit(true);
440                 } catch (Exception JavaDoc e) {
441                     logger.log(BasicLevel.ERROR, "Cannot enlist XAResource", e);
442                     logger.log(BasicLevel.ERROR, "Connection will not be enlisted in a transaction");
443                     // should return connection in the pool XXX
444
throw new SQLException JavaDoc("Cannot enlist XAResource");
445                 }
446             }
447         } else {
448             ret.setAutoCommit(true); // in case we do not start a Tx
449
}
450         // We are not in a transaction yet: we just make a pre-registration.
451
// We are in a stateful bean, put it in the list too.
452
if (!pi.isRME()) {
453             if (logger.isLoggable(BasicLevel.DEBUG)) {
454                 logger.log(BasicLevel.DEBUG, "register this connection to the TM.");
455             }
456             pi.setRME(true);
457             rmListener.connectionOpened(pi);
458         }
459         // return a Connection object
460
return ret;
461     }
462
463     /**
464      * Get the log writer for this data source.
465      *
466      * The log writer is a character output stream to which all logging and
467      * tracing messages for this data source object instance will be printed.
468      * This includes messages printed by the methods of this object, messages
469      * printed by methods of other objects manufactured by this object, and so on.
470      * Messages printed to a data source specificlog writer are not printed to the
471      * log writer associated with the Drivermanager class. When a data
472      * source object is created the log writer is initially null, in other words,
473      * logging is disabled.
474      *
475      * @return the log writer for this data source, null if disabled
476      *
477      * @exception SQLException - if a database-access error occurs.
478      */

479     public java.io.PrintWriter JavaDoc getLogWriter() throws SQLException JavaDoc {
480         return xads.getLogWriter();
481     }
482
483
484     /**
485      * Set the log writer for this data source.
486      *
487      * The log writer is a character output stream to which all logging and
488      * tracing messages for this data source object instance will be printed.
489      * This includes messages printed by the methods of this object, messages printed
490      * by methods of other objects manufactured by this object, and so on.
491      * Messages printed to a data source specific log writer are not printed to
492      * the log writer associated with the Drivermanager class. When a data
493      * source object is created the log writer is initially null, in other words,
494      * logging is disabled.
495      *
496      * @param out - the new log writer; to disable, set to null
497      *
498      * @exception SQLException - if a database-access error occurs.
499      */

500     public void setLogWriter(java.io.PrintWriter JavaDoc out) throws SQLException JavaDoc {
501         xads.setLogWriter(out);
502     }
503
504
505     /**
506      * Sets the maximum time in seconds that this data source will wait while
507      * attempting to connect to a database.
508      * A value of zero specifies that the timeout is the default system timeout
509      * if there is one;
510      * otherwise it specifies that there is no timeout.
511      * When a data source object is created the login timeout is initially zero.
512      *
513      * @param seconds - the data source login time limit
514      *
515      * @exception SQLException - if a database access error occurs.
516      */

517     public void setLoginTimeout(int seconds) throws SQLException JavaDoc {
518         xads.setLoginTimeout(seconds);
519     }
520
521     /**
522      * Gets the maximum time in seconds that this data source can wait while attempting
523      * to connect to a database.
524      * A value of zero means that the timeout is the default system timeout if there is one;
525      * otherwise it means that there is no timeout. When a data source object is created
526      * the login timeout is initially zero.
527      *
528      * @return the data source login time limit
529      *
530      * @exception SQLException - if a database access error occurs.
531      */

532     public int getLoginTimeout() throws SQLException JavaDoc {
533         return xads.getLoginTimeout();
534     }
535
536     // -----------------------------------------------------------------
537
// ConnectionEventListener implementation
538
// -----------------------------------------------------------------
539

540     /**
541      * Invoked when the application calls close() on its representation
542      * of the connection.
543      * @param event - an event object describing the source of the event
544      */

545     public void connectionClosed(ConnectionEvent JavaDoc event) {
546         if (logger.isLoggable(BasicLevel.DEBUG)) {
547             logger.log(BasicLevel.DEBUG, " ");
548         }
549
550         XAConnection JavaDoc xac = (XAConnection JavaDoc) event.getSource();
551         PoolItem pi = pool.closeConnection(xac, XAResource.TMSUCCESS);
552
553         // remove it from the list of open connections for this thread
554
// only if it was opened outside a tx.
555
if (pi != null && pi.isRME()) {
556             if (logger.isLoggable(BasicLevel.DEBUG)) {
557                 logger.log(BasicLevel.DEBUG, "unregister this connection to the TM.");
558             }
559             pi.setRME(false);
560             rmListener.connectionClosed(pi);
561         }
562     }
563
564     /**
565      * Invoked when a fatal connection error occurs, just before an
566      * SQLException is thrown to the application.
567      * @param event - an event object describing the source of the event
568      */

569     public void connectionErrorOccurred(ConnectionEvent JavaDoc event) {
570         if (logger.isLoggable(BasicLevel.DEBUG)) {
571             logger.log(BasicLevel.DEBUG, "");
572         }
573
574         XAConnection JavaDoc xac = (XAConnection JavaDoc) event.getSource();
575         PoolItem pi = pool.closeConnection(xac, XAResource.TMFAIL);
576
577         // remove it from the list of open connections for this thread
578
// only if it was opened outside a tx.
579
if (pi != null && pi.isRME()) {
580             if (logger.isLoggable(BasicLevel.DEBUG)) {
581                 logger.log(BasicLevel.DEBUG, "unregister this connection to the TM.");
582             }
583             pi.setRME(false);
584             rmListener.connectionErrorOccured(pi);
585         }
586     }
587
588     // -----------------------------------------------------------------
589
// Referenceable implementation
590
// -----------------------------------------------------------------
591

592     /**
593      * Retrieves the Reference of this object. Used at binding time by JNDI
594      * to build a reference on this object.
595      *
596      * @return The non-null Reference of this object.
597      * @exception NamingException If a naming exception was encountered while
598      * retrieving the reference.
599      */

600     public Reference JavaDoc getReference() throws NamingException JavaDoc {
601
602         Reference JavaDoc ref = new Reference JavaDoc (this.getClass().getName(),
603                                        "org.objectweb.jonas.dbm.DataSourceFactory",
604                                        null);
605         // These values are used by ObjectFactory (see DataSourceFactory.java)
606
ref.add(new StringRefAddr JavaDoc("datasource.name", getDSName()));
607         ref.add(new StringRefAddr JavaDoc("datasource.url", getUrl()));
608         ref.add(new StringRefAddr JavaDoc("datasource.classname", getClassName()));
609         ref.add(new StringRefAddr JavaDoc("datasource.username", getUserName()));
610         ref.add(new StringRefAddr JavaDoc("datasource.password", getPassword()));
611         ref.add(new StringRefAddr JavaDoc("datasource.isolationlevel", getTransactionIsolation()));
612         ref.add(new StringRefAddr JavaDoc("datasource.mapper", getMapperName()));
613         Integer JavaDoc checklevel = new Integer JavaDoc(pool.getCheckLevel());
614         ref.add(new StringRefAddr JavaDoc("connchecklevel", checklevel.toString()));
615         Integer JavaDoc maxage = new Integer JavaDoc(pool.getMaxAge());
616         ref.add(new StringRefAddr JavaDoc("connmaxage", maxage.toString()));
617         Integer JavaDoc maxopentime = new Integer JavaDoc(pool.getMaxOpenTime());
618         ref.add(new StringRefAddr JavaDoc("maxopentime", maxopentime.toString()));
619         ref.add(new StringRefAddr JavaDoc("connteststmt", pool.getTestStatement()));
620         Integer JavaDoc minpool = new Integer JavaDoc(pool.getPoolMin());
621         ref.add(new StringRefAddr JavaDoc("minconpool", minpool.toString()));
622         Integer JavaDoc maxpool = new Integer JavaDoc(pool.getPoolMax());
623         ref.add(new StringRefAddr JavaDoc("maxconpool", maxpool.toString()));
624         Integer JavaDoc maxwaittime = new Integer JavaDoc(pool.getMaxWaitTime());
625         ref.add(new StringRefAddr JavaDoc("maxwaittime", maxwaittime.toString()));
626         Integer JavaDoc maxwaiters = new Integer JavaDoc(pool.getMaxWaiters());
627         ref.add(new StringRefAddr JavaDoc("maxwaiters", maxwaiters.toString()));
628         Integer JavaDoc samplingperiod = new Integer JavaDoc(pool.getSamplingPeriod());
629         ref.add(new StringRefAddr JavaDoc("samplingperiod", samplingperiod.toString()));
630         return ref;
631     }
632
633     /**
634      * get the ConnectionManager matching the DataSource name
635      */

636     public static ConnectionManager getConnectionManager(String JavaDoc dsname) {
637
638         ConnectionManager cm = (ConnectionManager) cmList.get(dsname);
639         return cm;
640     }
641
642     public void closeAllConnection() {
643         if (logger.isLoggable(BasicLevel.DEBUG)) {
644             logger.log(BasicLevel.DEBUG, "");
645         }
646         pool.closeAllConnections();
647     }
648
649     public static ResourceManagerEventListener getResourceManagerEventListener() {
650         return rmListener;
651     }
652
653     /**
654      * @return datasource name
655      */

656     public String JavaDoc getDatasourceName() {
657         return datasourceName;
658     }
659
660     /**
661      * @param s datasource name
662      */

663     public void setDatasourceName(String JavaDoc s) {
664         datasourceName = s;
665     }
666
667     /**
668      * @return the desrciption of this datasource
669      */

670     public String JavaDoc getDataSourceDescription() {
671         return dsDescription;
672     }
673
674     /**
675      * @param dsDesc the desrciption of this datasource
676      */

677     public void setDataSourceDescription(String JavaDoc dsDesc) {
678         dsDescription = dsDesc;
679     }
680 }
Popular Tags