net.csdn.modules.thrift.pool
Class BaseObjectPool.Builder<K,V>

java.lang.Object
  extended by net.csdn.modules.thrift.pool.BaseObjectPool.Builder<K,V>
Enclosing class:
BaseObjectPool<K,V>

public static class BaseObjectPool.Builder<K,V>
extends Object


Constructor Summary
BaseObjectPool.Builder(PoolableObjectFactory<K,V> factory)
          BaseObjectPool's builder constructor
 
Method Summary
 BaseObjectPool.Builder<K,V> borrowValidation(boolean borrowValidation)
          Set whether this pool should validate the object by PoolableObjectFactory.validateObject(K, V) before returning a borrowed object to the user

Default is false.

 ObjectPool<K,V> build()
          Create an ObjectPool instance with this builder's properties
 BaseObjectPool.Builder<K,V> disposable(boolean disposable)
          Set disposable property

If this pool is bounded and doesn't have idle objects any more, temporary object will be returned to the user if disposable is true.

 BaseObjectPool.Builder<K,V> keepAliveTimeoutInSecs(long keepAliveTimeoutInSecs)
          Set the KeepAliveTimeout of this pool

This pool will schedule BaseObjectPool.EvictionTask with this interval.

 BaseObjectPool.Builder<K,V> max(int max)
          Set maximum size of this pool

Default is unbounded as Integer.MAX_VALUE.

 BaseObjectPool.Builder<K,V> min(int min)
          Set minimum size of this pool

Default is 5.

 BaseObjectPool.Builder<K,V> returnValidation(boolean returnValidation)
          Set whether this pool should validate the object by PoolableObjectFactory.validateObject(K, V) before returning a borrowed object to the pool

Default is false.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseObjectPool.Builder

public BaseObjectPool.Builder(PoolableObjectFactory<K,V> factory)
BaseObjectPool's builder constructor

Parameters:
factory - PoolableObjectFactory which is for creating, validating and destroying an object
Method Detail

min

public BaseObjectPool.Builder<K,V> min(int min)
Set minimum size of this pool

Default is 5.

Parameters:
min - min size
Returns:
this builder

max

public BaseObjectPool.Builder<K,V> max(int max)
Set maximum size of this pool

Default is unbounded as Integer.MAX_VALUE.

Parameters:
max - max size
Returns:
this builder

borrowValidation

public BaseObjectPool.Builder<K,V> borrowValidation(boolean borrowValidation)
Set whether this pool should validate the object by PoolableObjectFactory.validateObject(K, V) before returning a borrowed object to the user

Default is false.

Parameters:
borrowValidation - true if validation will be needed
Returns:
this builder

returnValidation

public BaseObjectPool.Builder<K,V> returnValidation(boolean returnValidation)
Set whether this pool should validate the object by PoolableObjectFactory.validateObject(K, V) before returning a borrowed object to the pool

Default is false.

Parameters:
returnValidation - true if validation will be needed
Returns:
this builder

disposable

public BaseObjectPool.Builder<K,V> disposable(boolean disposable)
Set disposable property

If this pool is bounded and doesn't have idle objects any more, temporary object will be returned to the user if disposable is true. The disposable object will be returned to the pool, it will be destroyed silently. Default is false.

Parameters:
disposable - true if the pool allows disposable objects
Returns:
this builder

keepAliveTimeoutInSecs

public BaseObjectPool.Builder<K,V> keepAliveTimeoutInSecs(long keepAliveTimeoutInSecs)
Set the KeepAliveTimeout of this pool

This pool will schedule BaseObjectPool.EvictionTask with this interval. BaseObjectPool.EvictionTask will evict idle objects if this pool has more than min objects. If the given parameter is negative, this pool never schedules BaseObjectPool.EvictionTask. Default is 1800.

Parameters:
keepAliveTimeoutInSecs - KeepAliveTimeout in seconds
Returns:
this builder

build

public ObjectPool<K,V> build()
Create an ObjectPool instance with this builder's properties

Returns:
an object pool


Copyright © 2014. All Rights Reserved.