1 16 19 20 21 package org.apache.xalan.lib.sql; 22 23 import java.util.Hashtable ; 24 25 import org.apache.xalan.res.XSLMessages; 26 import org.apache.xalan.res.XSLTErrorResources; 27 28 30 public class ConnectionPoolManager 31 { 32 34 static Hashtable m_poolTable = null; 35 37 static boolean m_isInit = false; 38 39 41 public ConnectionPoolManager( ) 42 { 43 init(); 44 } 45 46 50 public synchronized void init( ) 51 { 52 if (m_isInit == true) return; 54 55 56 m_poolTable = new Hashtable (); 60 61 m_isInit = true; 62 } 63 64 77 public synchronized void registerPool( String name, ConnectionPool pool ) 78 { 79 if ( m_poolTable.containsKey(name) ) 80 { 81 throw new IllegalArgumentException (XSLMessages.createMessage(XSLTErrorResources.ER_POOL_EXISTS, null)); } 83 84 m_poolTable.put(name, pool); 85 } 86 87 94 public synchronized void removePool( String name ) 95 { 96 ConnectionPool pool = getPool(name); 97 98 if (null != pool) 99 { 100 pool.setPoolEnabled(false); 105 106 107 if ( ! pool.hasActiveConnections() ) m_poolTable.remove(name); 112 } 113 114 } 115 116 117 125 public synchronized ConnectionPool getPool( String name ) 126 { 127 return (ConnectionPool) m_poolTable.get(name); 128 } 129 130 } 131 | Popular Tags |