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

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

Introduction

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

Prototype

public GenericObjectPool(PoolableObjectFactory factory, int maxActive) 

Source Link

Document

Create a new GenericObjectPool using the specified values.

Usage

From source file:agiato.cassandra.connect.HostConnections.java

public HostConnections(Host host, GenericObjectPool.Config poolConfig) {
    this.host = host;
    connectionFactory = new ConnectionFactory(host);
    connectionPool = new GenericObjectPool(connectionFactory, poolConfig);
}

From source file:com.github.chrishantha.microbenchmark.objectpool.CommonsPoolGenericObjectPoolBenchmark.java

@Override
public void setupObjectPool() {
    objectPool = new GenericObjectPool<>(new BasePoolableObjectFactory<TestObject>() {
        @Override/*from   w w  w . j a  v  a2s  .c om*/
        public TestObject makeObject() throws Exception {
            return new TestObject(true);
        }
    }, poolSize);
}

From source file:kr.debop4j.core.pool.AbstractPool.java

public AbstractPool(final GenericObjectPool.Config poolConfig, PoolableObjectFactory<T> factory) {
    log.info(" pool ? ?... config=[{}]", poolConfig);

    pool = new GenericObjectPool<T>(factory, poolConfig);
}

From source file:jongo.jdbc.JDBCConnectionFactory.java

/**
 * Instantiates a new JDBCConnectionFactory if required and creates a connections pool for every database.
 * @return the instance of the singleton.
 *//*from ww w .  jav  a2  s. c o m*/
private static JDBCConnectionFactory instanceOf() {
    if (instance == null) {
        instance = new JDBCConnectionFactory();
        for (DatabaseConfiguration db : configuration.getDatabases()) {
            l.debug("Registering Connection Pool for {}", db.getDatabase());
            GenericObjectPool pool = new GenericObjectPool(null, db.getMaxConnections());
            ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(db.toJdbcURL(),
                    db.getUsername(), db.getPassword());
            PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                    connectionFactory, pool, null, null, db.isReadOnly(), true);
            poolableConnectionFactory.hashCode();
            instance.connectionPool.put(db.getDatabase(), pool);
        }
    }
    return instance;
}

From source file:com.jaspersoft.hadoop.hbase.connection.HBaseConnectionManager.java

private GenericObjectPool<HBaseConnection> startConnectionsPool() {
    if (connectionsPool == null) {
        connectionsPool = new GenericObjectPool<HBaseConnection>(connectionFactory, poolConfiguration);
    }//  w w w  .j  a v a  2s.  c o m
    return connectionsPool;
}

From source file:com.khubla.cbean.mongokv.MongoKVService.java

/**
 * ctor/*from   www .java2  s .  c om*/
 */
public MongoKVService(CBeanUrl cBeanUrl) {
    this.cBeanUrl = cBeanUrl;
    mongoClientPool = new GenericObjectPool<MongoClient>(
            new MongoPoolableObjectFactoryImpl(cBeanUrl.getHostName()), MAX_STORAGESERVICE_CONNECTIONS);
}

From source file:com.mydlp.ui.thrift.MyDLPUIThriftServiceImpl.java

@PostConstruct
protected synchronized void init() {
    mydlpUIConnectionPool = new GenericObjectPool<MyDLPUIThriftConnection>(new MyDLPUIThriftConnectionFactory(),
            poolConfig);/*www. ja va  2s. co m*/
}

From source file:com.tdclighthouse.prototype.rmi.RepositoryConnector.java

public RepositoryConnector(String username, String password, String repositoryUrl, Config config)
        throws RepositoryException {
    this.username = username;
    this.password = password;
    this.repositoryUrl = repositoryUrl;
    this.config = config;
    sessionPool = new GenericObjectPool<Session>(new SessionFactory(), getPoolConfig());
}

From source file:com.genentech.struchk.NormalizerPool.java

private NormalizerPool(Set<CHECKType> exclusions, boolean errorAsWarning) {
    Config poolcfg = new Config();
    poolcfg.maxIdle = 3;//from  w ww.  j av a 2  s .  c o m
    poolcfg.maxActive = 20;
    poolcfg.timeBetweenEvictionRunsMillis = 1000 * 3600;
    poolcfg.testWhileIdle = true;
    // since we do not set maxActive for the moment this does not matter
    poolcfg.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
    poolcfg.maxWait = 40000;
    NormalizerFactory fact = new NormalizerFactory(exclusions, errorAsWarning);

    pool = new GenericObjectPool(fact, poolcfg);
}

From source file:com.jaspersoft.mongodb.connection.MongoDbConnectionManager.java

private GenericObjectPool<MongoDbConnection> startConnectionsPool() {
    if (connectionsPool == null) {
        connectionsPool = new GenericObjectPool<MongoDbConnection>(connectionFactory, poolConfiguration);
    }//ww w.j av  a  2s  .c  o m
    return connectionsPool;
}