/** Restores the delegation for the entire chain. */ private void clearXid() { _xid = null; UserPoolItem shareHead = _shareHead; _shareHead = null; ManagedPoolItem xaPtr = _xaNext; _xaHead = null; _xaNext = null; UserPoolItem assignedUserItem = null; for (UserPoolItem ptr = shareHead; ptr != null; ptr = ptr.getShareNext()) { if (ptr.getOwnPoolItem() == this) { assignedUserItem = ptr; break; } } for (UserPoolItem ptr = shareHead; ptr != null; ptr = ptr.getShareNext()) { if (assignedUserItem == null && ptr.getOwnPoolItem() == null) { ptr.associatePoolItem(this); assignedUserItem = ptr; } try { ptr.reassociatePoolItem(); } catch (Throwable e) { log.log(Level.WARNING, e.toString(), e); } } while (xaPtr != null) { ManagedPoolItem next = xaPtr._xaNext; xaPtr._xaNext = null; xaPtr._xaHead = null; xaPtr.clearXid(); xaPtr = next; } if (assignedUserItem != null) { // _shareHead = assignedUserItem; // _shareHead.setShareNext(null); } else if (_hasConnectionError) { destroy(); } else { toIdle(); } }
/** Try to share the connection. */ boolean share(UserPoolItem userPoolItem) { if (this == userPoolItem.getOwnPoolItem()) return true; else if (_mConn == null) // already closed return false; else if (!_cm.isShareable()) // not shareable return false; else if (_mcf != userPoolItem.getManagedConnectionFactory()) return false; else if (_subject != userPoolItem.getSubject()) return false; else if (_requestInfo != userPoolItem.getInfo()) return false; else if (_hasConnectionError) // had a fatal error return false; // skip for now if (true) return false; userPoolItem.associate(this, _mcf, _subject, _requestInfo); return true; }