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

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

Introduction

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

Prototype

int DEFAULT_MIN_IDLE

To view the source code for org.apache.commons.pool.impl GenericObjectPool DEFAULT_MIN_IDLE.

Click Source Link

Document

The default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.

Usage

From source file:com.ibm.xsp.extlib.relational.jdbc.datasource.dbcp.NSFFileJdbcDBCPProvider.java

public IJdbcResourceFactory loadConnection(Document doc, String name) throws XMLException, PoolException {

    // Common parameters
    String driver = getStringValue(doc, "/jdbc/driver", null); // $NON-NLS-1$
    String url = getStringValue(doc, "/jdbc/url", null); // $NON-NLS-1$
    String user = getStringValue(doc, "/jdbc/user", null); // $NON-NLS-1$
    String password = DOMAccessor.getStringValue(doc, "/jdbc/password"); // $NON-NLS-1$
    // dbcp pool parameters
    int minIdle = getIntValue(doc, "/jdbc/dbcp/minIdle", GenericObjectPool.DEFAULT_MIN_IDLE); // $NON-NLS-1$
    int maxIdle = getIntValue(doc, "/jdbc/dbcp/maxIdle", GenericObjectPool.DEFAULT_MAX_IDLE); // $NON-NLS-1$
    int maxActive = getIntValue(doc, "/jdbc/dbcp/maxActive", GenericObjectPool.DEFAULT_MAX_ACTIVE); // $NON-NLS-1$
    long maxWait = getLongValue(doc, "/jdbc/dbcp/maxWait", GenericObjectPool.DEFAULT_MAX_WAIT); // $NON-NLS-1$
    DbcpPoolDataSource dbcpDS = new DbcpPoolDataSource(name, driver, url, user, password, minIdle, maxIdle,
            maxActive, maxWait);//from   w  ww.  j  av a  2s . c  o  m
    return dbcpDS;

}

From source file:com.toolsverse.etl.sql.connection.PooledAliasConnectionProvider.java

/**
 * Instantiates a new pooled alias connection provider.
 *//* w  ww .  j  ava2  s . c  o m*/
