List of usage examples for org.apache.commons.pool.impl GenericKeyedObjectPool WHEN_EXHAUSTED_BLOCK
byte WHEN_EXHAUSTED_BLOCK
To view the source code for org.apache.commons.pool.impl GenericKeyedObjectPool WHEN_EXHAUSTED_BLOCK.
Click Source Link
From source file:Pool146.java
public void testBlockedKeyDoesNotBlockPoolImproved() throws Exception { SimpleFactory factory = new SimpleFactory(); GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); pool.setMaxActive(1);// w w w . j a v a2 s.c o m pool.setMaxTotal(-1); // Borrow with one key Object obj = pool.borrowObject("one"); // Borrow again with same key, should be blocked Runnable simple = new SimpleTestThread(pool, "one"); Thread borrowThread = new Thread(simple); borrowThread.start(); pool.borrowObject("two"); assert (pool.getNumActive("one") == 1); assert (pool.getNumActive("two") == 1); // Unblock and join the thread pool.returnObject("one", obj); borrowThread.join(); assert (pool.getNumActive("one") == 0); assert (pool.getNumActive("two") == 1); }
From source file:ch.epfl.eagle.daemon.util.ThriftClientPool.java
/** Get the configuration parameters used on the underlying client pool. */ protected static Config getPoolConfig() { Config conf = new Config(); conf.minIdle = MIN_IDLE_CLIENTS_PER_ADDR; conf.maxIdle = -1;/*w w w . j av a 2 s . c o m*/ conf.minEvictableIdleTimeMillis = EVICTABLE_IDLE_TIME_MILLIS; conf.timeBetweenEvictionRunsMillis = TIME_BETWEEN_EVICTION_RUNS_MILLIS; conf.maxActive = MAX_ACTIVE_CLIENTS_PER_ADDR; conf.whenExhaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK; return conf; }
From source file:com.seajas.search.contender.scripting.ScriptCache.java
/** * Default constructor.//from ww w .j a v a2 s . co m * * @param maximumEntries */ @Autowired public ScriptCache( @Value("${contender.project.script.cache.maximum.entries.per.script} ") final Integer maximumEntries) { pool = new GenericKeyedObjectPool<ModifierScript, ScriptCacheEntry>( new BaseKeyedPoolableObjectFactory<ModifierScript, ScriptCacheEntry>() { /** * {@inheritDoc} */ @Override public ScriptCacheEntry makeObject(final ModifierScript script) throws Exception { ScriptEngine engine = engineManager .getEngineByName(script.getScriptLanguage().toLowerCase()); if (engine instanceof Compilable) { CompiledScript compiledScript = ((Compilable) engine) .compile(script.getScriptContent()); return new ScriptCacheEntry(script.getModificationDate(), compiledScript); } else throw new Exception( String.format("The given script with ID %d of type %s cannot be compiled", script.getId(), script.getScriptLanguage())); } /** * {@inheritDoc} */ @Override public boolean validateObject(final ModifierScript script, final ScriptCacheEntry entry) { boolean result = entry.getModificationDate().equals(script.getModificationDate()); if (logger.isTraceEnabled()) logger.trace(String.format( (result ? "I" : "Not i") + "nvalidating pool entry for ID %d - modification date has changed", script.getId())); return result; } }, maximumEntries); pool.setMaxIdle(maximumEntries); pool.setTestOnBorrow(true); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); }
From source file:net.ontopia.persistence.proxy.DBCPConnectionFactory.java
protected void initPool() { // Set up connection pool pool = new GenericObjectPool(null); // Read/Write by default boolean readonly = defaultReadOnly; // Auto-commit disabled by default boolean autocommit = readonly; log.debug("Creating new DBCP connection factory, readonly=" + readonly + ", autocommit=" + autocommit); // Set minimum pool size (default: 20) String _minsize = PropertyUtils.getProperty(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.MinimumSize", false); int minsize = (_minsize == null ? 20 : Integer.parseInt(_minsize)); log.debug("Setting ConnectionPool.MinimumSize '" + minsize + "'"); pool.setMaxIdle(minsize); // 0 = no limit // Set maximum pool size (default: Integer.MAX_VALUE) String _maxsize = PropertyUtils.getProperty(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.MaximumSize", false); int maxsize = (_maxsize == null ? 0 : Integer.parseInt(_maxsize)); log.debug("Setting ConnectionPool.MaximumSize '" + maxsize + "'"); pool.setMaxActive(maxsize); // 0 = no limit // Set user timeout (default: never) String _utimeout = PropertyUtils.getProperty(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.UserTimeout", false); int utimeout = (_utimeout == null ? -1 : Integer.parseInt(_utimeout)); pool.setMaxWait(utimeout); // -1 = never // Set soft maximum - emergency objects (default: true) boolean softmax = PropertyUtils.isTrue(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.SoftMaximum", true); log.debug("Setting ConnectionPool.SoftMaximum '" + softmax + "'"); if (softmax)//from w ww .ja va 2 s . co m pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); else pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); // allow the user to overwrite exhausted options // warning: when set to fail, make sure Maximum and Minimum are set correctly // warning: when set to block, make sure a propper usertimeout is set, or pool will block // forever String _whenExhaustedAction = PropertyUtils.getProperty(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.WhenExhaustedAction", false); if (EXHAUSED_BLOCK.equals(_whenExhaustedAction)) pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); if (EXHAUSED_GROW.equals(_whenExhaustedAction)) pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); if (EXHAUSED_FAIL.equals(_whenExhaustedAction)) pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL); if (pool.getWhenExhaustedAction() == GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK) log.debug("Pool is set to block on exhaused"); if (pool.getWhenExhaustedAction() == GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW) log.debug("Pool is set to grow on exhaused"); if (pool.getWhenExhaustedAction() == GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL) log.debug("Pool is set to fail on exhaused"); // Statement pool GenericKeyedObjectPoolFactory stmpool = null; if (PropertyUtils.isTrue(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.PoolStatements", true)) { log.debug("Using prepared statement pool: Yes"); stmpool = new GenericKeyedObjectPoolFactory(null, -1, // unlimited maxActive (per key) GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL, 0, // maxWait 1, // maxIdle (per key) GenericKeyedObjectPool.DEFAULT_MAX_TOTAL); } else { log.debug("Using prepared statement pool: No"); } // Test on borrow pool.setTestOnBorrow(true); // Get validation query String vquery = PropertyUtils.getProperty(properties, "net.ontopia.topicmaps.impl.rdbms.ConnectionPool.ValidationQuery", false); if (vquery == null) vquery = "select seq_count from TM_ADMIN_SEQUENCE where seq_name = '<GLOBAL>'"; try { // Make sure driver is registered ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Class.forName(getDriver(), true, classLoader); // Create connection factory ConnectionFactory cfactory; if (getUserName() == null || getPassword() == null) { Properties props = new Properties(); props.putAll(properties); cfactory = new DriverManagerConnectionFactory(getConnectionString(), props); } else { cfactory = new DriverManagerConnectionFactory(getConnectionString(), getUserName(), getPassword()); } // Create data source this.pcfactory = new TraceablePoolableConnectionFactory(cfactory, pool, stmpool, vquery, readonly, autocommit); // Set default transaction isolation level pcfactory.setDefaultTransactionIsolation(defaultTransactionIsolation); this.datasource = new PoolingDataSource(pool); } catch (Exception e) { throw new OntopiaRuntimeException("Problems occurred when setting up DBCP connection pool.", e); } }
From source file:com.servoy.extensions.plugins.rest_ws.RestWSPlugin.java
synchronized KeyedObjectPool getClientPool() { if (clientPool == null) { byte exchaustedAction; int poolSize; if (ApplicationServerRegistry.get().isDeveloperStartup()) { // in developer multiple clients do not work well with debugger poolSize = 1;/*from w ww. j a v a 2s .co m*/ exchaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK; } else { try { poolSize = Integer.parseInt(application.getSettings() .getProperty(CLIENT_POOL_SIZE_PROPERTY, "" + CLIENT_POOL_SIZE_DEFAULT).trim()); } catch (NumberFormatException nfe) { poolSize = CLIENT_POOL_SIZE_DEFAULT; } String exchaustedActionCode = application.getSettings() .getProperty(CLIENT_POOL_EXCHAUSTED_ACTION_PROPERTY); if (exchaustedActionCode != null) exchaustedActionCode = exchaustedActionCode.trim(); if (ACTION_FAIL.equalsIgnoreCase(exchaustedActionCode)) { exchaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL; if (log.isDebugEnabled()) log.debug("Client pool, exchaustedAction=" + ACTION_FAIL); } else if (ACTION_GROW.equalsIgnoreCase(exchaustedActionCode)) { exchaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW; if (log.isDebugEnabled()) log.debug("Client pool, exchaustedAction=" + ACTION_GROW); } else { exchaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK; if (log.isDebugEnabled()) log.debug("Client pool, exchaustedAction=" + ACTION_BLOCK); } } if (log.isDebugEnabled()) log.debug("Creating client pool, maxSize=" + poolSize); clientPool = new GenericKeyedObjectPool(new BaseKeyedPoolableObjectFactory() { @Override public Object makeObject(Object key) throws Exception { if (log.isDebugEnabled()) log.debug("creating new session client for solution '" + key + '\''); String solutionName = (String) key; String[] solOpenArgs = SOLUTION_OPEN_METHOD_ARGS; String[] arr = solutionName.split(":"); if (arr.length == 2) { solutionName = arr[0]; solOpenArgs = Utils.arrayJoin(SOLUTION_OPEN_METHOD_ARGS, new String[] { "nodebug" }); } return HeadlessClientFactory.createHeadlessClient(solutionName, solOpenArgs); } @Override public boolean validateObject(Object key, Object obj) { IHeadlessClient client = ((IHeadlessClient) obj); if (client.getPluginAccess().isInDeveloper()) { String solutionName = (String) key; if (solutionName.contains(":")) solutionName = solutionName.split(":")[0]; if (!solutionName.equals(((IHeadlessClient) obj).getPluginAccess().getSolutionName())) { try { client.closeSolution(true); client.loadSolution(solutionName); } catch (Exception ex) { return false; } } } boolean valid = client.isValid(); if (log.isDebugEnabled()) log.debug("Validated session client for solution '" + key + "', valid = " + valid); return valid; } @Override public void destroyObject(Object key, Object obj) throws Exception { if (log.isDebugEnabled()) log.debug("Destroying session client for solution '" + key + "'"); IHeadlessClient client = ((IHeadlessClient) obj); try { client.shutDown(true); } catch (Exception e) { Debug.error(e); } } }, poolSize); clientPool.setTestOnBorrow(true); clientPool.setWhenExhaustedAction(exchaustedAction); clientPool.setMaxIdle(poolSize); // destroy objects when pool has grown } return clientPool; }
From source file:edu.illinois.enforcemop.examples.apache.pool.TestGenericKeyedObjectPool.java
public void testSettersAndGetters() throws Exception { GenericKeyedObjectPool pool = new GenericKeyedObjectPool(); {/*from ww w.j av a 2s . com*/ pool.setFactory(new SimpleFactory()); } { pool.setMaxActive(123); assertEquals(123, pool.getMaxActive()); } { pool.setMaxIdle(12); assertEquals(12, pool.getMaxIdle()); } { pool.setMaxWait(1234L); assertEquals(1234L, pool.getMaxWait()); } { pool.setMinEvictableIdleTimeMillis(12345L); assertEquals(12345L, pool.getMinEvictableIdleTimeMillis()); } { pool.setNumTestsPerEvictionRun(11); assertEquals(11, pool.getNumTestsPerEvictionRun()); } { pool.setTestOnBorrow(true); assertTrue(pool.getTestOnBorrow()); pool.setTestOnBorrow(false); assertTrue(!pool.getTestOnBorrow()); } { pool.setTestOnReturn(true); assertTrue(pool.getTestOnReturn()); pool.setTestOnReturn(false); assertTrue(!pool.getTestOnReturn()); } { pool.setTestWhileIdle(true); assertTrue(pool.getTestWhileIdle()); pool.setTestWhileIdle(false); assertTrue(!pool.getTestWhileIdle()); } { pool.setTimeBetweenEvictionRunsMillis(11235L); assertEquals(11235L, pool.getTimeBetweenEvictionRunsMillis()); } { pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_BLOCK, pool.getWhenExhaustedAction()); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_FAIL, pool.getWhenExhaustedAction()); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_GROW, pool.getWhenExhaustedAction()); } }
From source file:org.jahia.services.usermanager.ldap.JahiaLDAPConfig.java
/** * defines or update the context of the provider * @param context the Spring application context object * @param dictionary configuration parameters *///from w ww . ja v a2 s .co m public void setContext(ApplicationContext context, Dictionary<String, ?> dictionary) { Properties userLdapProperties = new Properties(); Properties groupLdapProperties = new Properties(); UserConfig userConfig = new UserConfig(); GroupConfig groupConfig = new GroupConfig(); Enumeration<String> keys = dictionary.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (Constants.SERVICE_PID.equals(key) || ConfigurationAdmin.SERVICE_FACTORYPID.equals(key) || "felix.fileinstall.filename".equals(key)) { continue; } Object value = dictionary.get(key); if (key.startsWith("user.")) { buildConfig(userLdapProperties, userConfig, key, value, true); } else if (key.startsWith("group.")) { buildConfig(groupLdapProperties, groupConfig, key, value, false); } else { userLdapProperties.put(transformPropKeyToBeanAttr(key), value); groupLdapProperties.put(transformPropKeyToBeanAttr(key), value); } } try { // populate config beans BeanUtils.populate(userConfig, userLdapProperties); BeanUtils.populate(groupConfig, groupLdapProperties); // handle defaults values userConfig.handleDefaults(); groupConfig.handleDefaults(); // instantiate ldap context if (userConfig.isMinimalSettingsOk()) { LdapContextSource lcs = new LdapContextSource(); lcs.setUrl(userConfig.getUrl()); if (StringUtils.isNotEmpty(userConfig.getPublicBindDn())) { lcs.setUserDn(userConfig.getPublicBindDn()); } if (StringUtils.isNotEmpty(userConfig.getPublicBindPassword())) { lcs.setPassword(userConfig.getPublicBindPassword()); } Map<String, Object> publicEnv = new Hashtable<String, Object>(1); if (POOL_LDAP.equalsIgnoreCase(userConfig.getLdapConnectPool())) { lcs.setPooled(true); publicEnv.put("com.sun.jndi.ldap.connect.pool.authentication", "none simple"); if (userConfig.getLdapConnectPoolTimeout() != null && Long.valueOf(userConfig.getLdapConnectTimeout()) > 0) { publicEnv.put("com.sun.jndi.ldap.connect.pool.timeout", userConfig.getLdapConnectPoolTimeout()); } if (userConfig.getLdapConnectPoolDebug() != null) { publicEnv.put("com.sun.jndi.ldap.connect.pool.debug", userConfig.getLdapConnectPoolDebug()); } if (userConfig.getLdapConnectPoolInitSize() != null) { publicEnv.put("com.sun.jndi.ldap.connect.pool.initsize", userConfig.getLdapConnectPoolInitSize()); } if (userConfig.getLdapConnectPoolMaxSize() != null) { publicEnv.put("com.sun.jndi.ldap.connect.pool.maxsize", userConfig.getLdapConnectPoolMaxSize()); } if (userConfig.getLdapConnectPoolPrefSize() != null) { publicEnv.put("com.sun.jndi.ldap.connect.pool.prefsize", userConfig.getLdapConnectPoolPrefSize()); } } if (userConfig.getLdapReadTimeout() != null) { publicEnv.put("com.sun.jndi.ldap.read.timeout", userConfig.getLdapReadTimeout()); } if (userConfig.getLdapConnectTimeout() != null) { publicEnv.put("com.sun.jndi.ldap.connect.timeout", userConfig.getLdapConnectTimeout()); } lcs.setBaseEnvironmentProperties(publicEnv); lcs.setReferral(groupConfig.getRefferal()); lcs.setDirObjectFactory(DefaultDirObjectFactory.class); lcs.afterPropertiesSet(); LdapTemplate ldap; if (POOL_APACHE_COMMONS.equalsIgnoreCase(userConfig.getLdapConnectPool())) { PoolingContextSource poolingContextSource = new PoolingContextSource(); poolingContextSource.setContextSource(lcs); if (userConfig.getLdapConnectPoolMaxActive() != null) { poolingContextSource.setMaxActive(userConfig.getLdapConnectPoolMaxActive()); } if (userConfig.getLdapConnectPoolMaxIdle() != null) { poolingContextSource.setMaxIdle(userConfig.getLdapConnectPoolMaxIdle()); } if (userConfig.getLdapConnectPoolMaxTotal() != null) { poolingContextSource.setMaxTotal(userConfig.getLdapConnectPoolMaxTotal()); } if (userConfig.getLdapConnectPoolMaxWait() != null) { poolingContextSource.setMaxWait(userConfig.getLdapConnectPoolMaxWait()); } if (userConfig.getLdapConnectPoolMinEvictableIdleTimeMillis() != null) { poolingContextSource.setMinEvictableIdleTimeMillis( userConfig.getLdapConnectPoolMinEvictableIdleTimeMillis()); } if (userConfig.getLdapConnectPoolMinIdle() != null) { poolingContextSource.setMinIdle(userConfig.getLdapConnectPoolMinIdle()); } if (userConfig.getLdapConnectPoolNumTestsPerEvictionRun() != null) { poolingContextSource .setNumTestsPerEvictionRun(userConfig.getLdapConnectPoolNumTestsPerEvictionRun()); } if (userConfig.getLdapConnectPoolTestOnBorrow() != null) { poolingContextSource.setTestOnBorrow(userConfig.getLdapConnectPoolTestOnBorrow()); } if (userConfig.getLdapConnectPoolTestOnReturn() != null) { poolingContextSource.setTestOnReturn(userConfig.getLdapConnectPoolTestOnReturn()); } if (userConfig.getLdapConnectPoolTestWhileIdle() != null) { poolingContextSource.setTestWhileIdle(userConfig.getLdapConnectPoolTestWhileIdle()); } if (userConfig.getLdapConnectPoolTimeBetweenEvictionRunsMillis() != null) { poolingContextSource.setTimeBetweenEvictionRunsMillis( userConfig.getLdapConnectPoolTimeBetweenEvictionRunsMillis()); } if (WHEN_EXHAUSTED_BLOCK.equalsIgnoreCase(userConfig.getLdapConnectPoolWhenExhaustedAction())) { poolingContextSource.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); } else if (WHEN_EXHAUSTED_FAIL .equalsIgnoreCase(userConfig.getLdapConnectPoolWhenExhaustedAction())) { poolingContextSource.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL); } else if (WHEN_EXHAUSTED_GROW .equalsIgnoreCase(userConfig.getLdapConnectPoolWhenExhaustedAction())) { poolingContextSource.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); } ldap = new LdapTemplate(poolingContextSource); } else { ldap = new LdapTemplate(lcs); } // AD workaround to ignore Exceptions ldap.setIgnorePartialResultException(true); ldap.setIgnoreNameNotFoundException(true); if (ldapUserGroupProvider == null) { ldapUserGroupProvider = (LDAPUserGroupProvider) context.getBean("ldapUserGroupProvider"); } ldapUserGroupProvider.setKey(providerKey); ldapUserGroupProvider.setUserConfig(userConfig); ldapUserGroupProvider.setGroupConfig(groupConfig); if (StringUtils.isNotEmpty(userConfig.getUidSearchName()) && StringUtils.isNotEmpty(groupConfig.getSearchName())) { ldapUserGroupProvider .setDistinctBase(!userConfig.getUidSearchName().startsWith(groupConfig.getSearchName()) && !groupConfig.getSearchName().startsWith(userConfig.getUidSearchName())); } ldapUserGroupProvider.setLdapTemplateWrapper(new LdapTemplateWrapper(ldap)); ldapUserGroupProvider.setContextSource(lcs); ldapUserGroupProvider.unregister(); ldapUserGroupProvider.register(); if (groupConfig.isPreload()) { new Thread(new Runnable() { @Override public void run() { List<String> l = ldapUserGroupProvider.searchGroups(new Properties(), 0, -1); for (String s : l) { List<Member> m = ldapUserGroupProvider.getGroupMembers(s); } } }, "LDAP Preload").start(); } } else { unregister(); } } catch (IllegalAccessException e) { logger.error("Config LDAP invalid, pls read the documentation on LDAP configuration", e); } catch (InvocationTargetException e) { logger.error("Config LDAP invalid, pls read the documentation on LDAP configuration", e); } }
From source file:org.mule.transport.DispatcherPoolTestCase.java
@Test public void testDefaultDispatcherPoolConfiguration() throws Exception { final TestConnector connector = createConnectorWithSingleObjectDispatcherPool( ThreadingProfile.WHEN_EXHAUSTED_RUN); // ThreadingProfile exhausted action default is RUN assertEquals(ThreadingProfile.WHEN_EXHAUSTED_RUN, connector.getDispatcherThreadingProfile().getPoolExhaustedAction()); assertEquals(2, connector.dispatchers.getMaxActive()); // This must equal maxActive dispatchers because low maxIdle would result in // a lot of dispatcher churn assertEquals(2, connector.dispatchers.getMaxIdle()); assertEquals(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, connector.dispatchers.getWhenExhaustedAction()); assertEquals(-1, connector.dispatchers.getMaxWait()); }
From source file:org.mule.transport.DispatcherPoolTestCase.java
@Test public void testDefaultDispatcherPoolConfigurationThreadingProfileWait() throws Exception { final TestConnector connector = createConnectorWithSingleObjectDispatcherPool( ThreadingProfile.WHEN_EXHAUSTED_WAIT); assertEquals(ThreadingProfile.WHEN_EXHAUSTED_WAIT, connector.getDispatcherThreadingProfile().getPoolExhaustedAction()); assertEquals(1, connector.dispatchers.getMaxActive()); assertEquals(1, connector.dispatchers.getMaxIdle()); assertEquals(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, connector.dispatchers.getWhenExhaustedAction()); assertEquals(-1, connector.dispatchers.getMaxWait()); }
From source file:org.mule.transport.legstar.tcp.LegstarTcpConnector.java
/** {@inheritDoc} */ public void doInitialise() throws InitialisationException { _socketsPool.setFactory(getSocketFactory()); _socketsPool.setTestOnBorrow(true);// ww w. j av a 2 s.co m // Testing is expensive in our case because we send a probe to the // mainframe _socketsPool.setTestOnReturn(false); // There should only be one pooled instance per socket (key) _socketsPool.setMaxActive(1); _socketsPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); }