当前位置: 首页>>代码示例>>Java>>正文


Java ObjectPool.close方法代码示例

本文整理汇总了Java中org.apache.commons.pool.ObjectPool.close方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectPool.close方法的具体用法?Java ObjectPool.close怎么用?Java ObjectPool.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.pool.ObjectPool的用法示例。


在下文中一共展示了ObjectPool.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: close

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
/**
 * 關閉
 * 
 * @throws CacheException
 */
public synchronized void close() throws CacheException {
	if (this.closed) {
		throw new CacheException("CacheFactory was already closed");
	}
	//
	try {
		// TODO cacheHolder 未清, 需用反射清除
		this.closed = true;
		ObjectPool<T> oldPool = this.objectPool;
		this.objectPool = null;
		if (oldPool != null) {
			oldPool.close();
		}
	} catch (Exception ex) {
		throw new CacheException("Cannot close pool", ex);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:23,代码来源:PoolingCacheFactory.java

示例2: releaseAllResources

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
/**
 * Closes all managed pools.
 */
public void releaseAllResources()
{
    synchronized (poolSynch)
    {
        Collection pools = poolMap.values();
        poolMap = new HashMap(poolMap.size());
        ObjectPool op = null;
        for (Iterator iterator = pools.iterator(); iterator.hasNext();)
        {
            try
            {
                op = ((ObjectPool) iterator.next());
                op.close();
            }
            catch (Exception e)
            {
                log.error("Exception occured while closing pool " + op, e);
            }
        }
    }
    super.releaseAllResources();
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:ConnectionFactoryPooledImpl.java

示例3: testAddObject

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
public void testAddObject() throws Exception {
    assertEquals("should be zero idle", 0, pool.getNumIdle());
    pool.addObject();
    assertEquals("should be one idle", 1, pool.getNumIdle());
    assertEquals("should be zero active", 0, pool.getNumActive());
    Object obj = pool.borrowObject();
    assertEquals("should be zero idle", 0, pool.getNumIdle());
    assertEquals("should be one active", 1, pool.getNumActive());
    pool.returnObject(obj);
    assertEquals("should be one idle", 1, pool.getNumIdle());
    assertEquals("should be zero active", 0, pool.getNumActive());

    ObjectPool op = new GenericObjectPool();
    try {
        op.addObject();
        fail("Expected IllegalStateException when there is no factory.");
    } catch (IllegalStateException ise) {
        //expected
    }
    op.close();
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:22,代码来源:TestGenericObjectPool.java

示例4: removeDBPool

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
/**
 * Closes the database connection pool
 */
private void removeDBPool() {
  final ObjectPool dbpool = getDBPool();

  if (dbpool != null) {
    try {
      dbpool.close();
    } catch (Throwable any) {
      LOGGER.error("Unable to close the database connection pool", any);
      messageOut(Resources.getString("errFailCloseDBPool", any.getMessage()),
          STYLE_RED);
    }
  }
}
 
开发者ID:DaveRead,项目名称:BasicQuery,代码行数:17,代码来源:BasicQuery.java

示例5: closePool

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
public synchronized void closePool(String name) throws SQLException {
    ObjectPool pool = (ObjectPool) _pools.get(name);
    if (pool != null) {
        _pools.remove(name);
        try {
            pool.close();
        }
        catch (Exception e) {
            throw (SQLException) new SQLException("Error closing pool " + name).initCause(e);
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:13,代码来源:PoolingDriver.java

示例6: testInitIdleCapacityExceeded

import org.apache.commons.pool.ObjectPool; //导入方法依赖的package包/类
/**
 * Verifies that initIdleCapacity is not a hard limit, but maxIdle is.
 */
public void testInitIdleCapacityExceeded() throws Exception {
    PoolableObjectFactory factory = new SimpleFactory();
    ObjectPool pool = new StackObjectPool(factory, 2, 1);
    pool.addObject();
    pool.addObject();
    assertEquals(2, pool.getNumIdle());
    pool.close();
    pool = new StackObjectPool(factory, 1, 2);
    pool.addObject();
    pool.addObject();
    assertEquals(1, pool.getNumIdle());
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:16,代码来源:TestStackObjectPool.java


注:本文中的org.apache.commons.pool.ObjectPool.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。