public PooledAliasConnectionProvider() {
    _config = new GenericObjectPool.Config();

    _config.maxActive = Utils.str2Int(SystemConfig.instance().getSystemProperty(MAX_ACTIVE),
            GenericObjectPool.DEFAULT_MAX_ACTIVE);

    _config.whenExhaustedAction = Utils.str2Byte(
            SystemConfig.instance().getSystemProperty(WHEN_EXHAUSTED_ACTION),
            GenericObjectPool.WHEN_EXHAUSTED_GROW);

    _config.maxWait = Utils.str2Long(SystemConfig.instance().getSystemProperty(MAX_WAIT), 1000 * 30);

    _config.maxIdle = Utils.str2Int(SystemConfig.instance().getSystemProperty(MAX_IDLE),
            GenericObjectPool.DEFAULT_MAX_IDLE);

    _config.minIdle = Utils.str2Int(SystemConfig.instance().getSystemProperty(MIN_IDLE),
            GenericObjectPool.DEFAULT_MIN_IDLE);

    _config.testOnBorrow = Utils.str2Boolean(SystemConfig.instance().getSystemProperty(TEST_ON_BORROW),
            GenericObjectPool.DEFAULT_TEST_ON_BORROW);

    _config.testOnReturn = Utils.str2Boolean(SystemConfig.instance().getSystemProperty(TEST_ON_RETURN),
            GenericObjectPool.DEFAULT_TEST_ON_RETURN);

    _config.timeBetweenEvictionRunsMillis = Utils.str2Long(
            SystemConfig.instance().getSystemProperty(TIME_BETWEEN_EVICTION_RUNS_MILLIS),
            GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);

    _config.numTestsPerEvictionRun = Utils.str2Int(
            SystemConfig.instance().getSystemProperty(NUM_TESTS_PER_EVICTION_RUN),
            GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN);

    _config.minEvictableIdleTimeMillis = Utils.str2Long(
            SystemConfig.instance().getSystemProperty(MIN_EVICTABLE_IDLE_TIME_MILLIS),
            GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    _config.testWhileIdle = Utils.str2Boolean(SystemConfig.instance().getSystemProperty(TEST_WHILE_IDLE),
            GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
}

From source file:org.apache.avalon.dbcp.DbcpConnectionManager.java

/**
 * Returns an object pool configuration object populated with data
 * retrieved from the component's configuration.  Defaults correspond
 * to the <code>GenericObjectPool</code> default values.
 *   /*www  .j  a v a 2  s  .  c  o  m*/
 * @return <code>GenericObjectPool.Config</code> instance containing
 * the pool's configuration parameters
 */
private GenericObjectPool.Config getPoolConfig() {
    GenericObjectPool.Config config = new GenericObjectPool.Config();
    if (m_pool != null) {
        config.maxActive = m_pool.getAttributeAsInteger("max-active", GenericObjectPool.DEFAULT_MAX_ACTIVE);
        config.maxIdle = m_pool.getAttributeAsInteger("max-idle", GenericObjectPool.DEFAULT_MAX_IDLE);
        config.maxWait = m_pool.getAttributeAsLong("max-wait", GenericObjectPool.DEFAULT_MAX_WAIT);
        config.minEvictableIdleTimeMillis = m_pool.getAttributeAsLong("min-evict-idle-time",
                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
        config.minIdle = m_pool.getAttributeAsInteger("min-idle", GenericObjectPool.DEFAULT_MIN_IDLE);
        config.numTestsPerEvictionRun = m_pool.getAttributeAsInteger("num-evict-tests",
                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
        config.testOnBorrow = m_pool.getAttributeAsBoolean("test-on-borrow",
                GenericObjectPool.DEFAULT_TEST_ON_BORROW);
        config.testOnReturn = m_pool.getAttributeAsBoolean("test-on-return",
                GenericObjectPool.DEFAULT_TEST_ON_RETURN);
        config.testWhileIdle = m_pool.getAttributeAsBoolean("test-while-idle",
                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
        config.timeBetweenEvictionRunsMillis = m_pool.getAttributeAsLong("time-between-evict-runs",
                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
        config.whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
    }
    return config;
}

From source file:org.apache.cayenne.conf.CustomDBCPDataSourceBuilder.java

private GenericObjectPool.Config createConnectionPoolConfig() {
    GenericObjectPool.Config poolConfig = new GenericObjectPool.Config();

    poolConfig.maxIdle = config.getInt(MAX_IDLE, GenericObjectPool.DEFAULT_MAX_IDLE);
    poolConfig.minIdle = config.getInt(MIN_IDLE, GenericObjectPool.DEFAULT_MIN_IDLE);
    poolConfig.maxActive = config.getInt(MAX_ACTIVE, GenericObjectPool.DEFAULT_MAX_ACTIVE);
    poolConfig.maxWait = config.getLong(MAX_WAIT, GenericObjectPool.DEFAULT_MAX_WAIT);

    poolConfig.testOnBorrow = config.getBoolean(TEST_ON_BORROW, GenericObjectPool.DEFAULT_TEST_ON_BORROW);
    poolConfig.testOnReturn = config.getBoolean(TEST_ON_RETURN, GenericObjectPool.DEFAULT_TEST_ON_RETURN);
    poolConfig.testWhileIdle = config.getBoolean(TEST_IDLE, GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);

    poolConfig.timeBetweenEvictionRunsMillis = config.getLong(TIME_BETWEEN_EVICTIONS,
            GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
    poolConfig.numTestsPerEvictionRun = config.getInt(NUM_TEST_PER_EVICTION,
            GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
    poolConfig.minEvictableIdleTimeMillis = config.getLong(MIN_EVICTABLE_TIME,
            GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    poolConfig.whenExhaustedAction = config.getWhenExhaustedAction(EXHAUSTED_ACTION,
            GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION);

    return poolConfig;
}

From source file:org.apache.hadoop.hive.metastore.datasource.DbCPDataSourceProvider.java

@Override
public DataSource create(Configuration hdpConfig) throws SQLException {

    LOG.debug("Creating dbcp connection pool for the MetaStore");

    String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig);
    String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig);
    String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig);
    int maxPoolSize = hdpConfig.getInt(MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS.getVarname(),
            ((Long) MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS.getDefaultVal()).intValue());
    long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L);
    int connectionMaxIlde = hdpConfig.getInt(CONNECTION_MAX_IDLE_PROPERTY, GenericObjectPool.DEFAULT_MAX_IDLE);
    int connectionMinIlde = hdpConfig.getInt(CONNECTION_MIN_IDLE_PROPERTY, GenericObjectPool.DEFAULT_MIN_IDLE);
    boolean testOnBorrow = hdpConfig.getBoolean(CONNECTION_TEST_BORROW_PROPERTY,
            GenericObjectPool.DEFAULT_TEST_ON_BORROW);
    long evictionTimeMillis = hdpConfig.getLong(CONNECTION_MIN_EVICT_MILLIS_PROPERTY,
            GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    boolean testWhileIdle = hdpConfig.getBoolean(CONNECTION_TEST_IDLEPROPERTY,
            GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
    long timeBetweenEvictionRuns = hdpConfig.getLong(CONNECTION_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
            GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
    int numTestsPerEvictionRun = hdpConfig.getInt(CONNECTION_NUM_TESTS_PER_EVICTION_RUN,
            GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
    boolean testOnReturn = hdpConfig.getBoolean(CONNECTION_TEST_ON_RETURN,
            GenericObjectPool.DEFAULT_TEST_ON_RETURN);
    long softMinEvictableIdleTimeMillis = hdpConfig.getLong(CONNECTION_SOFT_MIN_EVICTABLE_IDLE_TIME,
            GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    boolean lifo = hdpConfig.getBoolean(CONNECTION_LIFO, GenericObjectPool.DEFAULT_LIFO);

    GenericObjectPool objectPool = new GenericObjectPool();
    objectPool.setMaxActive(maxPoolSize);
    objectPool.setMaxWait(connectionTimeout);
    objectPool.setMaxIdle(connectionMaxIlde);
    objectPool.setMinIdle(connectionMinIlde);
    objectPool.setTestOnBorrow(testOnBorrow);
    objectPool.setTestWhileIdle(testWhileIdle);
    objectPool.setMinEvictableIdleTimeMillis(evictionTimeMillis);
    objectPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRuns);
    objectPool.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    objectPool.setTestOnReturn(testOnReturn);
    objectPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
    objectPool.setLifo(lifo);/*from w  w  w .ja  v  a  2  s  . c o  m*/

    ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd);
    // This doesn't get used, but it's still necessary, see
    // https://git1-us-west.apache.org/repos/asf?p=commons-dbcp.git;a=blob;f=doc/ManualPoolingDataSourceExample.java;
    // h=f45af2b8481f030b27364e505984c0eef4f35cdb;hb=refs/heads/DBCP_1_5_x_BRANCH
    new PoolableConnectionFactory(connFactory, objectPool, null, null, false, true);

    return new PoolingDataSource(objectPool);
}

From source file:org.apache.synapse.commons.datasource.factory.DataSourceInformationFactory.java

/**
 * Factory method to create a DataSourceInformation instance based on given properties
 *
 * @param dsName     DataSource Name//from www . j ava  2  s . c o  m
 * @param properties Properties to create and configure DataSource
 * @return DataSourceInformation instance
 */
public static DataSourceInformation createDataSourceInformation(String dsName, Properties properties) {

    if (dsName == null || "".equals(dsName)) {
        if (log.isDebugEnabled()) {
            log.debug("DataSource name is either empty or null, ignoring..");
        }
        return null;
    }

    StringBuffer buffer = new StringBuffer();
    buffer.append(DataSourceConstants.PROP_SYNAPSE_PREFIX_DS);
    buffer.append(DataSourceConstants.DOT_STRING);
    buffer.append(dsName);
    buffer.append(DataSourceConstants.DOT_STRING);

    // Prefix for getting particular data source's properties
    String prefix = buffer.toString();

    String driver = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DRIVER_CLS_NAME,
            null);
    if (driver == null) {
        handleException(prefix + DataSourceConstants.PROP_DRIVER_CLS_NAME + " cannot be found.");
    }

    String url = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_URL, null);
    if (url == null) {
        handleException(prefix + DataSourceConstants.PROP_URL + " cannot be found.");
    }

    DataSourceInformation datasourceInformation = new DataSourceInformation();
    datasourceInformation.setAlias(dsName);

    datasourceInformation.setDriver(driver);
    datasourceInformation.setUrl(url);

    String dataSourceName = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DS_NAME,
            dsName, String.class);
    datasourceInformation.setDatasourceName(dataSourceName);

    String dsType = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TYPE,
            DataSourceConstants.PROP_BASIC_DATA_SOURCE, String.class);

    datasourceInformation.setType(dsType);

    String repositoryType = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_REGISTRY, DataSourceConstants.PROP_REGISTRY_MEMORY, String.class);

    datasourceInformation.setRepositoryType(repositoryType);

    Integer maxActive = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_ACTIVE,
            GenericObjectPool.DEFAULT_MAX_ACTIVE, Integer.class);
    datasourceInformation.setMaxActive(maxActive);

    Integer maxIdle = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_IDLE,
            GenericObjectPool.DEFAULT_MAX_IDLE, Integer.class);
    datasourceInformation.setMaxIdle(maxIdle);

    Long maxWait = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_WAIT,
            GenericObjectPool.DEFAULT_MAX_WAIT, Long.class);

    datasourceInformation.setMaxWait(maxWait);

    // Construct DriverAdapterCPDS reference
    String suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING
            + DataSourceConstants.PROP_CLASS_NAME;
    String className = MiscellaneousUtil.getProperty(properties, prefix + suffix,
            DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
    datasourceInformation.addParameter(suffix, className);
    suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING
            + DataSourceConstants.PROP_FACTORY;
    String factory = MiscellaneousUtil.getProperty(properties, prefix + suffix,
            DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
    datasourceInformation.addParameter(suffix, factory);
    suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING
            + DataSourceConstants.PROP_NAME;
    String name = MiscellaneousUtil.getProperty(properties, prefix + suffix, "cpds");
    datasourceInformation.addParameter(suffix, name);

    boolean defaultAutoCommit = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_DEFAULT_AUTO_COMMIT, true, Boolean.class);

    boolean defaultReadOnly = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_DEFAULT_READ_ONLY, false, Boolean.class);

    boolean testOnBorrow = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_TEST_ON_BORROW, true, Boolean.class);

    boolean testOnReturn = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_TEST_ON_RETURN, false, Boolean.class);

    long timeBetweenEvictionRunsMillis = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
            GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, Long.class);

    int numTestsPerEvictionRun = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_NUM_TESTS_PER_EVICTION_RUN,
            GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, Integer.class);

    long minEvictableIdleTimeMillis = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_MIN_EVICTABLE_IDLE_TIME_MILLIS,
            GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, Long.class);

    boolean testWhileIdle = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_TEST_WHILE_IDLE, false, Boolean.class);

    String validationQuery = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_VALIDATION_QUERY, null);

    int minIdle = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MIN_IDLE,
            GenericObjectPool.DEFAULT_MIN_IDLE, Integer.class);

    int initialSize = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_INITIAL_SIZE,
            0, Integer.class);

    int defaultTransactionIsolation = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_DEFAULT_TRANSACTION_ISOLATION, -1, Integer.class);

    String defaultCatalog = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_DEFAULT_CATALOG, null);

    boolean accessToUnderlyingConnectionAllowed = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED, false, Boolean.class);

    boolean removeAbandoned = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_REMOVE_ABANDONED, false, Boolean.class);

    int removeAbandonedTimeout = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_REMOVE_ABANDONED_TIMEOUT, 300, Integer.class);

    boolean logAbandoned = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_LOG_ABANDONED, false, Boolean.class);

    boolean poolPreparedStatements = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_POOL_PREPARED_STATEMENTS, false, Boolean.class);

    int maxOpenPreparedStatements = MiscellaneousUtil.getProperty(properties,
            prefix + DataSourceConstants.PROP_MAX_OPEN_PREPARED_STATEMENTS,
            GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, Integer.class);

    datasourceInformation.setDefaultAutoCommit(defaultAutoCommit);
    datasourceInformation.setDefaultReadOnly(defaultReadOnly);
    datasourceInformation.setTestOnBorrow(testOnBorrow);
    datasourceInformation.setTestOnReturn(testOnReturn);
    datasourceInformation.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    datasourceInformation.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    datasourceInformation.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    datasourceInformation.setTestWhileIdle(testWhileIdle);
    datasourceInformation.setMinIdle(minIdle);
    datasourceInformation.setDefaultTransactionIsolation(defaultTransactionIsolation);
    datasourceInformation.setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
    datasourceInformation.setRemoveAbandoned(removeAbandoned);
    datasourceInformation.setRemoveAbandonedTimeout(removeAbandonedTimeout);
    datasourceInformation.setLogAbandoned(logAbandoned);
    datasourceInformation.setPoolPreparedStatements(poolPreparedStatements);
    datasourceInformation.setMaxOpenPreparedStatements(maxOpenPreparedStatements);
    datasourceInformation.setInitialSize(initialSize);

    if (validationQuery != null && !"".equals(validationQuery)) {
        datasourceInformation.setValidationQuery(validationQuery);
    }

    if (defaultCatalog != null && !"".equals(defaultCatalog)) {
        datasourceInformation.setDefaultCatalog(defaultCatalog);
    }

    datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_IC_FACTORY,
            MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_IC_FACTORY, null));
    //Provider URL
    datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_PROVIDER_URL,
            MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_PROVIDER_URL, null));

    datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_PROVIDER_PORT,
            MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_PROVIDER_PORT, null));

    String passwordPrompt = MiscellaneousUtil.getProperty(properties,
            prefix + SecurityConstants.PROP_PASSWORD_PROMPT, "Password for datasource " + dsName, String.class);

    SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(properties, prefix,
            passwordPrompt);
    secretInformation.setToken(dsName + "." + SecurityConstants.PROP_PASSWORD);
    datasourceInformation.setSecretInformation(secretInformation);

    return datasourceInformation;
}

