private T doGetItem() { T item = this.available.poll(); if (item != null && this.logger.isDebugEnabled()) { this.logger.debug("Obtained " + item + " from pool."); } if (item == null) { item = this.callback.createForPool(); if (this.logger.isDebugEnabled()) { this.logger.debug("Obtained new " + item + "."); } this.allocated.add(item); } else if (this.callback.isStale(item)) { if (this.logger.isDebugEnabled()) { this.logger.debug("Received a stale item " + item + ", will attempt to get a new one."); } doRemoveItem(item); item = doGetItem(); } this.inUse.add(item); return item; }
private void doRemoveItem(T item) { if (this.logger.isDebugEnabled()) { this.logger.debug("Removing " + item + " from the pool"); } this.allocated.remove(item); this.inUse.remove(item); this.callback.removedFromPool(item); }
private T doGetItem() { T item = this.available.poll(); if (item != null && this.logger.isDebugEnabled()) { this.logger.debug("Obtained " + item + " from pool."); } if (item == null) { item = this.callback.createForPool(); if (this.logger.isDebugEnabled()) { this.logger.debug("Obtained new " + item + "."); } this.allocated.add(item); } else if (this.callback.isStale(item)) { if (this.logger.isDebugEnabled()) { this.logger.debug("Received a stale item " + item + ", will attempt to get a new one."); } doRemoveItem(item); item = doGetItem(); } this.inUse.add(item); return item; }
private void doRemoveItem(T item) { if (this.logger.isDebugEnabled()) { this.logger.debug("Removing " + item + " from the pool"); } this.allocated.remove(item); this.inUse.remove(item); this.callback.removedFromPool(item); }