private static LdapConnectionPool createConnectionPool(LDAPConfiguration configuration) throws IOException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(configuration.getHostname()); config.setLdapPort(configuration.getPort()); config.setName(configuration.getBindDn()); config.setCredentials(configuration.getBindPassword()); final DefaultPoolableLdapConnectionFactory factory = new DefaultPoolableLdapConnectionFactory(config); final LdapConnectionPool pool = new LdapConnectionPool(factory); pool.setTestOnBorrow(configuration.isPoolTestOnBorrow()); pool.setTestOnReturn(configuration.isPoolTestOnReturn()); pool.setTestWhileIdle(configuration.isPoolTestWhileIdle()); pool.setMaxActive(configuration.getPoolMaxActive()); pool.setMaxIdle(configuration.getPoolMaxIdle()); pool.setMinIdle(configuration.getPoolMinIdle()); pool.setMaxWait(configuration.getPoolMaxWait()); switch (configuration.getPoolWhenExhaustedAction()) { case BLOCK: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_BLOCK); break; case FAIL: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_FAIL); break; case GROW: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_GROW); break; default: pool.setWhenExhaustedAction(LdapConnectionPool.DEFAULT_WHEN_EXHAUSTED_ACTION); } return pool; }
private static LdapConnectionPool createConnectionPool(LDAPConfiguration configuration) throws IOException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(configuration.getHostname()); config.setLdapPort(configuration.getPort()); config.setName(configuration.getBindDn()); config.setCredentials(configuration.getBindPassword()); final DefaultPoolableLdapConnectionFactory factory = new DefaultPoolableLdapConnectionFactory(config); final LdapConnectionPool pool = new LdapConnectionPool(factory); pool.setTestOnBorrow(configuration.isPoolTestOnBorrow()); pool.setTestOnReturn(configuration.isPoolTestOnReturn()); pool.setTestWhileIdle(configuration.isPoolTestWhileIdle()); pool.setMaxActive(configuration.getPoolMaxActive()); pool.setMaxIdle(configuration.getPoolMaxIdle()); pool.setMinIdle(configuration.getPoolMinIdle()); pool.setMaxWait(configuration.getPoolMaxWait()); switch (configuration.getPoolWhenExhaustedAction()) { case BLOCK: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_BLOCK); break; case FAIL: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_FAIL); break; case GROW: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_GROW); break; default: pool.setWhenExhaustedAction(LdapConnectionPool.DEFAULT_WHEN_EXHAUSTED_ACTION); } return pool; }
adminPool.setTestOnBorrow(true); adminPool.setMaxActive(config.getAdminPoolConfig().getMaxActive()); adminPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
adminPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW ); adminPool.setMaxActive( max ); adminPool.setMinIdle( min ); userPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW ); userPool.setMaxActive( max ); userPool.setMinIdle( min ); logPool = new LdapConnectionPool( poolFactory ); logPool.setTestOnBorrow( true ); logPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW ); logPool.setMaxActive( logmax ); logPool.setMinIdle( logmin );