From source file:org.apache.synapse.util.DataSourceRegistrar.java

/**
 * Helper method to set all BasicDataSource specific parameter
 *
 * @param reference  The naming reference instance
 * @param properties The properties which contains required parameter value
 * @param prefix     The key prefix for which is used to get data from given properties
 *//* w  ww.ja v a2  s.  c om*/
private static void setBasicDataSourceParameters(Reference reference, Properties properties, String prefix) {
    String minIdle = getProperty(properties, prefix + PROP_MINIDLE,
            String.valueOf(GenericObjectPool.DEFAULT_MIN_IDLE));
    String initialSize = getProperty(properties, prefix + PROP_INITIALSIZE, String.valueOf(0));
    String defaultTransactionIsolation = getProperty(properties, prefix + PROP_DEFAULTTRANSACTIONISOLATION,
            null);
    String defaultCatalog = getProperty(properties, prefix + PROP_DEFAULTCATALOG, null);
    String accessToUnderlyingConnectionAllowed = getProperty(properties,
            prefix + PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED, String.valueOf(false));
    String removeAbandoned = getProperty(properties, prefix + PROP_REMOVEABANDONED, String.valueOf(false));
    String removeAbandonedTimeout = getProperty(properties, prefix + PROP_REMOVEABANDONEDTIMEOUT,
            String.valueOf(300));
    String logAbandoned = getProperty(properties, prefix + PROP_LOGABANDONED, String.valueOf(false));
    String poolPreparedStatements = getProperty(properties, prefix + PROP_POOLPREPAREDSTATEMENTS,
            String.valueOf(false));
    String maxOpenPreparedStatements = getProperty(properties, prefix + PROP_MAXOPENPREPAREDSTATEMENTS,
            String.valueOf(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL));

    reference.add(new StringRefAddr(PROP_MINIDLE, minIdle));
    if (defaultTransactionIsolation != null && !"".equals(defaultTransactionIsolation)) {
        reference.add(new StringRefAddr(PROP_DEFAULTTRANSACTIONISOLATION, defaultTransactionIsolation));
    }
    reference.add(
            new StringRefAddr(PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED, accessToUnderlyingConnectionAllowed));
    reference.add(new StringRefAddr(PROP_REMOVEABANDONED, removeAbandoned));
    reference.add(new StringRefAddr(PROP_REMOVEABANDONEDTIMEOUT, removeAbandonedTimeout));
    reference.add(new StringRefAddr(PROP_LOGABANDONED, logAbandoned));
    reference.add(new StringRefAddr(PROP_POOLPREPAREDSTATEMENTS, poolPreparedStatements));
    reference.add(new StringRefAddr(PROP_MAXOPENPREPAREDSTATEMENTS, maxOpenPreparedStatements));
    reference.add(new StringRefAddr(PROP_INITIALSIZE, initialSize));
    if (defaultCatalog != null && !"".equals(defaultCatalog)) {
        reference.add(new StringRefAddr(PROP_DEFAULTCATALOG, defaultCatalog));
    }
}

