The interface Pool defines an object that pools resources of any
kind. Resources must be requested (getResource) and released
(releaseResource) on demand. A Pool object can be parameterized along
different dimensions. All these dimensions are represented by accessor
methods (getters and setters) assigned to each of them:
A Timeout can be assigned to a Pool. It is used when no more
resources are available and when the Pool has reached its maximum size.
This is the timeout to wait for a free resource until exiting with an
exception. It defaults to 0, which means waiting forever until a
resource is freed. Its value should be greater or equal to 0 ; negative
values are ignored (setTimeOut(-1) => NOP).
A MinSize can be assigned to a Pool. Its value should be greater or
equal to 0, and smaller or equal to MaxSize. Values that do not match these
conditions are ignored (e.g., setMinSize(-1) => NOP).
This size means that there is always MinSize PoolResource allocated in this
Pool. If PoolResource needs to be allocated when setting this size,
"getPoolMatchFactory().createResource(null)" is called. Its default value
is 0.
A MatchFactory (i.e., a PoolMatchFactory object) must be assigned to
a Pool. It defines the way new PoolResource are created and the way a
PoolResource of a Pool matches some "hints" properties when requested. It is
mandatory for the Pool to be fully functional.
A MaxSize can be assigned to a Pool. Its value should be greater or
equal to 0, and greater or equal to MinSize. Values that do not match these
conditions are ignored (e.g., setMaxSize(-1) => NOP). Its default value
is 0, thus it is mandatory to set this value for making the Poll functional.
getResource(Object hints) getResource is used to allocate a Object from the Pool.
Some hints are passed in order to specialise the matching or creation
of Object.
Parameters: hints - Some properties to specialise the matching or the creationof Object.
int
getSamplingPeriod() getSamplingPeriod gets the number of seconds between statistics
sampling for this Pool.
releaseResource(Object resource, boolean destroy, boolean adjustment) releaseResource releases a Object in order to allow the
Pool to recycle this Object.
getResource is used to allocate a Object from the Pool.
Some hints are passed in order to specialise the matching or creation
of Object.
Parameters: hints - Some properties to specialise the matching or the creationof Object. The Object allocated from the Pool. throws: Exception - if an error occurs
releaseResource releases a Object in order to allow the
Pool to recycle this Object.
Parameters: resource - The Object to be released. Parameters: destroy - boolean to remove the object from the pool anddestroy it Parameters: adjustment - boolean to determine if a pool adjustment should be done throws: Exception - if an error occurs
setMaxWaitTime sets the maximum number of seconds to wait for a
connection in this Pool.
Parameters: maxWaitTime - int maximum number of seconds to wait
setSamplingPeriod sets the number of seconds between statistics
sampling for this Pool.
Parameters: samplingPeriod - int number of seconds between samplings