SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

serp.util
Class AbstractPool

java.lang.Object
  |
  +--serp.util.AbstractPool
All Implemented Interfaces:
Collection, Pool, Set

Deprecated. Use the Jakarta project's Commons Pool module.

public abstract class AbstractPool
extends Object
implements Pool

Abstract generic pool implementation. Subclasses must implement the freeCollection() and takenMap() methods to return mutable views of the free and taken pool instances, respectively.

This implementation is not synchronized.


Constructor Summary
AbstractPool()
          Deprecated. Construct an empty pool with min, max, wait, autoReturn properties of 0.
AbstractPool(Collection c)
          Deprecated. Construct a pool initialized with the given collection of free instances.
AbstractPool(int min, int max, int wait, int autoReturn)
          Deprecated. Construct a pool with the given properties.
 
Method Summary
 boolean add(Object obj)
          Deprecated.  
 boolean addAll(Collection c)
          Deprecated.  
protected  void clean()
          Deprecated. Returns expired taken objects to the pool, and removes any null entries from the taken set (can occur if the taken set map does not hold strong references to its entries).
 void clear()
          Deprecated.  
 boolean contains(Object obj)
          Deprecated.  
 boolean containsAll(Collection c)
          Deprecated.  
protected  Object create(Object match)
          Deprecated. Return a new pool element matching the given criteria passed to the get(Object,Comparator) method.
 boolean equals(Object obj)
          Deprecated. Pool equality should be implemented to compare the free elements of the pool.
protected  Object find(Object match, Comparator comp)
          Deprecated. Locates a pooled object that matches the given instance according to the given comparator.
protected  void free(Object obj)
          Deprecated. Free the resources taken by the given pool element.
protected abstract  Collection freeCollection()
          Deprecated. Provide a modifiable view of the free pool instances.
 Object get()
          Deprecated. Return a free object from the pool.
 Object get(Object match)
          Deprecated. Return a free object from the pool that compares true using Object.equals(java.lang.Object) to the given instance.
 Object get(Object match, Comparator comp)
          Deprecated. Return a free object matching from the pool.
 int getAutoReturn()
          Deprecated. Return the maximum number of milliseconds a pooled item can be taken before it is automatically returned to the pool.
 int getMaxPool()
          Deprecated. Return the maximum number of pooled items, including taken instances.
 int getMinPool()
          Deprecated. Return the minimum number of pooled items, including taken instances.
 int getWait()
          Deprecated. Return the maximum number of milliseconds the get() method will wait for a free pool item.
 int hashCode()
          Deprecated. The hash code should be implemented to be consistent with equality.
 boolean isEmpty()
          Deprecated.  
protected  boolean isValid(Object obj)
          Deprecated. Return false if the given pool element is no longer valid.
 Iterator iterator()
          Deprecated. Returns an iterator over the free elements of the pool.
 boolean remove(Object obj)
          Deprecated.  
 boolean removeAll(Collection c)
          Deprecated.  
 boolean retainAll(Collection c)
          Deprecated.  
 void setAutoReturn(int millis)
          Deprecated. Return the maximum number of milliseconds a pooled item can be taken before it is automatically returned to the pool.
 void setMaxPool(int max)
          Deprecated. Set the maximum number of pooled items, including taken instances.
 void setMinPool(int min)
          Deprecated. Set the minimum number of pooled items, including taken instances.
 void setWait(int millis)
          Deprecated. Set the maximum number of milliseconds the get() method will wait for a free pool item.
 int size()
          Deprecated.  
protected abstract  Map takenMap()
          Deprecated. Provide a modifiable map view of the taken pool instances.
 Set takenSet()
          Deprecated. Return a read-only view of the set of taken instances.
 Object[] toArray()
          Deprecated.  
 Object[] toArray(Object[] fill)
          Deprecated.  
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPool

public AbstractPool()
Deprecated. 
Construct an empty pool with min, max, wait, autoReturn properties of 0.

AbstractPool

public AbstractPool(int min,
                    int max,
                    int wait,
                    int autoReturn)
Deprecated. 
Construct a pool with the given properties.
Parameters:
min - the minimum pool size, including taken instances
max - the maximum pool size, including taken instances
wait - the maximum number of milliseconds to wait for a free instance
autoReturn - the number of milliseconds after which taken instances can be automatically reclaimed

AbstractPool

public AbstractPool(Collection c)
Deprecated. 
Construct a pool initialized with the given collection of free instances.
Method Detail

getMaxPool

public int getMaxPool()
Deprecated. 
Description copied from interface: Pool
Return the maximum number of pooled items, including taken instances. A value of 0 indicates that there should be no maximum. This property defaults to 0.
Specified by:
getMaxPool in interface Pool

setMaxPool

public void setMaxPool(int max)
Deprecated. 
Description copied from interface: Pool
Set the maximum number of pooled items, including taken instances. A value of 0 indicates that there should be no maximum. This property defaults to 0. If it is set to less than the current size of the pool, the free instances will be trimmed to size, and subsequence Collection.add(java.lang.Object) operations will return false until the maximum is met.
Specified by:
setMaxPool in interface Pool

getMinPool

public int getMinPool()
Deprecated. 
Description copied from interface: Pool
Return the minimum number of pooled items, including taken instances. This property defaults to 0. If greater than 0, Collection.remove(java.lang.Object) methods may fail if the size would be trimmed to under the minimum value.
Specified by:
getMinPool in interface Pool

setMinPool

