// Copyright (c) 1999, 2000 Oracle Corporation package oracle.jbo.common.ampool; import java.util.Hashtable; import java.util.Enumeration; /** ** This class manages the Application Pool. It is a singleton instance. ** ** View implementation of PoolMgr **
** @author Juan Oropeza **/ public class PoolMgr extends Object { static PoolMgr instance = new PoolMgr(); Hashtable poolList = new Hashtable(10); /** ** Constructor **/ private PoolMgr() { } /** ** Retrieves the singleton instance of the Pool Manager **/ static public PoolMgr getInstance() { return instance; } /** ** returns true if the pool has already been created. **/ public synchronized boolean isPoolCreated(String sName) { if(poolList.get(sName) != null) return true; return false; } /** ** Returns the ApplicationPool interface for the named pool. **/ public synchronized ApplicationPool getPool(String sName) { return (ApplicationPool)poolList.get(sName); } /** ** Removes the named pool and calls remove() function on all ApplicationModule ** instances that are being managed by the pool. **/ public synchronized void removePool(String sName) { if(!isPoolCreated(sName)) return; ApplicationPool pool = getPool(sName); poolList.remove(sName); pool.releaseInstances(); } /** ** Create a new Application Module pool, throws an exception if the pool is already registered. ** The connectInfo parameter provides the necessary settings required for creating instances of ** Application Modules that are part of the pool. You can also specify the name of the class that ** implements the ApplicationPool interface. This is an important setting for users that want to provide ** a custom implementation of the ApplicationPool interface. The default ApplicationPool implementation is ** in the oracle.jbo.client.ampool.ApplicationPoolImpl class. **/ public synchronized ApplicationPool createPool(String sName , String sClass, String sApplicationModule, String sConnectString, Hashtable env) throws Exception { if(isPoolCreated(sName)) { throw new RuntimeException("Application Module Pool has already been created: " + sName); } Class poolClass = Class.forName(sClass); ApplicationPool pool = (ApplicationPool)poolClass.newInstance(); pool.initialize(sName, sApplicationModule, sConnectString, env); poolList.put(sName, pool); return pool; } /** ** Create a new Application Module pool, throws an exception if the pool is already registered. ** The connectInfo parameter provides the necessary settings required for creating instances of ** Application Modules that are part of the pool. You can also specify the name of the class that ** implements the ApplicationPool interface. This is an important setting for users that want to provide ** a custom implementation of the ApplicationPool interface. The default ApplicationPool implementation is ** in the oracle.jbo.client.ampool.ApplicationPoolImpl class. **/ public synchronized ApplicationPool createPool(String sName , String sApplicationModule, String sConnectString, Hashtable env) throws Exception { return createPool(sName , "oracle.jbo.common.ampool.ApplicationPoolImpl", sApplicationModule, sConnectString, env); } /** ** Returns the Enumeration interface that allows you to enumerate through ** all the Application Pools that are registered with the Pool Manager. **/ public synchronized Enumeration getPools() { return poolList.elements(); } }