Author: simonetripodi
Date: Sat Apr 23 18:34:52 2011
New Revision: 1096204
URL: http://svn.apache.org/viewvc?rev=1096204&view=rev
Log:
restored generics to KeyedObjectPool interface and related Factories
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPool.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPoolFactory.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedPoolableObjectFactory.java
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPool.java
URL:
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPool.java?rev=1096204&r1=1096203&r2=1096204&view=diff
==============================================================================
---
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPool.java
(original)
+++
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPool.java
Sat Apr 23 18:34:52 2011
@@ -64,7 +64,7 @@ import java.util.NoSuchElementException;
* @see BaseKeyedObjectPool
* @since Pool 1.0
*/
-public interface KeyedObjectPool {
+public interface KeyedObjectPool<K,V> {
/**
* Obtains an instance from this pool for the specified <code>key</code>.
* <p>
@@ -90,7 +90,7 @@ public interface KeyedObjectPool {
* @throws Exception when {@link KeyedPoolableObjectFactory#makeObject
makeObject} throws an exception
* @throws NoSuchElementException when the pool is exhausted and cannot or
will not return another instance
*/
- Object borrowObject(Object key) throws Exception, NoSuchElementException,
IllegalStateException;
+ V borrowObject(K key) throws Exception, NoSuchElementException,
IllegalStateException;
/**
* Return an instance to the pool.
@@ -105,7 +105,7 @@ public interface KeyedObjectPool {
* @param obj a {@link #borrowObject borrowed} instance to be returned.
* @throws Exception
*/
- void returnObject(Object key, Object obj) throws Exception;
+ void returnObject(K key, V obj) throws Exception;
/**
* <p>Invalidates an object from the pool.</p>
@@ -122,7 +122,7 @@ public interface KeyedObjectPool {
* @param obj a {@link #borrowObject borrowed} instance to be returned.
* @throws Exception
*/
- void invalidateObject(Object key, Object obj) throws Exception;
+ void invalidateObject(K key, V obj) throws Exception;
/**
* Create an object using the {@link KeyedPoolableObjectFactory factory}
or other
@@ -135,7 +135,7 @@ public interface KeyedObjectPool {
* @throws IllegalStateException after {@link #close} has been called on
this pool.
* @throws UnsupportedOperationException when this pool cannot add new
idle objects.
*/
- void addObject(Object key) throws Exception, IllegalStateException,
UnsupportedOperationException;
+ void addObject(K key) throws Exception, IllegalStateException,
UnsupportedOperationException;
/**
* Returns the number of instances
@@ -147,7 +147,7 @@ public interface KeyedObjectPool {
* @return the number of instances corresponding to the given
<code>key</code> currently idle in this pool or a negative value if unsupported
* @throws UnsupportedOperationException <strong>deprecated</strong>: when
this implementation doesn't support the operation
*/
- int getNumIdle(Object key) throws UnsupportedOperationException;
+ int getNumIdle(K key) throws UnsupportedOperationException;
/**
* Returns the number of instances
@@ -160,7 +160,7 @@ public interface KeyedObjectPool {
* @return the number of instances corresponding to the given
<code>key</code> currently borrowed in this pool or a negative value if
unsupported
* @throws UnsupportedOperationException <strong>deprecated</strong>: when
this implementation doesn't support the operation
*/
- int getNumActive(Object key) throws UnsupportedOperationException;
+ int getNumActive(K key) throws UnsupportedOperationException;
/**
* Returns the total number of instances
@@ -200,7 +200,7 @@ public interface KeyedObjectPool {
* @param key the key to clear
* @throws UnsupportedOperationException when this implementation doesn't
support the operation
*/
- void clear(Object key) throws Exception, UnsupportedOperationException;
+ void clear(K key) throws Exception, UnsupportedOperationException;
/**
* Close this pool, and free any resources associated with it.
@@ -225,5 +225,5 @@ public interface KeyedObjectPool {
* @throws UnsupportedOperationException when this implementation doesn't
support the operation
* @deprecated to be removed in pool 2.0
*/
- void setFactory(KeyedPoolableObjectFactory factory) throws
IllegalStateException, UnsupportedOperationException;
+ void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws
IllegalStateException, UnsupportedOperationException;
}
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPoolFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPoolFactory.java?rev=1096204&r1=1096203&r2=1096204&view=diff
==============================================================================
---
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPoolFactory.java
(original)
+++
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedObjectPoolFactory.java
Sat Apr 23 18:34:52 2011
@@ -26,11 +26,11 @@ package org.apache.commons.pool2;
* @version $Revision$ $Date$
* @since Pool 1.0
*/
-public interface KeyedObjectPoolFactory {
+public interface KeyedObjectPoolFactory<K,V> {
/**
* Create a new {@link KeyedObjectPool}.
* @return a new {@link KeyedObjectPool}
* @throws IllegalStateException when this pool factory is not configured
properly
*/
- KeyedObjectPool createPool() throws IllegalStateException;
+ KeyedObjectPool<K,V> createPool() throws IllegalStateException;
}
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedPoolableObjectFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedPoolableObjectFactory.java?rev=1096204&r1=1096203&r2=1096204&view=diff
==============================================================================
---
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedPoolableObjectFactory.java
(original)
+++
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/KeyedPoolableObjectFactory.java
Sat Apr 23 18:34:52 2011
@@ -71,7 +71,7 @@ package org.apache.commons.pool2;
* @version $Revision$ $Date$
* @since Pool 1.0
*/
-public interface KeyedPoolableObjectFactory {
+public interface KeyedPoolableObjectFactory<K,V> {
/**
* Create an instance that can be served by the pool.
*
@@ -80,7 +80,7 @@ public interface KeyedPoolableObjectFact
* @throws Exception if there is a problem creating a new instance,
* this will be propagated to the code requesting an object.
*/
- Object makeObject(Object key) throws Exception;
+ V makeObject(K key) throws Exception;
/**
* Destroy an instance no longer needed by the pool.
@@ -102,7 +102,7 @@ public interface KeyedPoolableObjectFact
* @see #validateObject
* @see KeyedObjectPool#invalidateObject
*/
- void destroyObject(Object key, Object obj) throws Exception;
+ void destroyObject(K key, V obj) throws Exception;
/**
* Ensures that the instance is safe to be returned by the pool.
@@ -113,7 +113,7 @@ public interface KeyedPoolableObjectFact
* @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 key, Object obj);
+ boolean validateObject(K key, V obj);
/**
* Reinitialize an instance to be returned by the pool.
@@ -124,7 +124,7 @@ public interface KeyedPoolableObjectFact
* this exception may be swallowed by the pool.
* @see #destroyObject
*/
- void activateObject(Object key, Object obj) throws Exception;
+ void activateObject(K key, V obj) throws Exception;
/**
* Uninitialize an instance to be returned to the idle object pool.
@@ -135,5 +135,5 @@ public interface KeyedPoolableObjectFact
* this exception may be swallowed by the pool.
* @see #destroyObject
*/
- void passivateObject(Object key, Object obj) throws Exception;
+ void passivateObject(K key, V obj) throws Exception;
}