use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project cas by apereo.
the class MemcachedMonitorConfiguration method memcachedHealthIndicator.
@Bean
public HealthIndicator memcachedHealthIndicator() {
final MonitorProperties.Memcached memcached = casProperties.getMonitor().getMemcached();
final MemcachedPooledClientConnectionFactory factory = new MemcachedPooledClientConnectionFactory(memcached, memcachedMonitorTranscoder());
final ObjectPool<MemcachedClientIF> pool = new GenericObjectPool<>(factory);
return new MemcachedHealthIndicator(pool, casProperties);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project fess-crawler by codelibs.
the class WebDriverClientTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
CrawlerPooledObjectFactory<CrawlerWebDriver> pooledObjectFactory = new CrawlerPooledObjectFactory<>();
pooledObjectFactory.setComponentName("webDriver");
pooledObjectFactory.setOnDestroyListener(p -> {
final CrawlerWebDriver driver = p.getObject();
driver.quit();
});
final StandardCrawlerContainer container = new StandardCrawlerContainer();
container.prototype("webDriver", CrawlerWebDriver.class).singleton("mimeTypeHelper", MimeTypeHelperImpl.class).singleton("pooledObjectFactory", pooledObjectFactory).singleton("webDriverPool", new GenericObjectPool<>(pooledObjectFactory), null, pool -> {
pool.close();
}).<AOnClickAction>singleton("aOnClickAction", AOnClickAction.class).<FormAction>singleton("formAction", FormAction.class).<WebDriverClient>singleton("webDriverClient", WebDriverClient.class, client -> {
AOnClickAction aOnClick = container.getComponent("aOnClickAction");
aOnClick.setName("aOnClick");
aOnClick.setCssQuery("a");
client.addUrlAction(aOnClick);
FormAction formAction = container.getComponent("formAction");
formAction.setName("form");
formAction.setCssQuery("form");
client.addUrlAction(formAction);
});
webDriverClient = container.getComponent("webDriverClient");
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project atmosphere by Atmosphere.
the class PoolableBroadcasterFactoryTest method testImplementation.
@Test
public void testImplementation() {
assertNotNull(factory.poolableProvider());
assertNotNull(factory.poolableProvider().implementation());
assertEquals(factory.poolableProvider().implementation().getClass(), GenericObjectPool.class);
GenericObjectPool nativePool = (GenericObjectPool) factory.poolableProvider().implementation();
assertTrue(nativePool.getLifo());
GenericObjectPoolConfig c = new GenericObjectPoolConfig();
c.setMaxTotal(1);
nativePool.setConfig(c);
assertEquals(1, nativePool.getMaxTotal());
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project cloudstack by apache.
the class TransactionLegacy method createDataSource.
/**
* Creates a data source
*/
private static DataSource createDataSource(String uri, String username, String password, Integer maxActive, Integer maxIdle, Long maxWait, Long timeBtwnEvictionRuns, Long minEvictableIdleTime, Boolean testWhileIdle, Boolean testOnBorrow, String validationQuery, Integer isolationLevel) {
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(uri, username, password);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
GenericObjectPoolConfig config = createPoolConfig(maxActive, maxIdle, maxWait, timeBtwnEvictionRuns, minEvictableIdleTime, testWhileIdle, testOnBorrow);
ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory, config);
poolableConnectionFactory.setPool(connectionPool);
if (validationQuery != null) {
poolableConnectionFactory.setValidationQuery(validationQuery);
}
if (isolationLevel != null) {
poolableConnectionFactory.setDefaultTransactionIsolation(isolationLevel);
}
return new PoolingDataSource<>(connectionPool);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project cas by apereo.
the class MemcachedMonitorConfiguration method memcachedHealthClientPool.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "memcachedHealthClientPool")
public ObjectPool<MemcachedClientIF> memcachedHealthClientPool(@Qualifier("memcachedMonitorTranscoder") final Transcoder memcachedMonitorTranscoder, final CasConfigurationProperties casProperties) {
val memcached = casProperties.getMonitor().getMemcached();
val factory = new MemcachedPooledClientConnectionFactory(memcached, memcachedMonitorTranscoder);
return new GenericObjectPool<>(factory);
}
Aggregations