public void setMinPool(int min)
Deprecated. 
Description copied from interface: Pool
Set the minimum number of pooled items, including taken instances. This property defaults to 0. If set to greater than 0, Collection.remove(java.lang.Object) operations may fail if the constraint would be violated. However, the Collection.clear() operation will always succeed.
Specified by:
setMinPool in interface Pool

getWait

public int getWait()
Deprecated. 
Description copied from interface: Pool
Return the maximum number of milliseconds the Pool.get() method will wait for a free pool item. This property defaults to 0.
Specified by:
getWait in interface Pool

setWait

public void setWait(int millis)
Deprecated. 
Description copied from interface: Pool
Set the maximum number of milliseconds the Pool.get() method will wait for a free pool item. This property defaults to 0.
Specified by:
setWait in interface Pool

getAutoReturn

public int getAutoReturn()
Deprecated. 
Description copied from interface: Pool
Return the maximum number of milliseconds a pooled item can be taken before it is automatically returned to the pool. If this property is set to 0, taken items will never be automatically returned. This property defaults to 0.
Specified by:
getAutoReturn in interface Pool

setAutoReturn

public void setAutoReturn(int millis)
Deprecated. 
Description copied from interface: Pool
Return the maximum number of milliseconds a pooled item can be taken before it is automatically returned to the pool. If this property is set to 0, taken items will never be automatically returned. This property defaults to 0.
Specified by:
setAutoReturn in interface Pool

iterator

public Iterator iterator()
Deprecated. 
Description copied from interface: Pool
Returns an iterator over the free elements of the pool. The iterator's Iterator.remove() remove method may throw an IllegalStateException if removing an element would violoate the minimum pool size.
Specified by:
iterator in interface Pool

size

public int size()
Deprecated. 
Specified by:
size in interface Set

isEmpty

public boolean isEmpty()
Deprecated. 
Specified by:
isEmpty in interface Set

contains

public boolean contains(Object obj)
Deprecated. 
Specified by:
contains in interface Set

containsAll

public boolean containsAll(Collection c)
Deprecated. 
Specified by:
containsAll in interface Set

toArray

public Object[] toArray()
Deprecated. 
Specified by:
toArray in interface Set

toArray

public Object[] toArray(Object[] fill)
Deprecated. 
Specified by:
toArray in interface Set

add

public boolean add(Object obj)
Deprecated. 
Specified by:
add in interface Set

addAll

public boolean addAll(Collection c)
Deprecated. 
Specified by:
addAll in interface Set

remove

public boolean remove(Object obj)
Deprecated. 
Specified by:
remove in interface Set

removeAll

public boolean removeAll(Collection c)
Deprecated. 
Specified by:
removeAll in interface Set

retainAll

public boolean retainAll(Collection c)
Deprecated. 
Specified by:
retainAll in interface Set

clear

public void clear()
Deprecated. 
Specified by:
clear in interface Set

equals

public boolean equals(Object obj)
Deprecated. 
Description copied from interface: Pool
Pool equality should be implemented to compare the free elements of the pool.
Specified by:
equals in interface Pool
Overrides:
equals in class Object

hashCode

public int hashCode()
Deprecated. 
Description copied from interface: Pool
The hash code should be implemented to be consistent with equality.
Specified by:
hashCode in interface Pool
Overrides:
hashCode in class Object

get

public Object get()
Deprecated. 
Return a free object from the pool.
Specified by:
get in interface Pool
See Also:
get(Object,Comparator)

get

public Object get(Object match)
Deprecated. 
Return a free object from the pool that compares true using Object.equals(java.lang.Object) to the given instance.
Specified by:
get in interface Pool
See Also:
get(Object,Comparator)

get

public Object get(Object match,
                  Comparator comp)
Deprecated. 
Return a free object matching from the pool. The object must match the given instance according to the given Comparator. All other get methods are implemented in terms of this version.
Specified by:
get in interface Pool
Parameters:
match - the object to compare to; may be null
comp - the comparator to use; if null and match is null, any object will match; if null and match is not null, matching will be based on the Object.equals(java.lang.Object) method
Throws:
NoSuchElementException - if no matching object can be obtained in the set wait period

takenSet

public Set takenSet()
Deprecated. 
Description copied from interface: Pool
Return a read-only view of the set of taken instances.
Specified by:
takenSet in interface Pool

find

protected Object find(Object match,
                      Comparator comp)
Deprecated. 
Locates a pooled object that matches the given instance according to the given comparator. The comparator will always be valid. This method is used by get() to find matching instances. The pool is first cleaned via the clean() method, then if the free set has any elements in it, it is iterated to find a matching instance. Before returning any matches the taken object is placed in the taken set along with the current time.
Returns:
a matching instance, or null if none

clean

protected void clean()
Deprecated. 
Returns expired taken objects to the pool, and removes any null entries from the taken set (can occur if the taken set map does not hold strong references to its entries).

freeCollection

protected abstract Collection freeCollection()
Deprecated. 
Provide a modifiable view of the free pool instances.

takenMap

protected abstract Map takenMap()
Deprecated. 
Provide a modifiable map view of the taken pool instances. Each entry will be used to map a taken instance to a Long value representing the millisecond time at which the key was taken. Implementations are free to use weak mappings.

isValid

protected boolean isValid(Object obj)
Deprecated. 
Return false if the given pool element is no longer valid. Returns true to everything by default.

free

protected void free(Object obj)
Deprecated. 
Free the resources taken by the given pool element. Does nothing by default.

create

protected Object create(Object match)
Deprecated. 
Return a new pool element matching the given criteria passed to the get(Object,Comparator) method. If auto-creation is not supported, return null. Returns null by default.

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.