From source file:org.ow2.petals.binding.soap.SoapComponentContext.java

/**
 * <p>//from w  ww  .j  av a2 s. c  o  m
 * Get a service client associated to an axis service set with the good
 * operation. It is taken from a pool object.
 * </p>
 * <p>
 * <b>This service client must be returned to the pool after usage using
 * API:
 * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * .</b>
 * </p>
 * 
 * @param address
 *            the address of the service, mainly used as key to retrieve the
 *            associated SU.
 * @param operation
 *            the target operation QName. Non null
 * @param mep
 *            the message exchange pattern used. Non null
 * @param cdkExtensions
 *            SU extensions used by the service client pool when the
 *            creation of a service client is needed
 * @param provides
 *            the provides block of the endpoint which is creating the
 *            external WS call
 * @param ramprtUserName 
 * @return a ServiceClient. Not null. Must be returned to the pool after
 *         usage using API:
 *         <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * @throws HandlingException
 */
public ServiceClient borrowServiceClient(final String address, final QName operation, final String soapAction,
        final URI mep, final ConfigurationExtensions cdkExtensions, final Provides provides,
        String rampartUserName) throws MessagingException {

    try {

        String resolvedOp;
        if (operation != null) {
            resolvedOp = operation.toString();
        } else if (soapAction != null) {
            resolvedOp = soapAction;
        } else {
            throw new MessagingException(
                    "Unable to resolve the operation. Set it in the Jbi exchange or SoapAction.");
        }

        final ServiceClientKey key = new ServiceClientKey(address, resolvedOp, mep);
        ObjectPool pool = this.serviceClientPools.get(key);
        if (pool == null) {
            // TODO: The pool max size should be limited by the JBI worker
            // number
            pool = new GenericObjectPool(
                    // object factory
                    new ServiceClientPoolObjectFactory(address, operation, mep, cdkExtensions, this, provides,
                            this.logger, soapAction, rampartUserName),

                    // max number of borrowed object sized to the number of
                    // JBI message processors
                    this.componentConfiguration.getProcessorPoolSize().getValue(),

                    // getting an object blocks until a new or idle object
                    // is available
                    GenericObjectPool.WHEN_EXHAUSTED_BLOCK,

                    // if getting an object is blocked for at most this
                    // delay, a NoSuchElementException will be thrown. In
                    // case of a synchronous call the delay is sized to the
                    // value of the SU's parameter "synchronous-timeout",
                    // otherwise it sized to 5 minutes.
                    MEPConstants.IN_OUT_PATTERN.equals(mep) || MEPConstants.IN_OPTIONAL_OUT_PATTERN.equals(mep)
                            ? SUPropertiesHelper.retrieveTimeout(cdkExtensions)
                            : 300000l,

                    // max number of idle object in the pool. Sized to the
                    // number of JBI acceptors.
                    this.componentConfiguration.getAcceptorPoolSize().getValue(),

                    // min number of idle object in the pool. Sized to 0
                    // (ie when no activity no object in pool)
                    GenericObjectPool.DEFAULT_MIN_IDLE,

                    // no validation test of the borrowed object
                    false,

                    // no validation test of the returned object
                    false,

                    // how long the eviction thread should sleep before
                    // "runs" of examining idle objects. Sized to 5min.
                    300000l,

                    // the number of objects examined in each run of the
                    // idle object evictor. Size to the default value (ie.
                    // 3)
                    GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,

                    // the minimum amount of time that an object may sit
                    // idle in the pool before it is eligible for eviction
                    // due to idle time. Sized to 30min
                    GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // no validation test of the idle object
                    false,

                    // the minimum amount of time an object may sit idle in
                    // the pool before it is eligible for eviction by the
                    // idle object evictor (if any), with the extra
                    // condition that at least "minIdle" amount of object
                    // remain in the pool.
                    GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // the pool returns idle objects in last-in-first-out
                    // order
                    true);

            this.serviceClientPools.put(key, pool);
        }

        return (ServiceClient) pool.borrowObject();

    } catch (final Exception e) {
        throw new MessagingException("Can't create get an Axis service client from the pool", e);
    }
}

