Java源码示例:org.vibur.objectpool.PoolService
示例1
/**
* Instantiates the PoolOperations facade.
*
* @param dataSource the Vibur dataSource on which we will operate
* @param connectionFactory the Vibur connection factory
* @param poolService the Vibur pool service
*/
public PoolOperations(ViburDBCPDataSource dataSource, ViburObjectFactory connectionFactory, PoolService<ConnHolder> poolService) {
this.dataSource = dataSource;
this.connectionTimeoutInNanos = MILLISECONDS.toNanos(dataSource.getConnectionTimeoutInMs());
this.connectionFactory = connectionFactory;
this.poolService = poolService;
this.criticalSQLStates = new HashSet<>(Arrays.asList(
whitespaces.matcher(dataSource.getCriticalSQLStates()).replaceAll("").split(",")));
}
示例2
private void doStart() throws ViburDBCPException {
if (!state.compareAndSet(NEW, WORKING)) {
throw new IllegalStateException();
}
validateConfig();
if (getExternalDataSource() == null) {
initJdbcDriver();
}
if (getConnector() == null) {
setConnector(buildConnector(this, getUsername(), getPassword()));
}
initDefaultHooks();
ViburObjectFactory connectionFactory = getConnectionFactory();
if (connectionFactory == null) {
setConnectionFactory(connectionFactory = new ConnectionFactory(this));
}
PoolService<ConnHolder> pool = getPool();
if (pool == null) {
if (isPoolEnableConnectionTracking() && getTakenConnectionsFormatter() == null) {
setTakenConnectionsFormatter(new TakenConnectionsFormatter.Default(this));
}
pool = new ConcurrentPool<>(getConcurrentCollection(), connectionFactory,
getPoolInitialSize(), getPoolMaxSize(), isPoolFair(),
isPoolEnableConnectionTracking() ? new ViburListener(this) : null);
setPool(pool);
}
poolOperations = new PoolOperations(this, connectionFactory, pool);
initPoolReducer();
initStatementCache();
if (isEnableJMX()) {
registerMBean(this);
}
}
示例3
private Worker(PoolService<Object> pool, AtomicInteger errors, long millis, long timeout,
CountDownLatch readySignal, CountDownLatch startSignal, CountDownLatch doneSignal) {
this.pool = pool;
this.errors = errors;
this.millis = millis;
this.timeout = timeout;
this.startSignal = startSignal;
this.readySignal = readySignal;
this.doneSignal = doneSignal;
}
示例4
public PoolService<ConnHolder> getPool() {
return pool;
}
示例5
protected void setPool(PoolService<ConnHolder> pool) {
this.pool = pool;
}