Class PoolConfig.Builder
java.lang.Object
cloud.opencode.base.pool.PoolConfig.Builder
- Enclosing class:
PoolConfig
Builder for PoolConfig.
PoolConfig构建器。
- Since:
- JDK 25, opencode-base-pool V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuration.eventListener(PoolEventListener<?> eventListener) Sets the pool event listener.evictionPolicy(EvictionPolicy<?> policy) Sets the eviction policy.lifo(boolean lifo) Sets LIFO ordering.maxIdle(int maxIdle) Sets the maximum idle objects.maxObjectLifetime(Duration maxObjectLifetime) Sets the maximum object lifetime before forced eviction.maxTotal(int maxTotal) Sets the maximum total objects.Sets the maximum wait time.minEvictableIdleTime(Duration duration) Sets the minimum evictable idle time.minIdle(int minIdle) Sets the minimum idle objects.numTestsPerEvictionRun(int numTests) Sets the number of tests per eviction run.testOnBorrow(boolean test) Sets whether to test on borrow.testOnCreate(boolean test) Sets whether to test on create.testOnReturn(boolean test) Sets whether to test on return.testWhileIdle(boolean test) Sets whether to test while idle.timeBetweenEvictionRuns(Duration duration) Sets the time between eviction runs.waitPolicy(WaitPolicy policy) Sets the wait policy.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
maxTotal
Sets the maximum total objects. 设置最大对象总数。- Parameters:
maxTotal- the max total - 最大总数- Returns:
- this builder - 此构建器
-
maxIdle
Sets the maximum idle objects. 设置最大空闲对象数。- Parameters:
maxIdle- the max idle - 最大空闲数- Returns:
- this builder - 此构建器
-
minIdle
Sets the minimum idle objects. 设置最小空闲对象数。- Parameters:
minIdle- the min idle - 最小空闲数- Returns:
- this builder - 此构建器
-
maxWait
Sets the maximum wait time. 设置最大等待时间。- Parameters:
maxWait- the max wait - 最大等待时间- Returns:
- this builder - 此构建器
-
minEvictableIdleTime
Sets the minimum evictable idle time. 设置最小可驱逐空闲时间。- Parameters:
duration- the duration - 时长- Returns:
- this builder - 此构建器
-
timeBetweenEvictionRuns
Sets the time between eviction runs. 设置驱逐运行之间的时间。- Parameters:
duration- the duration - 时长- Returns:
- this builder - 此构建器
-
numTestsPerEvictionRun
Sets the number of tests per eviction run. 设置每次驱逐运行的测试数。- Parameters:
numTests- the number of tests - 测试数- Returns:
- this builder - 此构建器
-
testOnBorrow
Sets whether to test on borrow. 设置是否在借用时测试。- Parameters:
test- true to test - 是否测试- Returns:
- this builder - 此构建器
-
testOnReturn
Sets whether to test on return. 设置是否在归还时测试。- Parameters:
test- true to test - 是否测试- Returns:
- this builder - 此构建器
-
testOnCreate
Sets whether to test on create. 设置是否在创建时测试。- Parameters:
test- true to test - 是否测试- Returns:
- this builder - 此构建器
-
testWhileIdle
Sets whether to test while idle. 设置是否在空闲时测试。- Parameters:
test- true to test - 是否测试- Returns:
- this builder - 此构建器
-
waitPolicy
Sets the wait policy. 设置等待策略。- Parameters:
policy- the policy - 策略- Returns:
- this builder - 此构建器
-
lifo
Sets LIFO ordering. 设置LIFO顺序。- Parameters:
lifo- true for LIFO - 是否LIFO- Returns:
- this builder - 此构建器
-
evictionPolicy
Sets the eviction policy. 设置驱逐策略。- Parameters:
policy- the policy - 策略- Returns:
- this builder - 此构建器
-
maxObjectLifetime
Sets the maximum object lifetime before forced eviction. 设置强制驱逐前的最大对象生命周期。- Parameters:
maxObjectLifetime- the max lifetime (Duration.ZERO to disable) - 最大生命周期(Duration.ZERO禁用)- Returns:
- this builder - 此构建器
-
eventListener
Sets the pool event listener. 设置池事件监听器。Type Safety Warning | 类型安全警告: The listener's type parameter must match the pool's object type
<T>. Due to Java type erasure, mismatched types will not cause a compile-time error but may result inClassCastExceptionat runtime when listener methods are invoked.监听器的类型参数必须与池的对象类型
<T>匹配。由于 Java 类型擦除, 类型不匹配不会产生编译时错误,但在调用监听器方法时可能导致ClassCastException。- Parameters:
eventListener- the event listener (null for none) - 事件监听器(null表示无)- Returns:
- this builder - 此构建器
-
build
-