tyrex.resource

Class PoolLimits

public final class PoolLimits extends Object

Represents limits placed on a connection pool. The limits are read from the configuration file and apply to the connection pool.

The following XML elements are used to specify the pool limits:

This object is thread-safe and mutable. Modifying the pool limits associated with an active connection pool will affect the future behavior of the connection pool.

Version: $Revision: 1.2 $

Author: Assaf Arkin

Field Summary
static intNO_LIMIT
Value representing no limit.
static intNO_TIMEOUT
Valued representing no timeout.
Method Summary
intgetInitial()
Returns the initial pool size.
intgetMaximum()
Returns the maximum number of connections supported.
intgetMaxRetain()
Returns the maximum time to retain an unused connection.
intgetMinimum()
Returns the minimum number of connections required.
intgetReuseOption()
Return the reuse option.
StringgetReuseOptionAsString()
Return the reuse option.
intgetTimeout()
Returns the timeout when attempting to open a new connection.
booleangetTrace()
Returns the tracing flag.
voidsetInitial(int initial)
Sets the initial connection pool size.
voidsetMaximum(int maximum)
Sets the maximum number of connections supported.
voidsetMaxRetain(int seconds)
Sets the maximum time to retain an unused connection.
voidsetMinimum(int minimum)
Sets the minimum number of connections required.
voidsetReuseOption(int option)
Set the reuse option.
voidsetReuseOptionAsString(String option)
Set the reuse option.
voidsetTimeout(int seconds)
Sets the timeout when attempting to open a new connection.
voidsetTrace(boolean trace)
Sets the tracing flag.

Field Detail

NO_LIMIT

public static final int NO_LIMIT
Value representing no limit. Used for the maximum pool size and maximum retain time.

NO_TIMEOUT

public static final int NO_TIMEOUT
Valued representing no timeout.

Method Detail

getInitial

public int getInitial()
Returns the initial pool size. When the resource manager is loaded, the connection pool will attempt to create that number of connections.

Returns: The initial pool size

getMaximum

public int getMaximum()
Returns the maximum number of connections supported. If this value s zero, no limit is placed on the connection pool.

Returns: The maximum number of connections supported, or zero

getMaxRetain

public int getMaxRetain()
Returns the maximum time to retain an unused connection. This is the longest duration an unusued connection will be retained in the pool, specified in seconds.

Returns: The maximum time to retain an unused connection (in seconds), or zero

getMinimum

public int getMinimum()
Returns the minimum number of connections required. The connection pool will not attempt to release unused connections when the pool size falls below this threshold.

Returns: The minimum number of connections required

getReuseOption

public int getReuseOption()
Return the reuse option. This is the option that controls the reuse of a connection when it is returned to the pool.

Returns: One of REUSE_ON, REUSE_OFF, REUSE_TRANSACTION or REUSE_TRANSACTION_OFF

See Also: REUSE_OFF REUSE_TRANSACTION REUSE_TRANSACTION_OFF

getReuseOptionAsString

public String getReuseOptionAsString()
Return the reuse option. This is the option that controls the reuse of a connection when it is returned to the pool.

Returns: One of REUSE_ON_NAME, REUSE_OFF_NAME, REUSE_TRANSACTION_NAME or REUSE_TRANSACTION_OFF_NAME

See Also: REUSE_OFF_NAME REUSE_TRANSACTION_NAME REUSE_TRANSACTION_OFF_NAME

getTimeout

public int getTimeout()
Returns the timeout when attempting to open a new connection. This is the longest duration to wait for a new connection to be available when the pool has reached its maximum size, specified in seconds.

Returns: The timeout when attempting to open a new connection (in seconds), or zero

getTrace

public boolean getTrace()
Returns the tracing flag. If this value is true, the resource manager will be asked to write trace information to the log.

Returns: True if resource manager should write trace information to the log

setInitial

public void setInitial(int initial)
Sets the initial connection pool size. When the resource manager is loaded, the connection pool will attempt to create that number of connections.

Parameters: initial The initial pool size

setMaximum

public void setMaximum(int maximum)
Sets the maximum number of connections supported. If this value is zero, no limit is placed on the connection pool.

If this value is non-zero, the connection pool will not allow more connections to be opened than this upper limit. If this value is higher than the maximum connections reported by the resource manager, the latter will be used.

Parameters: maximum The maximum number of connections supported, or zero

setMaxRetain

public void setMaxRetain(int seconds)
Sets the maximum time to retain an unused connection. This is the longest duration an unusued connection will be retained in the pool, specified in seconds.

If this number if not zero, the connection pool will attempt to release connections that have not been used for that amount of time. The connection pool will not release connections if the pool size is equal to the value specified by getMinimum.

Parameters: seconds The maximum time to retain an unused connection (in seconds), or zero

setMinimum

public void setMinimum(int minimum)
Sets the minimum number of connections required. The connection pool will not attempt to release unused connections when the pool size falls below this threshold.

This threshold can be used to determine the number of connections that are always available in the pool. However, the connection pool will not attempt to create that number of connections directly.

Parameters: minimum The minimum number of connections required

setReuseOption

public void setReuseOption(int option)
Set the reuse option. This is the option that controls the reuse of a connection when it is returned to the pool.

Parameters: One of REUSE_ON, REUSE_OFF, REUSE_TRANSACTION or REUSE_TRANSACTION_OFF

Throws: IllegalArgumentException if the reuse option is not recognised.

See Also: REUSE_OFF REUSE_TRANSACTION REUSE_TRANSACTION_OFF

setReuseOptionAsString

public void setReuseOptionAsString(String option)
Set the reuse option. This is the option that controls the reuse of a connection when it is returned to the pool.

Parameters: One of REUSE_ON_NAME, REUSE_OFF_NAME, REUSE_TRANSACTION_NAME or REUSE_TRANSACTION_OFF_NAME

Throws: IllegalArgumentException if the reuse option is not recognised.

See Also: REUSE_OFF_NAME REUSE_TRANSACTION_NAME REUSE_TRANSACTION_OFF_NAME

setTimeout

public void setTimeout(int seconds)
Sets the timeout when attempting to open a new connection. This is the longest duration to wait for a new connection to be available when the pool has reached its maximum size, specified in seconds.

If this value is not zero, the connection pool will block up to this number of milliseconds if it is unable to obtain an existing connection. The connection pool is not able to obtain an existing connection if the connection pool size has reached the maximum size as specified by getMaximum.

Parameters: timeout The timeout when attempting to open a new connection (in seconds), or zero

setTrace

public void setTrace(boolean trace)
Sets the tracing flag. If this value is true, the resource manager will be asked to write trace information to the log.

Parameters: trace True if resource manager should write trace information to the log

Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.