ManagedConnection dmc
= (ManagedConnection) handle.getResource();
dmc.associateConnection(connection);
} catch (ResourceException e) {
putbackDirectToPool(handle, spec.getPoolInfo());
PoolingException pe = new PoolingException(
e.getMessage());
pe.initCause(e);
throw pe;
}
}
//If the ResourceAdapter does not support lazy enlistment
//we cannot either
if (!handle.supportsLazyEnlistment()) {
spec.setLazyEnlistable(false);
}
handle.setResourceSpec(spec);
try {
if (handle.getResourceState().isUnenlisted()) {
//The spec being used here is the spec with the updated
//lazy enlistment info
//Here's the real place where we care about the correct
//resource manager (which in turn depends upon the ResourceSpec)
//and that's because if lazy enlistment needs to be done
//we need to get the LazyEnlistableResourceManager
getResourceManager(spec).enlistResource(handle);
}
} catch (Exception e) {
//In the rare cases where enlistResource throws exception, we
//should return the resource to the pool
putbackDirectToPool(handle, spec.getPoolInfo());
_logger.log(Level.WARNING, "poolmgr.err_enlisting_res_in_getconn",
spec.getPoolInfo());
logFine("rm.enlistResource threw Exception. Returning resource to pool");
//and rethrow the exception
throw new PoolingException(e);
}
return handle.getUserConnection();
}