Example usage for org.apache.commons.pool.impl GenericObjectPool clear

List of usage examples for org.apache.commons.pool.impl GenericObjectPool clear

Introduction

In this page you can find the example usage for org.apache.commons.pool.impl GenericObjectPool clear.

Prototype

public void clear() 

Source Link

Document

Clears any objects sitting idle in the pool.

Usage

From source file:org.alinous.plugin.mysql.MySQLDataSource.java

public void dispose() {
    GenericObjectPool pool = this.connectionPool;
    this.connectionPool = null;

    pool.clear();

    try {// w  w  w.j  a v  a2s.c o m
        pool.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    AlinousDebug.debugOut(core, "Disposed mysql pool..............");
}

From source file:org.cipango.sipatra.DefaultContextLoader.java

protected void stopPool(GenericObjectPool pool) {
    pool.clear();
    try {//from   w  w  w  .  j  a  va2 s.  c  o m
        pool.close();
    } catch (Exception e) {
        _log.error("ERROR >> Failed to close pool ", e);
    }
}

From source file:org.ofbiz.tenant.jdbc.TenantJdbcConnectionHandler.java

/**
 * delete database// w w w .ja  v a 2 s . c  o m
 * @return
 */
public void deleteDatabase() throws GenericEntityException, SQLException {
    Delegator delegator = tenantDataSource.getDelegator();
    GenericHelperInfo helperInfo = delegator.getGroupHelperInfo(this.getEntityGroupName());
    helperInfo.setTenantId(this.getTenantId());
    Datasource datasource = EntityConfigUtil.getDatasource(helperInfo.getHelperBaseName());
    datasource.inlineJdbc.setJdbcUri(this.getJdbcUri());

    // get pool and shared connection
    DBCPConnectionFactory managedConnectionFactory = (DBCPConnectionFactory) ConnectionFactory
            .getManagedConnectionFactory();
    GenericObjectPool pool = managedConnectionFactory.getGenericObjectPool(helperInfo);
    XAConnectionFactory xacf = managedConnectionFactory.getXAConnectionFactory(helperInfo);

    // return shared connection
    if (UtilValidate.isNotEmpty(xacf)) {
        TransactionRegistry transactionRegistry = xacf.getTransactionRegistry();
        TransactionContext transactionContext = transactionRegistry.getActiveTransactionContext();
        if (UtilValidate.isNotEmpty(transactionContext)) {
            PoolableConnection sharedConnection = (PoolableConnection) transactionContext.getSharedConnection();

            try {
                pool.returnObject(sharedConnection);
                pool.clear();
            } catch (Exception e) {
                Debug.logError(e, module);
            }
        }
    }

    // do delete database
    doDeleteDatabase(helperInfo);

    // remove delegator
    String tenantDelegatorName = delegator.getDelegatorBaseName() + "#" + this.getTenantId();
    DelegatorFactory.removeDelegator(tenantDelegatorName);

    // remove connection
    managedConnectionFactory.removeConnection(helperInfo);
}