* @exception ResourceException if an error occurs
*/
protected ConnectionListener getManagedConnection(Transaction transaction, Subject subject, ConnectionRequestInfo cri)
throws ResourceException
{
ResourceException failure = null;
if (shutdown.get())
throw new ResourceException("The connection manager is shutdown " + jndiName);
// First attempt
try
{
return poolingStrategy.getConnection(transaction, subject, cri);
}
catch (ResourceException e)
{
failure = e;
// Retry?
if (allocationRetry != 0)
{
for (int i = 0; i < allocationRetry; i++)
{
if (shutdown.get())
throw new ResourceException("The connection manager is shutdown " + jndiName);
if (trace)
log.trace("Attempting allocation retry for cri=" + cri);
try
{
if (allocationRetryWaitMillis != 0)
Thread.sleep(allocationRetryWaitMillis);
return poolingStrategy.getConnection(transaction, subject, cri);
}
catch (ResourceException e1)
{
failure = e1;
}
catch (InterruptedException e1)
{
Thread.currentThread().interrupt();
JBossResourceException.rethrowAsResourceException("getManagedConnection retry wait was interrupted " + jndiName, e1);
}
}
}
}
// If we get here all retries failed, throw the lastest failure
throw new ResourceException("Unable to get managed connection for " + jndiName, failure);
}