org.apache.commons.pool.impl
クラス GenericObjectPool

java.lang.Object
  拡張org.apache.commons.pool.BaseObjectPool
      拡張org.apache.commons.pool.impl.GenericObjectPool
すべての実装インタフェース:
ObjectPool

public class GenericObjectPool
extends BaseObjectPool
implements ObjectPool

詳細な設定の可能な ObjectPool の実装です。

A configurable {@link ObjectPool} implementation.

適切な PoolableObjectFactory と対となって動作することにより GenericObjectPool は強固な任意のオブジェクトのプーリングの機能を提供します。

When coupled with the appropriate {@link PoolableObjectFactory}, GenericObjectPool provides robust pooling functionality for arbitrary objects.

GenericObjectPool は多くの設定可能なパラメータを提供します。

A GenericObjectPool provides a number of configurable parameters:

オプションとして、プール内を走査して不正な状態でプール内に居続けるオブジェクトを排除する設定をすることができます。 これは非同期な "未使用オブジェクト排除" スレッドで行われます。 "未使用オブジェクト排除" スレッドの挙動は以下の属性で設定されます:

Optionally, one may configure the pool to examine and possibly evict objects as they sit idle in the pool. This is performed by an "idle object eviction" thread, which runs asychronously. The idle object eviction thread may be configured using the following attributes:

PoolableObjectFactory を使用しない場合、GenericObjectPool は有用ではありません。 コンストラクタの引数または、setFactory(org.apache.commons.pool.PoolableObjectFactory) メソッドをコールすることによって null ではないファクトリを提供する必要があります。

GenericObjectPool is not usable without a {@link PoolableObjectFactory}. A non-null factory must be provided either as a constructor argument or via a call to {@link #setFactory} before the pool is used.

バージョン:
$Revision: 1.1 $ $Date: 2004/02/22 11:58:26 $
作成者:
Rodney Waldhoff, Dirk Verbeeck
関連項目:
GenericKeyedObjectPool
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2004/02/21

入れ子クラスの概要
static class GenericObjectPool.Config
          GenericObjectPool のための設定情報を格納したシンプルな "構造体(のようなもの)" です。
 
フィールドの概要
static int DEFAULT_MAX_ACTIVE
          同時にプールから取り出すことのできるインスタンスの最大数のデフォルト値です。
static int DEFAULT_MAX_IDLE
          プール内に保持できる未使用インスタンスの最大数のデフォルト値です。
static long DEFAULT_MAX_WAIT
          プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)のデフォルト値です。
static long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
          getMinEvictableIdleTimeMillis() のデフォルト値です。
static int DEFAULT_MIN_IDLE
          プール内に保持される未使用インスタンスの最少数のデフォルト値です。
static int DEFAULT_NUM_TESTS_PER_EVICTION_RUN
          1度のオブジェクト排除処理でチェックされるオブジェクトの数のデフォルト値です。
static boolean DEFAULT_TEST_ON_BORROW
          オブジェクトの状態を "取り出し時に確認" するかどうかのデフォルトの値です。
static boolean DEFAULT_TEST_ON_RETURN
          オブジェクトの状態を "戻される時に確認" するかどうかのデフォルトの値です。
static boolean DEFAULT_TEST_WHILE_IDLE
          オブジェクトの状態を "未使用の間に確認" するかどうかのデフォルトの値です。
static long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
          "オブジェクト排除処理の実行間隔" のデフォルトの値です。
static byte DEFAULT_WHEN_EXHAUSTED_ACTION
          "使い尽された時の処理"のタイプのデフォルト値です。
static byte WHEN_EXHAUSTED_BLOCK
          "使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは新たなオブジェクトが利用できるまでまたは 最大待機時間 に達するまで待機します。
static byte WHEN_EXHAUSTED_FAIL
          "使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは失敗し、NoSuchElementException を投げます。
static byte WHEN_EXHAUSTED_GROW
          "使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは単純にとにかく新たなオブジェクトを生成します。
 