From source file:org.ow2.petals.binding.soapproxy.SoapComponentContext.java

/**
 * <p>/*from   w w w  .  j  a  v  a 2 s  .  c om*/
 * Get a service client associated to an axis service set with the good
 * operation. It is taken from a pool object.
 * </p>
 * <p>
 * <b>This service client must be returned to the pool after usage using
 * API:
 * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * .</b>
 * </p>
 * 
 * @param address
 *            the address of the service, mainly used as key to retrieve the
 *            associated SU.
 * @param operation
 *            the target operation QName. Non null
 * @param mep
 *            the message exchange pattern used. Non null
 * @param cdkExtensions
 *            SU extensions used by the service client pool when the
 *            creation of a service client is needed
 * @param provides
 *            the provides block of the endpoint which is creating the
 *            external WS call
 * @param ramprtUserName
 * @return a ServiceClient. Not null. Must be returned to the pool after
 *         usage using API:
 *         <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * @throws HandlingException
 */
public ServiceClient borrowServiceClient(final String address, final QName operation, final String soapAction,
        final URI mep) throws MessagingException {

    try {

        String resolvedOp;
        if (operation != null) {
            resolvedOp = operation.toString();
        } else if (soapAction != null) {
            resolvedOp = soapAction;
        } else {
            throw new MessagingException(
                    "Unable to resolve the operation. Set it in the Jbi exchange or SoapAction.");
        }

        final ServiceClientKey key = new ServiceClientKey(address, resolvedOp, mep);
        ObjectPool pool = this.serviceClientPools.get(key);
        if (pool == null) {
            // TODO: The pool max size should be limited by the JBI worker
            // number
            pool = new GenericObjectPool(
                    // object factory
                    new ServiceClientPoolObjectFactory(address, operation, mep, this, this.logger, soapAction),

                    // max number of borrowed object sized to the number of
                    // JBI message processors
                    this.componentConfiguration.getProcessorPoolSize().getValue(),

                    // getting an object blocks until a new or idle object
                    // is available
                    GenericObjectPool.WHEN_EXHAUSTED_BLOCK,

                    // if getting an object is blocked for at most this
                    // delay, a NoSuchElementException will be thrown. In
                    // case of a synchronous call the delay is sized to the
                    // value of the SU's parameter "synchronous-timeout",
                    // otherwise it sized to 5 minutes.
                    MEPConstants.IN_OUT_PATTERN.equals(mep) || MEPConstants.IN_OPTIONAL_OUT_PATTERN.equals(mep)
                            ? 300000l
                            : 300000l,

                    // max number of idle object in the pool. Sized to the
                    // number of JBI acceptors.
                    this.componentConfiguration.getAcceptorPoolSize().getValue(),

                    // min number of idle object in the pool. Sized to 0
                    // (ie when no activity no object in pool)
                    GenericObjectPool.DEFAULT_MIN_IDLE,

                    // no validation test of the borrowed object
                    false,

                    // no validation test of the returned object
                    false,

                    // how long the eviction thread should sleep before
                    // "runs" of examining idle objects. Sized to 5min.
                    300000l,

                    // the number of objects examined in each run of the
                    // idle object evictor. Size to the default value (ie.
                    // 3)
                    GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,

                    // the minimum amount of time that an object may sit
                    // idle in the pool before it is eligible for eviction
                    // due to idle time. Sized to 30min
                    GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // no validation test of the idle object
                    false,

                    // the minimum amount of time an object may sit idle in
                    // the pool before it is eligible for eviction by the
                    // idle object evictor (if any), with the extra
                    // condition that at least "minIdle" amount of object
                    // remain in the pool.
                    GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // the pool returns idle objects in last-in-first-out
                    // order
                    true);

            this.serviceClientPools.put(key, pool);
        }

        return (ServiceClient) pool.borrowObject();

    } catch (final Exception e) {
        throw new MessagingException("Can't create get an Axis service client from the pool", e);
    }
}