// wrap it with a LocalXAConnectionFactory
XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf);
// configure the pool settings
GenericObjectPool pool = new GenericObjectPool();
pool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
pool.setMaxActive(maxSize);
pool.setMaxIdle(maxIdle);
pool.setMinIdle(minSize);
pool.setMaxWait(120000);
// create the pool object factory
PoolableManagedConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, pool, null, null, true, true);
factory.setValidationQuery("select example_type_id from example_type limit 1");
factory.setDefaultReadOnly(false);
String transIso = jdbcElement.getAttribute("isolation-level");
if (UtilValidate.isNotEmpty(transIso)) {
if ("Serializable".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
} else if ("RepeatableRead".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
} else if ("ReadUncommitted".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
} else if ("ReadCommitted".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
} else if ("None".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
}
}
pool.setFactory(factory);
mds = new ManagedDataSource(pool, xacf.getTransactionRegistry());
//mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool
mds.setAccessToUnderlyingConnectionAllowed(true);