}
if (cachedConnectionHash.containsKey(factory)) {
Stack stack = (Stack) cachedConnectionHash.get(factory);
try {
Connection connection = null;
if (stack.isEmpty()) {
connection = factory.getConnection();
return connection;
} else {
connection = (Connection) stack.pop();
if ((connection != null) && (!connection.isClosed())) {
return connection;
} else {
logger.error("Cached connection was null or closed, creating new connection");
connection = factory.getConnection();
return connection;
}
}
} catch (JAXRException jaxre) {
return null;
}
} else {
Stack stack = new Stack();
cachedConnectionHash.put(factory, stack);
Connection connection = factory.getConnection();
return connection;
}
}