コンストラクタの概要
GenericObjectPool()
          新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, GenericObjectPool.Config config)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
          指定された値を使用して新たな GenericObjectPool を生成します。
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
          指定された値を使用して新たな GenericObjectPool を生成します。
 
メソッドの概要
 void addObject()
          Create an object, and place it into the pool.
 Object borrowObject()
          プールからインスタンスを取り出します。
 void clear()
          プール内にある使用されていないオブジェクトを削除し、関連するリソースを開放します(オプショナルな処理)。
 void close()
          このプールを閉じ、関連する全てのリソースを開放します。
 void evict()
           
 int getMaxActive()
          同時にプールから取り出すことのできるオブジェクトの最大数を返します。
 int getMaxIdle()
          プール内に保持できる未使用のオブジェクトの最大数を返します。
 long getMaxWait()
          プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)を返します。
 long getMinEvictableIdleTimeMillis()
          オブジェクトがプール内に未使用状態でいられる時間の最小値を返します。
 int getMinIdle()
          プール内に保持される未使用のオブジェクトの最小数を返します。
 int getNumActive()
          現在プールから貸し出されているインスタンスの数を返します(オプショナルな処理)。
 int getNumIdle()
          現在プール内にある使用されていないインスタンスの数を返します(オプショナルな処理)。
 int getNumTestsPerEvictionRun()
          1度のオブジェクト排除処理で排除スレッドにチェックされるオブジェクトの数を返します。
 boolean getTestOnBorrow()
          この値が true の場合 インスタンスが borrowObject() メソッドにて取り出される前に 有効かどうかの確認 を行います。
 boolean getTestOnReturn()
          この値が true の場合 オブジェクトが returnObject(java.lang.Object) メソッドにて戻される前に 有効かどうかの確認 を行います。
 boolean getTestWhileIdle()
          この値が true の場合 オブジェクト排除処理によってオブジェクトに対する 有効かどうかの確認 が実施されます。
 long getTimeBetweenEvictionRunsMillis()
          未使用オブジェクト排除処理が次の実行までの間スリープする時間(ミリセカンド)を返します。
 byte getWhenExhaustedAction()
          プールが使い尽されている場合(取り出すことのできるオブジェクトが最大数に達した場合)に borrowObject() メソッドが行う処理の種別を返します。
 void invalidateObject(Object obj)
          プール内で管理されるオブジェクトを無効にします。
 void returnObject(Object obj)
          プールにインスタンスを返します。
 void setConfig(GenericObjectPool.Config conf)
          設定情報を登録します。
 void setFactory(PoolableObjectFactory factory)
          新たなインスタンスを生成するために使用する factory を設定します(オプショナルな処理)。
 void setMaxActive(int maxActive)
          同時にプールから取り出すことのできるオブジェクトの最大数を設定します。
 void setMaxIdle(int maxIdle)
          プール内に保持できる未使用のオブジェクトの最大数を設定します。
 void setMaxWait(long maxWait)
          プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)を設定します。
 void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
          オブジェクトがプール内に未使用状態でいられる時間の最小値を設定します。
 void setMinIdle(int minIdle)
          プール内に保持される未使用のオブジェクトの最小数を設定します。
 void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
          1度のオブジェクト排除処理で排除スレッドにチェックされるオブジェクトの数を返します。
 void setTestOnBorrow(boolean testOnBorrow)
          この値が true の場合 オブジェクトが borrowObject() メソッドにて取り出される前に 有効かどうかの確認 を行います。
 void setTestOnReturn(boolean testOnReturn)
          この値が true の場合 オブジェクトが returnObject(java.lang.Object) メソッドにて戻される前に 有効かどうかの確認 を行います。
 void setTestWhileIdle(boolean testWhileIdle)
          この値が true の場合 オブジェクト排除処理によってオブジェクトに対する 有効かどうかの確認 が実施されます。
 void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
          未使用オブジェクト排除処理が次の実行までの間スリープする時間(ミリセカンド)を設定します。
 void setWhenExhaustedAction(byte whenExhaustedAction)
          プールが使い尽されている場合(取り出すことのできるオブジェクトが最大数に達した場合)に borrowObject() メソッドが行う処理の種別を設定します。
 
