tyrex.resource
Class PoolLimits

java.lang.Object
  extended bytyrex.resource.PoolLimits

public final class PoolLimits
extends java.lang.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 int NO_LIMIT
          Value representing no limit.
static int NO_TIMEOUT
          Valued representing no timeout.
 
Constructor Summary
PoolLimits()
           
 
Method Summary
 int getInitial()
          Returns the initial pool size.
 int getMaximum()
          Returns the maximum number of connections supported.
 int getMaxRetain()
          Returns the maximum time to retain an unused connection.
 int getMinimum()
          Returns the minimum number of connections required.
 int getReuseOption()
          Return the reuse option.
 java.lang.String getReuseOptionAsString()
          Return the reuse option.
 int getTimeout()
          Returns the timeout when attempting to open a new connection.
 boolean getTrace()
          Returns the tracing flag.
 void setInitial(int initial)
          Sets the initial connection pool size.
 void setMaximum(int maximum)
          Sets the maximum number of connections supported.
 void setMaxRetain(int seconds)
          Sets the maximum time to retain an unused connection.
 void setMinimum(int minimum)
          Sets the minimum number of connections required.
 void setReuseOption(int option)
          Set the reuse option.
 void setReuseOptionAsString(java.lang.String option)
          Set the reuse option.
 void setTimeout(int seconds)
          Sets the timeout when attempting to open a new connection.
 void setTrace(boolean trace)
          Sets the tracing flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_LIMIT

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

See Also:
Constant Field Values

NO_TIMEOUT

public static final int NO_TIMEOUT
Valued representing no timeout.

See Also:
Constant Field Values
Constructor Detail

PoolLimits

public PoolLimits()
Method Detail

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

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

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

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

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

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

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

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

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.


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

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

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

setReuseOptionAsString

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

Throws:
java.lang.IllegalArgumentException - if the reuse option is not recognised.
See Also:
ReuseOptions.REUSE_OFF_NAME, ReuseOptions.REUSE_TRANSACTION_NAME, ReuseOptions.REUSE_TRANSACTION_OFF_NAME

getReuseOptionAsString

public java.lang.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 ReuseOptions.REUSE_ON_NAME, ReuseOptions.REUSE_OFF_NAME, ReuseOptions.REUSE_TRANSACTION_NAME or ReuseOptions.REUSE_TRANSACTION_OFF_NAME
See Also:
ReuseOptions.REUSE_OFF_NAME, ReuseOptions.REUSE_TRANSACTION_NAME, ReuseOptions.REUSE_TRANSACTION_OFF_NAME

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.

Throws:
java.lang.IllegalArgumentException - if the reuse option is not recognised.
See Also:
ReuseOptions.REUSE_OFF, ReuseOptions.REUSE_TRANSACTION, ReuseOptions.REUSE_TRANSACTION_OFF

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 ReuseOptions.REUSE_ON, ReuseOptions.REUSE_OFF, ReuseOptions.REUSE_TRANSACTION or ReuseOptions.REUSE_TRANSACTION_OFF
See Also:
ReuseOptions.REUSE_OFF, ReuseOptions.REUSE_TRANSACTION, ReuseOptions.REUSE_TRANSACTION_OFF


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.