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) 

Source Link

Document

Create a new GenericObjectPool using the specified factory.

Usage

From source file:org.springframework.aop.target.CommonsPoolTargetSource.java

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons {@code ObjectPool}.
 * @see org.apache.commons.pool.impl.GenericObjectPool
 * @see #setMaxSize/*from w  ww .  j  ava 2s . c o  m*/
 */
protected ObjectPool createObjectPool() {
    GenericObjectPool gop = new GenericObjectPool(this);
    gop.setMaxActive(getMaxSize());
    gop.setMaxIdle(getMaxIdle());
    gop.setMinIdle(getMinIdle());
    gop.setMaxWait(getMaxWait());
    gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
    gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
    gop.setWhenExhaustedAction(getWhenExhaustedAction());
    return gop;
}

From source file:org.springframework.jms.listener.serversession.CommonsPoolServerSessionFactory.java

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @param sessionManager the session manager to use for
 * creating and executing new listener sessions
 * @return an empty Commons <code>ObjectPool</code>.
 * @see org.apache.commons.pool.impl.GenericObjectPool
 * @see #setMaxSize//from  ww  w .  j a v  a  2 s. c o m
 */
protected ObjectPool createObjectPool(ListenerSessionManager sessionManager) {
    GenericObjectPool pool = new GenericObjectPool(createPoolableObjectFactory(sessionManager));
    pool.setMaxActive(getMaxSize());
    pool.setMaxIdle(getMaxIdle());
    pool.setMinIdle(getMinIdle());
    pool.setMaxWait(getMaxWait());
    pool.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
    pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
    return pool;
}

From source file:org.workin.fastdfs.factory.connection.PoolConnectionFactory.java

@Override
public void afterPropertiesSet() throws Exception {
    if (this.trackerServerPool == null)
        this.trackerServerPool = new GenericObjectPool<TrackerServer>(
                new DefaultPoolableTrackerServerFactory());

    if (this.storageServerPool == null) {
        PoolableStorageServerFactory factory = new DefaultPoolableStorageServerFactory();
        factory.setTrackerClient(super.getTrackerClient());
        this.storageServerPool = new GenericObjectPool<StorageServer>(factory);
    } else {// ww  w.j a  v a 2  s  .  co m
        Object fieldValue = ReflectionUtils.getFieldValue(this.storageServerPool, "_factory");
        if (fieldValue instanceof PoolableStorageServerFactory) {
            PoolableStorageServerFactory factory = (PoolableStorageServerFactory) fieldValue;
            if (factory.getTrackerClient() == null)
                factory.setTrackerClient(super.getTrackerClient());
        }
    }
}

From source file:org.wsm.database.tools.util.FANConnectionManager.java

public void setupDataSource(String dsName) {
    try {/*from w w w .  j  av  a  2 s .com*/
        OracleDataSource ods = super.getBasicDataSourceSetup(dsName);

        java.util.Properties prop = new java.util.Properties();
        prop.setProperty("MinLimit", "5");
        prop.setProperty("MaxLimit", "45");
        ods.setConnectionCacheName("FanConnectionCache01");
        ods.setConnectionCachingEnabled(true);
        ods.setConnectionCacheProperties(prop);
        ods.setFastConnectionFailoverEnabled(true);
        ObjectPool connectionPool = new GenericObjectPool(null);
        ConnectionFactory connectionFactory = new DataSourceConnectionFactory(ods);
        PoolableConnectionFactory pcf = new PoolableConnectionFactory(connectionFactory, connectionPool, null,
                null, false, true);
        PoolingDataSource pds = new PoolingDataSource(connectionPool);
        addPoolingDataSourceToBucket(dsName, pds);
        //addOracleDataSourceToBucket(dsName, ods);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:org.wso2.carbon.andes.authentication.andes.OAuth2BasedMQTTAuthenticator.java

/**
 * Initialize the OAUTH2ValidationStubFactory  to communicate with the OAuth2TokenValidationService
 *//* www .j a v  a 2 s.  c  o  m*/
public OAuth2BasedMQTTAuthenticator() {
    stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory());
}

From source file:org.wso2.carbon.device.mgt.extensions.remote.session.authentication.oauth.OAuthTokenValidator.java

public OAuthTokenValidator(Map<String, String> globalProperties) {
    this.stubs = new GenericObjectPool(new OAuthTokenValidatorStubFactory(globalProperties));
}

From source file:org.wso2.carbon.device.mgt.input.adapter.http.oauth.OAuthAuthenticator.java

public OAuthAuthenticator(Map<String, String> globalProperties) {
    this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(globalProperties));
}

From source file:org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.OAuthAuthenticator.java

public OAuthAuthenticator(InputEventAdapterConfiguration eventAdapterConfiguration) {
    this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(eventAdapterConfiguration));
}

From source file:org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.OAuthTokenValdiator.java

private OAuthTokenValdiator() {
    try {/*from w  w  w  .jav a 2s.c  o m*/
        Properties properties = getWebSocketConfig();
        this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(properties));
    } catch (IOException e) {
        log.error("Failed to parse the web socket org.wso2.carbon.device.mgt.iot.output.adapter.ui.config file "
                + WEBSOCKET_CONFIG_LOCATION, e);
    }
}

From source file:org.wso2.carbon.device.mgt.mobile.windows.api.common.authenticator.impl.RemoteOAuthValidator.java

public RemoteOAuthValidator(String hostURL, String adminUsername, String adminPassword, Properties properties) {
    this.stubs = new GenericObjectPool(
            new OAuthTokenValidationStubFactory(hostURL, adminUsername, adminPassword, properties));
}