Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0BD2F10D02 for ; Wed, 24 Jul 2013 10:23:32 +0000 (UTC) Received: (qmail 34507 invoked by uid 500); 24 Jul 2013 10:23:30 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 34403 invoked by uid 500); 24 Jul 2013 10:23:29 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 34396 invoked by uid 99); 24 Jul 2013 10:23:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jul 2013 10:23:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jul 2013 10:23:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EAE1223889ED; Wed, 24 Jul 2013 10:23:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1506481 - in /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl: LinkedBlockingDeque.java PooledObject.java Date: Wed, 24 Jul 2013 10:23:01 -0000 To: commits@commons.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130724102301.EAE1223889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed Jul 24 10:23:01 2013 New Revision: 1506481 URL: http://svn.apache.org/r1506481 Log: Decouple PooledObject from the Deque implementation (required for some refactoring to follow) Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java?rev=1506481&r1=1506480&r2=1506481&view=diff ============================================================================== --- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java (original) +++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java Wed Jul 24 10:23:01 2013 @@ -16,8 +16,10 @@ */ package org.apache.commons.pool2.impl; +import java.io.Serializable; import java.util.AbstractQueue; import java.util.Collection; +import java.util.Deque; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; @@ -55,7 +57,7 @@ import java.util.concurrent.locks.Reentr * Commons Pool. */ class LinkedBlockingDeque extends AbstractQueue - implements java.io.Serializable { + implements Deque, Serializable { /* * Implemented as a simple doubly-linked list protected by a @@ -303,6 +305,7 @@ class LinkedBlockingDeque extends Abs * @throws IllegalStateException * @throws NullPointerException */ + @Override public void addFirst(E e) { if (!offerFirst(e)) throw new IllegalStateException("Deque full"); @@ -312,6 +315,7 @@ class LinkedBlockingDeque extends Abs * @throws IllegalStateException * @throws NullPointerException */ + @Override public void addLast(E e) { if (!offerLast(e)) throw new IllegalStateException("Deque full"); @@ -320,6 +324,7 @@ class LinkedBlockingDeque extends Abs /** * @throws NullPointerException */ + @Override public boolean offerFirst(E e) { if (e == null) throw new NullPointerException(); final ReentrantLock lock = this.lock; @@ -334,6 +339,7 @@ class LinkedBlockingDeque extends Abs /** * @throws NullPointerException */ + @Override public boolean offerLast(E e) { if (e == null) throw new NullPointerException(); final ReentrantLock lock = this.lock; @@ -424,6 +430,7 @@ class LinkedBlockingDeque extends Abs /** * @throws NoSuchElementException */ + @Override public E removeFirst() { E x = pollFirst(); if (x == null) throw new NoSuchElementException(); @@ -433,12 +440,14 @@ class LinkedBlockingDeque extends Abs /** * @throws NoSuchElementException */ + @Override public E removeLast() { E x = pollLast(); if (x == null) throw new NoSuchElementException(); return x; } + @Override public E pollFirst() { final ReentrantLock lock = this.lock; lock.lock(); @@ -449,6 +458,7 @@ class LinkedBlockingDeque extends Abs } } + @Override public E pollLast() { final ReentrantLock lock = this.lock; lock.lock(); @@ -524,6 +534,7 @@ class LinkedBlockingDeque extends Abs /** * @throws NoSuchElementException */ + @Override public E getFirst() { E x = peekFirst(); if (x == null) throw new NoSuchElementException(); @@ -533,12 +544,14 @@ class LinkedBlockingDeque extends Abs /** * @throws NoSuchElementException */ + @Override public E getLast() { E x = peekLast(); if (x == null) throw new NoSuchElementException(); return x; } + @Override public E peekFirst() { final ReentrantLock lock = this.lock; lock.lock(); @@ -549,6 +562,7 @@ class LinkedBlockingDeque extends Abs } } + @Override public E peekLast() { final ReentrantLock lock = this.lock; lock.lock(); @@ -559,6 +573,7 @@ class LinkedBlockingDeque extends Abs } } + @Override public boolean removeFirstOccurrence(Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; @@ -576,6 +591,7 @@ class LinkedBlockingDeque extends Abs } } + @Override public boolean removeLastOccurrence(Object o) { if (o == null) return false; final ReentrantLock lock = this.lock; @@ -747,6 +763,7 @@ class LinkedBlockingDeque extends Abs * @throws IllegalStateException * @throws NullPointerException */ + @Override public void push(E e) { addFirst(e); } @@ -754,6 +771,7 @@ class LinkedBlockingDeque extends Abs /** * @throws NoSuchElementException */ + @Override public E pop() { return removeFirst(); } @@ -1007,6 +1025,7 @@ class LinkedBlockingDeque extends Abs * construction of the iterator, and may (but is not guaranteed to) * reflect any modifications subsequent to construction. */ + @Override public Iterator descendingIterator() { return new DescendingItr(); } Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java?rev=1506481&r1=1506480&r2=1506481&view=diff ============================================================================== --- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java (original) +++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java Wed Jul 24 10:23:01 2013 @@ -19,6 +19,7 @@ package org.apache.commons.pool2.impl; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Deque; /** * This wrapper is used to track the additional information, such as state, for @@ -47,7 +48,7 @@ public class PooledObject implements createdBy = null; logWriter = null; } - + public PooledObject(T object, PrintWriter logWriter) { this.object = object; this.logWriter = logWriter; @@ -103,14 +104,14 @@ public class PooledObject implements public long getLastReturnTime() { return lastReturnTime; } - + /** * Return an estimate of the last time this object was used. If the class - * of the pooled object implements {@link TrackedUse}, what is returned is + * of the pooled object implements {@link TrackedUse}, what is returned is * the maximum of {@link TrackedUse#getLastUsed()} and * {@link #getLastBorrowTime()}; otherwise this method gives the same * value as {@link #getLastBorrowTime()}. - * + * * @return the last time this object was used */ public long getLastUsed() { @@ -184,7 +185,7 @@ public class PooledObject implements } public synchronized boolean endEvictionTest( - LinkedBlockingDeque> idleQueue) { + Deque> idleQueue) { if (state == PooledObjectState.EVICTION) { state = PooledObjectState.IDLE; return true; @@ -241,7 +242,7 @@ public class PooledObject implements public synchronized void invalidate() { state = PooledObjectState.INVALID; } - + /** * Prints the stack trace of the code that created this pooled object to * the configured log writer. Does nothing of no PrintWriter was supplied @@ -252,7 +253,7 @@ public class PooledObject implements createdBy.printStackTrace(logWriter); } } - + /** * Returns the state of this object. * @return state @@ -260,21 +261,21 @@ public class PooledObject implements public synchronized PooledObjectState getState() { return state; } - + /** * Marks the pooled object as abandoned. */ public synchronized void markAbandoned() { state = PooledObjectState.ABANDONED; } - + /** * Marks the object as returning to the pool. */ public synchronized void markReturning() { state = PooledObjectState.RETURNING; } - + static class AbandonedObjectException extends Exception { private static final long serialVersionUID = 7398692158058772916L;