pool = new GenericObjectPool();
pool.setMaxActive(getMaxActive());
pool.setMaxWait(getMaxWait());
// create the pool object factory
PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, pool, null, "SELECT DUMMY FROM DUAL", true, true);
pool.setFactory(factory);
// finally create the datasource
ds = new ManagedDataSource(pool, xaConnectionFactory.getTransactionRegistry());
ds.setAccessToUnderlyingConnectionAllowed(true);