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


Java KeyedObjectPool.setFactory方法代码示例

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


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

示例1: wrapConnection

import org.apache.commons.pool.KeyedObjectPool; //导入方法依赖的package包/类
protected PreparedStatementCachingConnection wrapConnection(Connection realConnection) {
	// can't initialize the following variable in the constructor because the prepared statement cache size won't be available
	if (_stmtPoolFactory == null) {
		_stmtPoolFactory = createStatementPoolFactory();
	}
	
       KeyedObjectPool stmtpool = _stmtPoolFactory.createPool();
       PreparedStatementCachingConnection wrappedConnection = new PreparedStatementCachingConnection(realConnection, stmtpool);
       
       stmtpool.setFactory(wrappedConnection);
       return wrappedConnection;
}
 
开发者ID:kuali,项目名称:rice,代码行数:13,代码来源:RiceXADataSource.java

示例2: makeObject

import org.apache.commons.pool.KeyedObjectPool; //导入方法依赖的package包/类
public Object makeObject() throws Exception {
    Connection conn = _connFactory.createConnection();
    if (conn == null) {
        throw new IllegalStateException("Connection factory returned null from createConnection");
    }
    initializeConnection(conn);
    if(null != _stmtPoolFactory) {
        KeyedObjectPool stmtpool = _stmtPoolFactory.createPool();
        conn = new PoolingConnection(conn,stmtpool);
        stmtpool.setFactory((PoolingConnection)conn);
    }
    return new PoolableConnection(conn,_pool,_config);
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:14,代码来源:PoolableConnectionFactory.java

示例3: testSetFactory

import org.apache.commons.pool.KeyedObjectPool; //导入方法依赖的package包/类
public void testSetFactory() throws Exception {
    KeyedObjectPool pool = new StackKeyedObjectPool();
    try {
        pool.borrowObject("x");
        fail("Expected NoSuchElementException");
    } catch(NoSuchElementException e) {
        // expected
    }
    pool.setFactory(new SimpleFactory());
    Object obj = pool.borrowObject("x");
    assertNotNull(obj);
    pool.returnObject("x",obj);
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:14,代码来源:TestStackKeyedObjectPool.java

示例4: testCantResetFactoryWithActiveObjects

import org.apache.commons.pool.KeyedObjectPool; //导入方法依赖的package包/类
public void testCantResetFactoryWithActiveObjects() throws Exception {
    KeyedObjectPool pool = new StackKeyedObjectPool();
    pool.setFactory(new SimpleFactory());
    Object obj = pool.borrowObject("x");
    assertNotNull(obj);

    try {
        pool.setFactory(new SimpleFactory());
        fail("Expected IllegalStateException");
    } catch(IllegalStateException e) {
        // expected
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:14,代码来源:TestStackKeyedObjectPool.java

示例5: KeyedCPDSConnectionFactory

import org.apache.commons.pool.KeyedObjectPool; //导入方法依赖的package包/类
/**
 * Create a new <tt>KeyedPoolableConnectionFactory</tt>.
 * @param cpds the ConnectionPoolDataSource from which to obtain
 * PooledConnections
 * @param pool the {@link KeyedObjectPool} in which to pool those
 * {@link Connection}s
 * @param validationQuery a query to use to {@link #validateObject validate}
 * {@link Connection}s.  Should return at least one row. May be <tt>null</tt>
 * @param rollbackAfterValidation whether a rollback should be issued after
 * {@link #validateObject validating} {@link Connection}s.
 */
public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds, 
                                  KeyedObjectPool pool, 
                                  String validationQuery,
                                  boolean rollbackAfterValidation) {
    _cpds = cpds;
    _pool = pool;
    pool.setFactory(this);
    _validationQuery = validationQuery;
    _rollbackAfterValidation = rollbackAfterValidation;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:22,代码来源:KeyedCPDSConnectionFactory.java


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