You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/04/23 17:49:19 UTC

svn commit: r1096165 - in /commons/proper/pool/trunk/src/java/org/apache/commons/pool: ObjectPool.java ObjectPoolFactory.java PoolableObjectFactory.java

Author: simonetripodi
Date: Sat Apr 23 15:49:19 2011
New Revision: 1096165

URL: http://svn.apache.org/viewvc?rev=1096165&view=rev
Log:
restored generics in the ObjectPool and related interfaces

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPoolFactory.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolableObjectFactory.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java?rev=1096165&r1=1096164&r2=1096165&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java Sat Apr 23 15:49:19 2011
@@ -62,7 +62,7 @@ import java.util.NoSuchElementException;
  * @see BaseObjectPool
  * @since Pool 1.0
  */
-public interface ObjectPool {
+public interface ObjectPool<T> {
     /**
      * Obtains an instance from this pool.
      * <p>
@@ -88,7 +88,7 @@ public interface ObjectPool {
      * @throws Exception when {@link PoolableObjectFactory#makeObject makeObject} throws an exception.
      * @throws NoSuchElementException when the pool is exhausted and cannot or will not return another instance.
      */
-    Object borrowObject() throws Exception, NoSuchElementException, IllegalStateException;
+    T borrowObject() throws Exception, NoSuchElementException, IllegalStateException;
 
     /**
      * Return an instance to the pool.
@@ -100,7 +100,7 @@ public interface ObjectPool {
      * @param obj a {@link #borrowObject borrowed} instance to be returned.
      * @throws Exception 
      */
-    void returnObject(Object obj) throws Exception;
+    void returnObject(T obj) throws Exception;
 
     /**
      * <p>Invalidates an object from the pool.</p>
@@ -115,7 +115,7 @@ public interface ObjectPool {
      * @param obj a {@link #borrowObject borrowed} instance to be disposed.
      * @throws Exception
      */
-    void invalidateObject(Object obj) throws Exception;
+    void invalidateObject(T obj) throws Exception;
 
     /**
      * Create an object using the {@link PoolableObjectFactory factory} or other
@@ -186,5 +186,5 @@ public interface ObjectPool {
      * @throws UnsupportedOperationException if this implementation does not support the operation
      * @deprecated to be removed in pool 2.0
      */
-    void setFactory(PoolableObjectFactory factory) throws IllegalStateException, UnsupportedOperationException;
+    void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException, UnsupportedOperationException;
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPoolFactory.java?rev=1096165&r1=1096164&r2=1096165&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPoolFactory.java Sat Apr 23 15:49:19 2011
@@ -26,11 +26,11 @@ package org.apache.commons.pool;
  * @version $Revision$ $Date$
  * @since Pool 1.0
  */
-public interface ObjectPoolFactory {
+public interface ObjectPoolFactory<T> {
     /**
      * Create and return a new {@link ObjectPool}.
      * @return a new {@link ObjectPool}
      * @throws IllegalStateException when this pool factory is not configured properly
      */
-    ObjectPool createPool() throws IllegalStateException;
+    ObjectPool<T> createPool() throws IllegalStateException;
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolableObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolableObjectFactory.java?rev=1096165&r1=1096164&r2=1096165&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolableObjectFactory.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/PoolableObjectFactory.java Sat Apr 23 15:49:19 2011
@@ -71,7 +71,7 @@ package org.apache.commons.pool;
  * @version $Revision$ $Date$
  * @since Pool 1.0
  */
-public interface PoolableObjectFactory {
+public interface PoolableObjectFactory<T> {
   /**
    * Creates an instance that can be served by the pool.
    * Instances returned from this method should be in the
@@ -83,7 +83,7 @@ public interface PoolableObjectFactory {
    * @throws Exception if there is a problem creating a new instance,
    *    this will be propagated to the code requesting an object.
    */
-  Object makeObject() throws Exception;
+  T makeObject() throws Exception;
 
   /**
    * Destroys an instance no longer needed by the pool.
@@ -104,7 +104,7 @@ public interface PoolableObjectFactory {
    * @see #validateObject
    * @see ObjectPool#invalidateObject
    */
-  void destroyObject(Object obj) throws Exception;
+  void destroyObject(T obj) throws Exception;
 
   /**
    * Ensures that the instance is safe to be returned by the pool.
@@ -114,7 +114,7 @@ public interface PoolableObjectFactory {
    * @return <code>false</code> if <code>obj</code> is not valid and should
    *         be dropped from the pool, <code>true</code> otherwise.
    */
-  boolean validateObject(Object obj);
+  boolean validateObject(T obj);
 
   /**
    * Reinitialize an instance to be returned by the pool.
@@ -124,7 +124,7 @@ public interface PoolableObjectFactory {
    *    this exception may be swallowed by the pool.
    * @see #destroyObject
    */
-  void activateObject(Object obj) throws Exception;
+  void activateObject(T obj) throws Exception;
 
   /**
    * Uninitialize an instance to be returned to the idle object pool.
@@ -134,5 +134,5 @@ public interface PoolableObjectFactory {
    *    this exception may be swallowed by the pool.
    * @see #destroyObject
    */
-  void passivateObject(Object obj) throws Exception;
+  void passivateObject(T obj) throws Exception;
 }



Re: svn commit: r1096165 - in /commons/proper/pool/trunk/src/java/org/apache/commons/pool: ObjectPool.java ObjectPoolFactory.java PoolableObjectFactory.java

Posted by Simone Tripodi <si...@apache.org>.
Hi Phil,
thanks for your prompt feedback!!!

On Sat, Apr 23, 2011 at 6:36 PM, Phil Steitz <ph...@gmail.com> wrote:
> Can you please either do something to suppress all the checkstyle
> warnings generated because of missing "T" params or add them?

sure, just give me the time to get the doc how to do it.

> Also, its fine if it is easier to do the initial commit of these
> changes with the pool package name, but we should change the package
> name ASAP.

my fault, got too distracted by generics, I currently have an appended
commit, then I'll move the package

> It would also be great to update the developer documentation and
> examples once the repackaging has been done.  Might be good to raise
> an issue for this so we don't forget it.

Going to do it now!!!

> Thanks!
>
> Phil
>

Thanks to you! :)
Simo

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1096165 - in /commons/proper/pool/trunk/src/java/org/apache/commons/pool: ObjectPool.java ObjectPoolFactory.java PoolableObjectFactory.java

Posted by Phil Steitz <ph...@gmail.com>.
Can you please either do something to suppress all the checkstyle
warnings generated because of missing "T" params or add them?

Also, its fine if it is easier to do the initial commit of these
changes with the pool package name, but we should change the package
name ASAP.

It would also be great to update the developer documentation and
examples once the repackaging has been done.  Might be good to raise
an issue for this so we don't forget it.

Thanks!

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org