クラス java.lang.Object から継承したメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

DEFAULT_MAX_ACTIVE

public static final int DEFAULT_MAX_ACTIVE
同時にプールから取り出すことのできるインスタンスの最大数のデフォルト値です。
The default cap on the total number of active instances from the pool.

関連項目:
getMaxActive(), 定数フィールド値

DEFAULT_MAX_IDLE

public static final int DEFAULT_MAX_IDLE
プール内に保持できる未使用インスタンスの最大数のデフォルト値です。
The default cap on the number of "sleeping" instances in the pool.

関連項目:
getMaxIdle(), setMaxIdle(int), 定数フィールド値

DEFAULT_MAX_WAIT

public static final long DEFAULT_MAX_WAIT
プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)のデフォルト値です。
The default maximum amount of time (in millis) the {@link #borrowObject} method should block before throwing an exception when the pool is exhausted and the {@link #getWhenExhaustedAction "when exhausted" action} is {@link #WHEN_EXHAUSTED_BLOCK}.

関連項目:
getMaxWait(), setMaxWait(long), 定数フィールド値

DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS

public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
getMinEvictableIdleTimeMillis() のデフォルト値です。
The default value for {@link #getMinEvictableIdleTimeMillis}.

関連項目:
getMinEvictableIdleTimeMillis(), setMinEvictableIdleTimeMillis(long), 定数フィールド値

DEFAULT_MIN_IDLE

public static final int DEFAULT_MIN_IDLE
プール内に保持される未使用インスタンスの最少数のデフォルト値です。
The default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.

関連項目:
getMinIdle(), setMinIdle(int), 定数フィールド値

DEFAULT_NUM_TESTS_PER_EVICTION_RUN

public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN
1度のオブジェクト排除処理でチェックされるオブジェクトの数のデフォルト値です。
The default number of objects to examine per run in the idle object evictor.

関連項目:
getNumTestsPerEvictionRun(), setNumTestsPerEvictionRun(int), getTimeBetweenEvictionRunsMillis(), setTimeBetweenEvictionRunsMillis(long), 定数フィールド値

DEFAULT_TEST_ON_BORROW

public static final boolean DEFAULT_TEST_ON_BORROW
オブジェクトの状態を "取り出し時に確認" するかどうかのデフォルトの値です。
The default "test on borrow" value.

関連項目:
getTestOnBorrow(), setTestOnBorrow(boolean), 定数フィールド値

DEFAULT_TEST_ON_RETURN

public static final boolean DEFAULT_TEST_ON_RETURN
オブジェクトの状態を "戻される時に確認" するかどうかのデフォルトの値です。
The default "test on return" value.

関連項目:
getTestOnReturn(), setTestOnReturn(boolean), 定数フィールド値

DEFAULT_TEST_WHILE_IDLE

public static final boolean DEFAULT_TEST_WHILE_IDLE
オブジェクトの状態を "未使用の間に確認" するかどうかのデフォルトの値です。
The default "test while idle" value.

関連項目:
getTestWhileIdle(), setTestWhileIdle(boolean), getTimeBetweenEvictionRunsMillis(), setTimeBetweenEvictionRunsMillis(long), 定数フィールド値

DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS

public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
"オブジェクト排除処理の実行間隔" のデフォルトの値です。
The default "time between eviction runs" value.

関連項目:
getTimeBetweenEvictionRunsMillis(), setTimeBetweenEvictionRunsMillis(long), 定数フィールド値

DEFAULT_WHEN_EXHAUSTED_ACTION

public static final byte DEFAULT_WHEN_EXHAUSTED_ACTION
"使い尽された時の処理"のタイプのデフォルト値です。
The default "when exhausted action" for the pool.

関連項目:
WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW, setWhenExhaustedAction(byte), 定数フィールド値

WHEN_EXHAUSTED_BLOCK

public static final byte WHEN_EXHAUSTED_BLOCK
"使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは新たなオブジェクトが利用できるまでまたは 最大待機時間 に達するまで待機します。
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the {@link #borrowObject} method should block until a new object is available, or the {@link #getMaxWait maximum wait time} has been reached.

関連項目:
WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW, setMaxWait(long), getMaxWait(), setWhenExhaustedAction(byte), 定数フィールド値

WHEN_EXHAUSTED_FAIL

public static final byte WHEN_EXHAUSTED_FAIL
"使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは失敗し、NoSuchElementException を投げます。
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the {@link #borrowObject} method should fail, throwing a {@link NoSuchElementException}.

関連項目:
WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_GROW, setWhenExhaustedAction(byte), 定数フィールド値

WHEN_EXHAUSTED_GROW

public static final byte WHEN_EXHAUSTED_GROW
"使い尽された時の処理"のタイプ、 プールが尽されている場合 (同時にプールから取り出すことのできるオブジェクトの最大数に達した場合) の処理を示し、borrowObject() メソッドは単純にとにかく新たなオブジェクトを生成します。
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the {@link #borrowObject} method should simply create a new object anyway.

関連項目:
WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW, setWhenExhaustedAction(byte), 定数フィールド値
コンストラクタの詳細

GenericObjectPool

public GenericObjectPool()
新たな GenericObjectPool を生成します。
Create a new GenericObjectPool.


GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         GenericObjectPool.Config config)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
config - 設定情報を定義する GenericObjectPool.Config ( null を許容しません)
a non-null {@link GenericObjectPool.Config} describing my configuration

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait,
                         boolean testOnBorrow,
                         boolean testOnReturn)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数 (setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
testOnBorrow - オブジェクトの状態を borrowObject() メソッドを使って取り出す前に確認するかどうか (getTestOnBorrow() を参照)
whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})
testOnReturn - オブジェクトの状態を returnObject(java.lang.Object) メソッドを使って戻した後に確認するかどうか (getTestOnReturn() を参照)
whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait,
                         int maxIdle)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
maxIdle - プール内に保持できる未使用のオブジェクトの最大数 (getMaxIdle() を参照)
the maximum number of idle objects in my pool (see {@link #getMaxIdle})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait,
                         int maxIdle,
                         boolean testOnBorrow,
                         boolean testOnReturn)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
maxIdle - プール内に保持できる未使用のオブジェクトの最大数 (getMaxIdle() を参照)
the maximum number of idle objects in my pool (see {@link #getMaxIdle})
testOnBorrow - オブジェクトの状態を borrowObject() メソッドを使って取り出す前に確認するかどうか (getTestOnBorrow() を参照)
whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})
testOnReturn - オブジェクトの状態を returnObject(java.lang.Object) メソッドを使って戻した後に確認するかどうか (getTestOnReturn() を参照)
whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait,
                         int maxIdle,
                         boolean testOnBorrow,
                         boolean testOnReturn,
                         long timeBetweenEvictionRunsMillis,
                         int numTestsPerEvictionRun,
                         long minEvictableIdleTimeMillis,
                         boolean testWhileIdle)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
maxIdle - プール内に保持できる未使用のオブジェクトの最大数 (getMaxIdle() を参照)
the maximum number of idle objects in my pool (see {@link #getMaxIdle})
testOnBorrow - オブジェクトの状態を borrowObject() メソッドを使って取り出す前に確認するかどうか (getTestOnBorrow() を参照)
whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})
testOnReturn - オブジェクトの状態を returnObject(java.lang.Object) メソッドを使って戻した後に確認するかどうか (getTestOnReturn() を参照)
whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})
timeBetweenEvictionRunsMillis - 未使用オブジェクト排除処理が次の実行までの間スリープする時間(ミリセカンド) (setTimeBetweenEvictionRunsMillis(long) を参照)
the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see {@link #setTimeBetweenEvictionRunsMillis})
numTestsPerEvictionRun - 1度のオブジェクト排除処理でチェックされるオブジェクトの数 (setNumTestsPerEvictionRun(int) を参照)
the number of idle objects to examine per run within the idle object eviction thread (if any) (see {@link #setNumTestsPerEvictionRun})
minEvictableIdleTimeMillis - オブジェクトがプール内に未使用状態でいられる時間の最小値(ミリセカンド) (setMinEvictableIdleTimeMillis(long) を参照)
the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see {@link #setMinEvictableIdleTimeMillis})
testWhileIdle - 未使用状態のオブジェクトを未使用オブジェクト排除スレッドでチェックするかどうか (setTestWhileIdle(boolean) を参照)
whether or not to validate objects in the idle object eviction thread, if any (see {@link #setTestWhileIdle})

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory,
                         int maxActive,
                         byte whenExhaustedAction,
                         long maxWait,
                         int maxIdle,
                         int minIdle,
                         boolean testOnBorrow,
                         boolean testOnReturn,
                         long timeBetweenEvictionRunsMillis,
                         int numTestsPerEvictionRun,
                         long minEvictableIdleTimeMillis,
                         boolean testWhileIdle)
指定された値を使用して新たな GenericObjectPool を生成します。
Create a new GenericObjectPool using the specified values.

パラメータ:
factory - オブジェクトの生成、確認、破棄を行う際に使用される PoolableObjectFactory( null を許容します)
the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects
maxActive - 同時にプールから取り出すことのできるオブジェクトの最大数(setMaxActive(int) を参照)
the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})
whenExhaustedAction - プールが使い尽されている場合の処理 (getWhenExhaustedAction() を参照)
the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})
maxWait - プールが使い尽されていて whenExhaustedActionWHEN_EXHAUSTED_BLOCK の場合(それ以外の場合、無視されます)の最長待機時間 (getMaxWait() を参照)
the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
maxIdle - プール内に保持できる未使用のオブジェクトの最大数 (getMaxIdle() を参照)
the maximum number of idle objects in my pool (see {@link #getMaxIdle})
minIdle - プール内に保持される未使用のオブジェクトの最少数 (setMinIdle(int) を参照)
the minimum number of idle objects in my pool (see {@link #setMinIdle})
testOnBorrow - オブジェクトの状態を borrowObject() メソッドを使って取り出す前に確認するかどうか (getTestOnBorrow() を参照)
whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})
testOnReturn - オブジェクトの状態を returnObject(java.lang.Object) メソッドを使って戻した後に確認するかどうか (getTestOnReturn() を参照)
whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})
timeBetweenEvictionRunsMillis - 未使用オブジェクト排除処理が次の実行までの間スリープする時間(ミリセカンド) (setTimeBetweenEvictionRunsMillis(long) を参照)
the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see {@link #setTimeBetweenEvictionRunsMillis})
numTestsPerEvictionRun - 1度のオブジェクト排除処理でチェックされるオブジェクトの数 (setNumTestsPerEvictionRun(int) を参照)
the number of idle objects to examine per run within the idle object eviction thread (if any) (see {@link #setNumTestsPerEvictionRun})
minEvictableIdleTimeMillis - オブジェクトがプール内に未使用状態でいられる時間の最小値(ミリセカンド) (setMinEvictableIdleTimeMillis(long) を参照)
the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see {@link #setMinEvictableIdleTimeMillis})
testWhileIdle - 未使用状態のオブジェクトを未使用オブジェクト排除スレッドでチェックするかどうか (setTestWhileIdle(boolean) を参照)
whether or not to validate objects in the idle object eviction thread, if any (see {@link #setTestWhileIdle})
メソッドの詳細

addObject

public void addObject()
               throws Exception
Create an object, and place it into the pool. addObject() is useful for "pre-loading" a pool with idle objects.

定義:
インタフェース ObjectPool 内の addObject
オーバーライド:
クラス BaseObjectPool 内の addObject
例外:
Exception

borrowObject

public Object borrowObject()
                    throws Exception
インタフェース ObjectPool の記述:
プールからインスタンスを取り出します。 プールからインスタンスを取得したクライアントは必ず returnObject または実装クラスやサブインターフェイスのそれと関連するメソッドを使用して インスタンスをプールに返さなくてはなりません。
Obtain an instance from my pool. By contract, clients MUST return the borrowed instance using {@link #returnObject(java.lang.Object) returnObject} or a related method as defined in an implementation or sub-interface.

プール内のインスタンスが空の場合のこのメソッドの振る舞いは明示されません (各実装クラスで明示されるでしょう)。

The behaviour of this method when the pool has been exhausted is not specified (although it may be specified by implementations).

定義:
インタフェース ObjectPool 内の borrowObject
定義:
クラス BaseObjectPool 内の borrowObject
例外:
Exception

clear

public void clear()
インタフェース ObjectPool の記述:
プール内にある使用されていないオブジェクトを削除し、関連するリソースを開放します(オプショナルな処理)。
Clears any objects sitting idle in the pool, releasing any associated resources (optional operation).

定義:
インタフェース ObjectPool 内の clear
オーバーライド:
クラス BaseObjectPool 内の clear

close

public void close()
           throws Exception
インタフェース ObjectPool の記述:
このプールを閉じ、関連する全てのリソースを開放します。
Close this pool, and free any resources associated with it.

定義:
インタフェース ObjectPool 内の close
オーバーライド:
クラス BaseObjectPool 内の close
例外:
Exception

evict

public void evict()
           throws Exception
例外:
Exception

getMaxActive

public int getMaxActive()
同時にプールから取り出すことのできるオブジェクトの最大数を返します。
Returns the cap on the total number of active instances from my pool.

戻り値:
取り出すことのできるオブジェクトの最大数
the cap on the total number of active instances from my pool.
関連項目:
setMaxActive(int)

getMaxIdle

public int getMaxIdle()
プール内に保持できる未使用のオブジェクトの最大数を返します。
Returns the cap on the number of "idle" instances in the pool.

戻り値:
プール内に保持できる未使用のオブジェクトの最大数
the cap on the number of "idle" instances in the pool.
関連項目:
setMaxIdle(int)

getMaxWait

public long getMaxWait()
プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)を返します。 0より小さな値が設定された場合、borrowObject() メソッドは無期限に待機します。
Returns the maximum amount of time (in milliseconds) the {@link #borrowObject} method should block before throwing an exception when the pool is exhausted and the {@link #setWhenExhaustedAction "when exhausted" action} is {@link #WHEN_EXHAUSTED_BLOCK}.
When less than 0, the borrowObject() method may block indefinitely.}

関連項目:
setMaxWait(long), setWhenExhaustedAction(byte), WHEN_EXHAUSTED_BLOCK

getMinEvictableIdleTimeMillis

public long getMinEvictableIdleTimeMillis()
オブジェクトがプール内に未使用状態でいられる時間の最小値を返します。 未使用状態でいる時間がこの値に達すると排除処理の対象となります。
Returns the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).

関連項目:
setMinEvictableIdleTimeMillis(long), setTimeBetweenEvictionRunsMillis(long)

getMinIdle

public int getMinIdle()
プール内に保持される未使用のオブジェクトの最小数を返します。 この値に達しない場合には排除処理スレッドにて新たなオブジェクトの生成を行います。 (Note no objects are created when: numActive + numIdle >= maxActive)
Returns the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects. (Note no objects are created when: numActive + numIdle >= maxActive)

戻り値:
オブジェクトの最小数
The minimum number of objects.
関連項目:
setMinIdle(int)

getNumActive

public int getNumActive()
インタフェース ObjectPool の記述:
現在プールから貸し出されているインスタンスの数を返します(オプショナルな処理)。
Return the number of instances currently borrowed from my pool (optional operation).

定義:
インタフェース ObjectPool 内の getNumActive
オーバーライド:
クラス BaseObjectPool 内の getNumActive

getNumIdle

public int getNumIdle()
インタフェース ObjectPool の記述:
現在プール内にある使用されていないインスタンスの数を返します(オプショナルな処理)。 これは新たなインスタンスを生成せずに 取得 することのできるオブジェクトの数を対象とします。
Return the number of instances currently idle in my pool (optional operation). This may be considered an approximation of the number of objects that can be {@link #borrowObject borrowed} without creating any new instances.

定義:
インタフェース ObjectPool 内の getNumIdle
オーバーライド:
クラス BaseObjectPool 内の getNumIdle

getNumTestsPerEvictionRun

public int getNumTestsPerEvictionRun()
1度のオブジェクト排除処理で排除スレッドにチェックされるオブジェクトの数を返します。
Returns the number of objects to examine during each run of the idle object evictor thread (if any).

関連項目:
setNumTestsPerEvictionRun(int), setTimeBetweenEvictionRunsMillis(long)

getTestOnBorrow

public boolean getTestOnBorrow()
この値が true の場合 インスタンスが borrowObject() メソッドにて取り出される前に 有効かどうかの確認 を行います。 有効でないと判断された場合、オブジェクトはプールから破棄され、他のオブジェクトが取り出されます。
When true, objects will be {@link PoolableObjectFactory#validateObject validated} before being returned by the {@link #borrowObject} method. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.

関連項目:
setTestOnBorrow(boolean)

getTestOnReturn

public boolean getTestOnReturn()
この値が true の場合 オブジェクトが returnObject(java.lang.Object) メソッドにて戻される前に 有効かどうかの確認 を行います。
When true, objects will be {@link PoolableObjectFactory#validateObject validated} before being returned to the pool within the {@link #returnObject}.

関連項目:
setTestOnReturn(boolean)

getTestWhileIdle

public boolean getTestWhileIdle()
この値が true の場合 オブジェクト排除処理によってオブジェクトに対する 有効かどうかの確認 が実施されます。 有効でないと判断されたオブジェクトはプールから破棄されます。
When true, objects will be {@link PoolableObjectFactory#validateObject validated} by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.

関連項目:
setTestWhileIdle(boolean), setTimeBetweenEvictionRunsMillis(long)

getTimeBetweenEvictionRunsMillis

public long getTimeBetweenEvictionRunsMillis()
未使用オブジェクト排除処理が次の実行までの間スリープする時間(ミリセカンド)を返します。 マイナスの値が設定された場合、排除スレッドは起動しません。
Returns the number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.

関連項目:
setTimeBetweenEvictionRunsMillis(long)

getWhenExhaustedAction

public byte getWhenExhaustedAction()
プールが使い尽されている場合(取り出すことのできるオブジェクトが最大数に達した場合)に borrowObject() メソッドが行う処理の種別を返します。
Returns the action to take when the {@link #borrowObject} method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).

戻り値:
WHEN_EXHAUSTED_BLOCKWHEN_EXHAUSTED_FAILWHEN_EXHAUSTED_GROW のうちののどれか
one of {@link #WHEN_EXHAUSTED_BLOCK}, {@link #WHEN_EXHAUSTED_FAIL} or {@link #WHEN_EXHAUSTED_GROW}
関連項目:
setWhenExhaustedAction(byte)

invalidateObject

public void invalidateObject(Object obj)
                      throws Exception
インタフェース ObjectPool の記述:
プール内で管理されるオブジェクトを無効にします。 対象となる objborrowObject か、実装クラスに定義された関連するメソッドか、 key を用いたサブインターフェイスの同等の機能を持つメソッドによって取得されたものでなくてはなりません。
Invalidates an object from the pool By contract, obj MUST have been obtained using {@link #borrowObject() borrowObject} or a related method as defined in an implementation or sub-interface.

このメソッドはプールから取得されたオブジェクトが(例外等で)無効であるとみなされた場合に使用するべきです。 オブジェクト取得の前、もしくは戻された後にオブジェクトの評価を行う場合には PoolableObjectFactory.validateObject(java.lang.Object) を使用して下さい。

This method should be used when an object that has been borrowed is determined (due to an exception or other problem) to be invalid. If the connection should be validated before or after borrowing, then the {@link PoolableObjectFactory#validateObject} method should be used instead.

定義:
インタフェース ObjectPool 内の invalidateObject
定義:
クラス BaseObjectPool 内の invalidateObject
例外:
Exception

returnObject

public void returnObject(Object obj)
                  throws Exception
インタフェース ObjectPool の記述:
プールにインスタンスを返します。 プールに返される obj は必ず borrowObject または実装クラスやサブインターフェイスのそれと関連するメソッドを使用して 取得されたインスタンスでなくてはなりません。
Return an instance to my pool. By contract, obj MUST have been obtained using {@link #borrowObject() borrowObject} or a related method as defined in an implementation or sub-interface.

定義:
インタフェース ObjectPool 内の returnObject
定義:
クラス BaseObjectPool 内の returnObject
例外:
Exception

setConfig

public void setConfig(GenericObjectPool.Config conf)
設定情報を登録します。
Sets my configuration.

関連項目:
GenericObjectPool.Config

setFactory

public void setFactory(PoolableObjectFactory factory)
                throws IllegalStateException
インタフェース ObjectPool の記述:
新たなインスタンスを生成するために使用する factory を設定します(オプショナルな処理)。
Sets the {@link PoolableObjectFactory ファクトリ} I use to create new instances (optional operation).

定義:
インタフェース ObjectPool 内の setFactory
オーバーライド:
クラス BaseObjectPool 内の setFactory
例外:
IllegalStateException

setMaxActive

public void setMaxActive(int maxActive)
同時にプールから取り出すことのできるオブジェクトの最大数を設定します。
Sets the cap on the total number of active instances from my pool.

パラメータ:
maxActive - 取り出すことのできるオブジェクトの最大数、 インスタンスの数を制限しない場合にはマイナスの値を設定します
The cap on the total number of active instances from my pool. Use a negative value for an infinite number of instances.
関連項目:
getMaxActive()

setMaxIdle

public void setMaxIdle(int maxIdle)
プール内に保持できる未使用のオブジェクトの最大数を設定します。
Sets the cap on the number of "idle" instances in the pool.

パラメータ:
maxIdle - プール内に保持できる未使用のオブジェクトの最大数 マイナスの値が設定された場合には同時にプール内に保持できるオブジェクトを制限しません
The cap on the number of "idle" instances in the pool. Use a negative value to indicate an unlimited number of idle instances.
関連項目:
getMaxIdle()

setMaxWait

public void setMaxWait(long maxWait)
プールが使い尽されていて "使い尽された時の処理"WHEN_EXHAUSTED_BLOCK が設定されている場合の borrowObject() メソッドが例外を投げるまでの最長待機時間(ミリセカンド)を設定します。 0より小さな値が設定された場合、borrowObject() メソッドは無期限に待機します。
Sets the maximum amount of time (in milliseconds) the {@link #borrowObject} method should block before throwing an exception when the pool is exhausted and the {@link #setWhenExhaustedAction "when exhausted" action} is {@link #WHEN_EXHAUSTED_BLOCK}.
When less than 0, the borrowObject() method may block indefinitely.}

関連項目:
getMaxWait(), setWhenExhaustedAction(byte), WHEN_EXHAUSTED_BLOCK

setMinEvictableIdleTimeMillis

public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
オブジェクトがプール内に未使用状態でいられる時間の最小値を設定します。 未使用状態でいる時間がこの値に達すると排除処理の対象となります。 マイナスの値が設定された場合、未使用状態でいる時間が原因ではオブジェクトの削除は行われません。
Sets the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). When non-positive, no objects will be evicted from the pool due to idl