Class BaseKeyedObjectPool<K,V>
- Type Parameters:
K- the type of keys in this poolV- the type of objects held in this pool
- All Implemented Interfaces:
KeyedObjectPool<K,V>
- Direct Known Subclasses:
GenericKeyedObjectPool,StackKeyedObjectPool
KeyedObjectPool.
Optional operations are implemented to either do nothing, return a value
indicating it is unsupported or throw UnsupportedOperationException.- Since:
- Pool 1.0
- Version:
- $Revision: 1222396 $ $Date: 2011-12-22 14:02:25 -0500 (Thu, 22 Dec 2011) $
- Author:
- Rodney Waldhoff, Sandy McArthur
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidNot supported in this base implementation.abstract VborrowObject(K key) Obtains an instance from this pool for the specifiedkey.voidclear()Not supported in this base implementation.voidNot supported in this base implementation.voidclose()Close this pool.intNot supported in this base implementation.intgetNumActive(K key) Not supported in this base implementation.intNot supported in this base implementation.intgetNumIdle(K key) Not supported in this base implementation.abstract voidinvalidateObject(K key, V obj) Invalidates an object from the pool.abstract voidreturnObject(K key, V obj) Return an instance to the pool.
-
Constructor Details
-
BaseKeyedObjectPool
public BaseKeyedObjectPool()
-
-
Method Details
-
borrowObject
Obtains an instance from this pool for the specifiedkey.Instances returned from this method will have been either newly created with
makeObjector will be a previously idle object and have been activated withactivateObjectand then validated withvalidateObject.By contract, clients must return the borrowed object using
returnObject,invalidateObject, or a related method as defined in an implementation or sub-interface, using akeythat isequivalentto the one used to borrow the instance in the first place.The behaviour of this method when the pool has been exhausted is not strictly specified (although it may be specified by implementations). Older versions of this method would return
nullto indicate exhaustion, newer versions are encouraged to throw aNoSuchElementException.- Specified by:
borrowObjectin interfaceKeyedObjectPool<K,V> - Parameters:
key- the key used to obtain the object- Returns:
- an instance from this pool.
- Throws:
IllegalStateException- afterclosehas been called on this poolException- whenmakeObjectthrows an exceptionNoSuchElementException- when the pool is exhausted and cannot or will not return another instance
-
returnObject
Return an instance to the pool. By contract,objmust have been obtained usingborrowObjector a related method as defined in an implementation or sub-interface using akeythat is equivalent to the one used to borrow the instance in the first place.- Specified by:
returnObjectin interfaceKeyedObjectPool<K,V> - Parameters:
key- the key used to obtain the objectobj- aborrowedinstance to be returned.- Throws:
Exception
-
invalidateObject
Invalidates an object from the pool.
By contract,
objmust have been obtained usingborrowObjectusing akeythat is equivalent to the one used to borrow theObjectin the first place.This method should be used when an object that has been borrowed is determined (due to an exception or other problem) to be invalid.
- Specified by:
invalidateObjectin interfaceKeyedObjectPool<K,V> - Parameters:
key- the key used to obtain the objectobj- aborrowedinstance to be returned.- Throws:
Exception
-
addObject
Not supported in this base implementation. Always throws anUnsupportedOperationException, subclasses should override this behavior.- Specified by:
addObjectin interfaceKeyedObjectPool<K,V> - Parameters:
key- ignored- Throws:
UnsupportedOperationExceptionException- whenKeyedPoolableObjectFactory.makeObject(K)fails.IllegalStateException- afterKeyedObjectPool.close()has been called on this pool.
-
getNumIdle
Not supported in this base implementation.- Specified by:
getNumIdlein interfaceKeyedObjectPool<K,V> - Parameters:
key- ignored- Returns:
- a negative value.
- Throws:
UnsupportedOperationException- deprecated: when this implementation doesn't support the operation
-
getNumActive
Not supported in this base implementation.- Specified by:
getNumActivein interfaceKeyedObjectPool<K,V> - Parameters:
key- ignored- Returns:
- a negative value.
- Throws:
UnsupportedOperationException- deprecated: when this implementation doesn't support the operation
-
getNumIdle
Not supported in this base implementation.- Specified by:
getNumIdlein interfaceKeyedObjectPool<K,V> - Returns:
- a negative value.
- Throws:
UnsupportedOperationException- deprecated: when this implementation doesn't support the operation
-
getNumActive
Not supported in this base implementation.- Specified by:
getNumActivein interfaceKeyedObjectPool<K,V> - Returns:
- a negative value.
- Throws:
UnsupportedOperationException- deprecated: when this implementation doesn't support the operation
-
clear
Not supported in this base implementation.- Specified by:
clearin interfaceKeyedObjectPool<K,V> - Throws:
UnsupportedOperationExceptionException
-
clear
Not supported in this base implementation.- Specified by:
clearin interfaceKeyedObjectPool<K,V> - Parameters:
key- ignored- Throws:
UnsupportedOperationExceptionException
-
close
Close this pool. This affects the behavior ofisClosedandassertOpen.- Specified by:
closein interfaceKeyedObjectPool<K,V> - Throws:
Exception
-