File: BaseObjectPoolConfig.java

package info (click to toggle)
tomcat9 9.0.111-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,852 kB
  • sloc: java: 381,732; xml: 70,399; jsp: 4,682; sh: 1,336; perl: 324; makefile: 18; ansic: 14
file content (957 lines) | stat: -rw-r--r-- 40,722 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.tomcat.dbcp.pool2.impl;

import java.time.Duration;

import org.apache.tomcat.dbcp.pool2.BaseObject;

/**
 * Provides the implementation for the common attributes shared by the sub-classes. New instances of this class will be created using the defaults defined by
 * the public constants.
 * <p>
 * This class is not thread-safe.
 * </p>
 *
 * @param <T> Type of element pooled.
 * @since 2.0
 */
public abstract class BaseObjectPoolConfig<T> extends BaseObject implements Cloneable {

    /**
     * The default value for the {@code lifo} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getLifo()
     * @see GenericKeyedObjectPool#getLifo()
     */
    public static final boolean DEFAULT_LIFO = true;

    /**
     * The default value for the {@code fairness} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getFairness()
     * @see GenericKeyedObjectPool#getFairness()
     */
    public static final boolean DEFAULT_FAIRNESS = false;

    /**
     * The default value for the {@code maxWait} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @deprecated Use {@link #DEFAULT_MAX_WAIT}.
     */
    @Deprecated
    public static final long DEFAULT_MAX_WAIT_MILLIS = -1L;

    /**
     * The default value for the {@code maxWait} configuration attribute.
     *
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @since 2.10.0
     */
    public static final Duration DEFAULT_MAX_WAIT = Duration.ofMillis(DEFAULT_MAX_WAIT_MILLIS);

    /**
     * The default value for the {@code minEvictableIdleDuration} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @deprecated Use {@link #DEFAULT_MIN_EVICTABLE_IDLE_TIME}.
     */
    @Deprecated
    public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 1000L * 60L * 30L;

    /**
     * The default value for the {@code minEvictableIdleDuration} configuration attribute.
     *
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.11.0
     */
    public static final Duration DEFAULT_MIN_EVICTABLE_IDLE_DURATION = Duration.ofMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    /**
     * The default value for the {@code minEvictableIdleDuration} configuration attribute.
     *
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #DEFAULT_MIN_EVICTABLE_IDLE_DURATION}.
     */
    @Deprecated
    public static final Duration DEFAULT_MIN_EVICTABLE_IDLE_TIME = Duration.ofMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    /**
     * The default value for the {@code softMinEvictableIdleTime} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @deprecated Use {@link #DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME}.
     */
    @Deprecated
    public static final long DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS = -1;

    /**
     * The default value for the {@code softMinEvictableIdleTime} configuration attribute.
     *
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #DEFAULT_SOFT_MIN_EVICTABLE_IDLE_DURATION}.
     */
    @Deprecated
    public static final Duration DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME = Duration.ofMillis(DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    /**
     * The default value for the {@code softMinEvictableIdleTime} configuration attribute.
     *
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.11.0
     */
    public static final Duration DEFAULT_SOFT_MIN_EVICTABLE_IDLE_DURATION = Duration.ofMillis(DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);

    /**
     * The default value for {@code evictorShutdownTimeout} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @deprecated Use {@link #DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT}.
     */
    @Deprecated
    public static final long DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS = 10L * 1000L;

    /**
     * The default value for {@code evictorShutdownTimeout} configuration attribute.
     *
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @since 2.10.0
     */
    public static final Duration DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT = Duration.ofMillis(DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS);

    /**
     * The default value for the {@code numTestsPerEvictionRun} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getNumTestsPerEvictionRun()
     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
     */
    public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = 3;

    /**
     * The default value for the {@code testOnCreate} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getTestOnCreate()
     * @see GenericKeyedObjectPool#getTestOnCreate()
     * @since 2.2
     */
    public static final boolean DEFAULT_TEST_ON_CREATE = false;

    /**
     * The default value for the {@code testOnBorrow} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getTestOnBorrow()
     * @see GenericKeyedObjectPool#getTestOnBorrow()
     */
    public static final boolean DEFAULT_TEST_ON_BORROW = false;

    /**
     * The default value for the {@code testOnReturn} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getTestOnReturn()
     * @see GenericKeyedObjectPool#getTestOnReturn()
     */
    public static final boolean DEFAULT_TEST_ON_RETURN = false;

    /**
     * The default value for the {@code testWhileIdle} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getTestWhileIdle()
     * @see GenericKeyedObjectPool#getTestWhileIdle()
     */
    public static final boolean DEFAULT_TEST_WHILE_IDLE = false;

    /**
     * The default value for the {@code timeBetweenEvictionRuns} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @deprecated Use {@link #DEFAULT_TIME_BETWEEN_EVICTION_RUNS}.
     */
    @Deprecated
    public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = -1L;

    /**
     * The default value for the {@code timeBetweenEvictionRuns} configuration attribute.
     *
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @since 2.12.0
     */
    public static final Duration DEFAULT_DURATION_BETWEEN_EVICTION_RUNS = Duration.ofMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);

    /**
     * The default value for the {@code timeBetweenEvictionRuns} configuration attribute.
     *
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @deprecated Use {@link #DEFAULT_DURATION_BETWEEN_EVICTION_RUNS}.
     */
    @Deprecated
    public static final Duration DEFAULT_TIME_BETWEEN_EVICTION_RUNS = Duration.ofMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);

    /**
     * The default value for the {@code blockWhenExhausted} configuration attribute: {@value}.
     *
     * @see GenericObjectPool#getBlockWhenExhausted()
     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
     */
    public static final boolean DEFAULT_BLOCK_WHEN_EXHAUSTED = true;

    /**
     * The default value for enabling JMX for pools created with a configuration instance: {@value}.
     */
    public static final boolean DEFAULT_JMX_ENABLE = true;

    /**
     * The default value for the prefix used to name JMX enabled pools created with a configuration instance: {@value}.
     *
     * @see GenericObjectPool#getJmxName()
     * @see GenericKeyedObjectPool#getJmxName()
     */
    public static final String DEFAULT_JMX_NAME_PREFIX = "pool";

    /**
     * The default value for the base name to use to name JMX enabled pools created with a configuration instance. The default is {@code null} which means the
     * pool will provide the base name to use.
     *
     * @see GenericObjectPool#getJmxName()
     * @see GenericKeyedObjectPool#getJmxName()
     */
    public static final String DEFAULT_JMX_NAME_BASE = null;

    /**
     * The default value for the {@code evictionPolicyClassName} configuration attribute.
     *
     * @see GenericObjectPool#getEvictionPolicyClassName()
     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
     */
    public static final String DEFAULT_EVICTION_POLICY_CLASS_NAME = DefaultEvictionPolicy.class.getName();

    private boolean lifo = DEFAULT_LIFO;

    private boolean fairness = DEFAULT_FAIRNESS;

    private Duration maxWaitDuration = DEFAULT_MAX_WAIT;

    private Duration minEvictableIdleDuration = DEFAULT_MIN_EVICTABLE_IDLE_TIME;

    private Duration evictorShutdownTimeoutDuration = DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT;

    private Duration softMinEvictableIdleDuration = DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME;

    private int numTestsPerEvictionRun = DEFAULT_NUM_TESTS_PER_EVICTION_RUN;

    private EvictionPolicy<T> evictionPolicy; // Only 2.6.0 applications set this

    private String evictionPolicyClassName = DEFAULT_EVICTION_POLICY_CLASS_NAME;

    private boolean testOnCreate = DEFAULT_TEST_ON_CREATE;

    private boolean testOnBorrow = DEFAULT_TEST_ON_BORROW;

    private boolean testOnReturn = DEFAULT_TEST_ON_RETURN;

    private boolean testWhileIdle = DEFAULT_TEST_WHILE_IDLE;

    private Duration durationBetweenEvictionRuns = DEFAULT_DURATION_BETWEEN_EVICTION_RUNS;

    private boolean blockWhenExhausted = DEFAULT_BLOCK_WHEN_EXHAUSTED;

    private boolean jmxEnabled = DEFAULT_JMX_ENABLE;

    // TODO Consider changing this to a single property for 3.x
    private String jmxNamePrefix = DEFAULT_JMX_NAME_PREFIX;

    private String jmxNameBase = DEFAULT_JMX_NAME_BASE;

    /**
     * Gets the value for the {@code blockWhenExhausted} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code blockWhenExhausted} for this configuration instance
     * @see GenericObjectPool#getBlockWhenExhausted()
     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
     */
    public boolean getBlockWhenExhausted() {
        return blockWhenExhausted;
    }

    /**
     * Gets the value for the {@code timeBetweenEvictionRuns} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code timeBetweenEvictionRuns} for this configuration instance
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @since 2.11.0
     */
    public Duration getDurationBetweenEvictionRuns() {
        return durationBetweenEvictionRuns;
    }

    /**
     * Gets the value for the {@code evictionPolicyClass} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code evictionPolicyClass} for this configuration instance
     * @see GenericObjectPool#getEvictionPolicy()
     * @see GenericKeyedObjectPool#getEvictionPolicy()
     * @since 2.6.0
     */
    public EvictionPolicy<T> getEvictionPolicy() {
        return evictionPolicy;
    }

    /**
     * Gets the value for the {@code evictionPolicyClassName} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code evictionPolicyClassName} for this configuration instance
     * @see GenericObjectPool#getEvictionPolicyClassName()
     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
     */
    public String getEvictionPolicyClassName() {
        return evictionPolicyClassName;
    }

    /**
     * Gets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @since 2.10.0
     * @deprecated Use {@link #getEvictorShutdownTimeoutDuration()}.
     */
    @Deprecated
    public Duration getEvictorShutdownTimeout() {
        return evictorShutdownTimeoutDuration;
    }

    /**
     * Gets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @since 2.11.0
     */
    public Duration getEvictorShutdownTimeoutDuration() {
        return evictorShutdownTimeoutDuration;
    }

    /**
     * Gets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @deprecated Use {@link #getEvictorShutdownTimeout()}.
     */
    @Deprecated
    public long getEvictorShutdownTimeoutMillis() {
        return evictorShutdownTimeoutDuration.toMillis();
    }

    /**
     * Gets the value for the {@code fairness} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code fairness} for this configuration instance
     * @see GenericObjectPool#getFairness()
     * @see GenericKeyedObjectPool#getFairness()
     */
    public boolean getFairness() {
        return fairness;
    }

    /**
     * Gets the value of the flag that determines if JMX will be enabled for pools created with this configuration instance.
     *
     * @return The current setting of {@code jmxEnabled} for this configuration instance
     */
    public boolean getJmxEnabled() {
        return jmxEnabled;
    }

    /**
     * Gets the value of the JMX name base that will be used as part of the name assigned to JMX enabled pools created with this configuration instance. A value
     * of {@code null} means that the pool will define the JMX name base.
     *
     * @return The current setting of {@code jmxNameBase} for this configuration instance
     */
    public String getJmxNameBase() {
        return jmxNameBase;
    }

    /**
     * Gets the value of the JMX name prefix that will be used as part of the name assigned to JMX enabled pools created with this configuration instance.
     *
     * @return The current setting of {@code jmxNamePrefix} for this configuration instance
     */
    public String getJmxNamePrefix() {
        return jmxNamePrefix;
    }

    /**
     * Gets the value for the {@code lifo} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code lifo} for this configuration instance
     * @see GenericObjectPool#getLifo()
     * @see GenericKeyedObjectPool#getLifo()
     */
    public boolean getLifo() {
        return lifo;
    }

    /**
     * Gets the value for the {@code maxWait} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code maxWait} for this configuration instance
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @since 2.11.0
     */
    public Duration getMaxWaitDuration() {
        return maxWaitDuration;
    }

    /**
     * Gets the value for the {@code maxWait} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code maxWait} for this configuration instance
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @deprecated Use {@link #getMaxWaitDuration()}.
     */
    @Deprecated
    public long getMaxWaitMillis() {
        return maxWaitDuration.toMillis();
    }

    /**
     * Gets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.11.0
     */
    public Duration getMinEvictableIdleDuration() {
        return minEvictableIdleDuration;
    }

    /**
     * Gets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #getMinEvictableIdleDuration()}.
     */
    @Deprecated
    public Duration getMinEvictableIdleTime() {
        return minEvictableIdleDuration;
    }

    /**
     * Gets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @deprecated Use {@link #getMinEvictableIdleTime()}.
     */
    @Deprecated
    public long getMinEvictableIdleTimeMillis() {
        return minEvictableIdleDuration.toMillis();
    }

    /**
     * Gets the value for the {@code numTestsPerEvictionRun} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code numTestsPerEvictionRun} for this configuration instance
     * @see GenericObjectPool#getNumTestsPerEvictionRun()
     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
     */
    public int getNumTestsPerEvictionRun() {
        return numTestsPerEvictionRun;
    }

    /**
     * Gets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.11.0
     */
    public Duration getSoftMinEvictableIdleDuration() {
        return softMinEvictableIdleDuration;
    }

    /**
     * Gets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #getSoftMinEvictableIdleDuration()}.
     */
    @Deprecated
    public Duration getSoftMinEvictableIdleTime() {
        return softMinEvictableIdleDuration;
    }

    /**
     * Gets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @deprecated Use {@link #getSoftMinEvictableIdleDuration()}.
     */
    @Deprecated
    public long getSoftMinEvictableIdleTimeMillis() {
        return softMinEvictableIdleDuration.toMillis();
    }

    /**
     * Gets the value for the {@code testOnBorrow} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code testOnBorrow} for this configuration instance
     * @see GenericObjectPool#getTestOnBorrow()
     * @see GenericKeyedObjectPool#getTestOnBorrow()
     */
    public boolean getTestOnBorrow() {
        return testOnBorrow;
    }

    /**
     * Gets the value for the {@code testOnCreate} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code testOnCreate} for this configuration instance
     * @see GenericObjectPool#getTestOnCreate()
     * @see GenericKeyedObjectPool#getTestOnCreate()
     * @since 2.2
     */
    public boolean getTestOnCreate() {
        return testOnCreate;
    }

    /**
     * Gets the value for the {@code testOnReturn} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code testOnReturn} for this configuration instance
     * @see GenericObjectPool#getTestOnReturn()
     * @see GenericKeyedObjectPool#getTestOnReturn()
     */
    public boolean getTestOnReturn() {
        return testOnReturn;
    }

    /**
     * Gets the value for the {@code testWhileIdle} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code testWhileIdle} for this configuration instance
     * @see GenericObjectPool#getTestWhileIdle()
     * @see GenericKeyedObjectPool#getTestWhileIdle()
     */
    public boolean getTestWhileIdle() {
        return testWhileIdle;
    }

    /**
     * Gets the value for the {@code timeBetweenEvictionRuns} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code timeBetweenEvictionRuns} for this configuration instance
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @since 2.10.0
     * @deprecated Use {@link #getDurationBetweenEvictionRuns()}.
     */
    @Deprecated
    public Duration getTimeBetweenEvictionRuns() {
        return durationBetweenEvictionRuns;
    }

    /**
     * Gets the value for the {@code timeBetweenEvictionRuns} configuration attribute for pools created with this configuration instance.
     *
     * @return The current setting of {@code timeBetweenEvictionRuns} for this configuration instance
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @deprecated Use {@link #getDurationBetweenEvictionRuns()}.
     */
    @Deprecated
    public long getTimeBetweenEvictionRunsMillis() {
        return durationBetweenEvictionRuns.toMillis();
    }

    /**
     * Sets the value for the {@code blockWhenExhausted} configuration attribute for pools created with this configuration instance.
     *
     * @param blockWhenExhausted The new setting of {@code blockWhenExhausted} for this configuration instance
     * @see GenericObjectPool#getBlockWhenExhausted()
     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
     */
    public void setBlockWhenExhausted(final boolean blockWhenExhausted) {
        this.blockWhenExhausted = blockWhenExhausted;
    }

    /**
     * Sets the value for the {@code evictionPolicyClass} configuration attribute for pools created with this configuration instance.
     *
     * @param evictionPolicy The new setting of {@code evictionPolicyClass} for this configuration instance
     * @see GenericObjectPool#getEvictionPolicy()
     * @see GenericKeyedObjectPool#getEvictionPolicy()
     * @since 2.6.0
     */
    public void setEvictionPolicy(final EvictionPolicy<T> evictionPolicy) {
        this.evictionPolicy = evictionPolicy;
    }

    /**
     * Sets the value for the {@code evictionPolicyClassName} configuration attribute for pools created with this configuration instance.
     *
     * @param evictionPolicyClassName The new setting of {@code evictionPolicyClassName} for this configuration instance
     * @see GenericObjectPool#getEvictionPolicyClassName()
     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
     */
    public void setEvictionPolicyClassName(final String evictionPolicyClassName) {
        this.evictionPolicyClassName = evictionPolicyClassName;
    }

    /**
     * Sets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @param evictorShutdownTimeoutDuration The new setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @since 2.11.0
     */
    public void setEvictorShutdownTimeout(final Duration evictorShutdownTimeoutDuration) {
        this.evictorShutdownTimeoutDuration = PoolImplUtils.nonNull(evictorShutdownTimeoutDuration, DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT);
    }

    /**
     * Sets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @param evictorShutdownTimeout The new setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @since 2.10.0
     * @deprecated Use {@link #setEvictorShutdownTimeout(Duration)}.
     */
    @Deprecated
    public void setEvictorShutdownTimeoutMillis(final Duration evictorShutdownTimeout) {
        setEvictorShutdownTimeout(evictorShutdownTimeout);
    }

    /**
     * Sets the value for the {@code evictorShutdownTimeout} configuration attribute for pools created with this configuration instance.
     *
     * @param evictorShutdownTimeoutMillis The new setting of {@code evictorShutdownTimeout} for this configuration instance
     * @see GenericObjectPool#getEvictorShutdownTimeoutDuration()
     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutDuration()
     * @deprecated Use {@link #setEvictorShutdownTimeout(Duration)}.
     */
    @Deprecated
    public void setEvictorShutdownTimeoutMillis(final long evictorShutdownTimeoutMillis) {
        setEvictorShutdownTimeout(Duration.ofMillis(evictorShutdownTimeoutMillis));
    }

    /**
     * Sets the value for the {@code fairness} configuration attribute for pools created with this configuration instance.
     *
     * @param fairness The new setting of {@code fairness} for this configuration instance
     * @see GenericObjectPool#getFairness()
     * @see GenericKeyedObjectPool#getFairness()
     */
    public void setFairness(final boolean fairness) {
        this.fairness = fairness;
    }

    /**
     * Sets the value of the flag that determines if JMX will be enabled for pools created with this configuration instance.
     *
     * @param jmxEnabled The new setting of {@code jmxEnabled} for this configuration instance
     */
    public void setJmxEnabled(final boolean jmxEnabled) {
        this.jmxEnabled = jmxEnabled;
    }

    /**
     * Sets the value of the JMX name base that will be used as part of the name assigned to JMX enabled pools created with this configuration instance. A value
     * of {@code null} means that the pool will define the JMX name base.
     *
     * @param jmxNameBase The new setting of {@code jmxNameBase} for this configuration instance
     */
    public void setJmxNameBase(final String jmxNameBase) {
        this.jmxNameBase = jmxNameBase;
    }

    /**
     * Sets the value of the JMX name prefix that will be used as part of the name assigned to JMX enabled pools created with this configuration instance.
     *
     * @param jmxNamePrefix The new setting of {@code jmxNamePrefix} for this configuration instance
     */
    public void setJmxNamePrefix(final String jmxNamePrefix) {
        this.jmxNamePrefix = jmxNamePrefix;
    }

    /**
     * Sets the value for the {@code lifo} configuration attribute for pools created with this configuration instance.
     *
     * @param lifo The new setting of {@code lifo} for this configuration instance
     * @see GenericObjectPool#getLifo()
     * @see GenericKeyedObjectPool#getLifo()
     */
    public void setLifo(final boolean lifo) {
        this.lifo = lifo;
    }

    /**
     * Sets the value for the {@code maxWait} configuration attribute for pools created with this configuration instance.
     *
     * @param maxWaitDuration The new setting of {@code maxWaitDuration} for this configuration instance
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @since 2.11.0
     */
    public void setMaxWait(final Duration maxWaitDuration) {
        this.maxWaitDuration = PoolImplUtils.nonNull(maxWaitDuration, DEFAULT_MAX_WAIT);
    }

    /**
     * Sets the value for the {@code maxWait} configuration attribute for pools created with this configuration instance.
     *
     * @param maxWaitMillis The new setting of {@code maxWaitMillis} for this configuration instance
     * @see GenericObjectPool#getMaxWaitDuration()
     * @see GenericKeyedObjectPool#getMaxWaitDuration()
     * @deprecated Use {@link #setMaxWait(Duration)}.
     */
    @Deprecated
    public void setMaxWaitMillis(final long maxWaitMillis) {
        setMaxWait(Duration.ofMillis(maxWaitMillis));
    }

    /**
     * Sets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param minEvictableIdleTime The new setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.12.0
     */
    public void setMinEvictableIdleDuration(final Duration minEvictableIdleTime) {
        this.minEvictableIdleDuration = PoolImplUtils.nonNull(minEvictableIdleTime, DEFAULT_MIN_EVICTABLE_IDLE_TIME);
    }

    /**
     * Sets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param minEvictableIdleTime The new setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #setMinEvictableIdleDuration(Duration)}.
     */
    @Deprecated
    public void setMinEvictableIdleTime(final Duration minEvictableIdleTime) {
        this.minEvictableIdleDuration = PoolImplUtils.nonNull(minEvictableIdleTime, DEFAULT_MIN_EVICTABLE_IDLE_TIME);
    }

    /**
     * Sets the value for the {@code minEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param minEvictableIdleTimeMillis The new setting of {@code minEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getMinEvictableIdleDuration()
     * @deprecated Use {@link #setMinEvictableIdleDuration(Duration)}.
     */
    @Deprecated
    public void setMinEvictableIdleTimeMillis(final long minEvictableIdleTimeMillis) {
        this.minEvictableIdleDuration = Duration.ofMillis(minEvictableIdleTimeMillis);
    }

    /**
     * Sets the value for the {@code numTestsPerEvictionRun} configuration attribute for pools created with this configuration instance.
     *
     * @param numTestsPerEvictionRun The new setting of {@code numTestsPerEvictionRun} for this configuration instance
     * @see GenericObjectPool#getNumTestsPerEvictionRun()
     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
     */
    public void setNumTestsPerEvictionRun(final int numTestsPerEvictionRun) {
        this.numTestsPerEvictionRun = numTestsPerEvictionRun;
    }

    /**
     * Sets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param softMinEvictableIdleTime The new setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.12.0
     */
    public void setSoftMinEvictableIdleDuration(final Duration softMinEvictableIdleTime) {
        this.softMinEvictableIdleDuration = PoolImplUtils.nonNull(softMinEvictableIdleTime, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME);
    }

    /**
     * Sets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param softMinEvictableIdleTime The new setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @since 2.10.0
     * @deprecated Use {@link #setSoftMinEvictableIdleDuration(Duration)}.
     */
    @Deprecated
    public void setSoftMinEvictableIdleTime(final Duration softMinEvictableIdleTime) {
        this.softMinEvictableIdleDuration = PoolImplUtils.nonNull(softMinEvictableIdleTime, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME);
    }

    /**
     * Sets the value for the {@code softMinEvictableIdleTime} configuration attribute for pools created with this configuration instance.
     *
     * @param softMinEvictableIdleTimeMillis The new setting of {@code softMinEvictableIdleTime} for this configuration instance
     * @see GenericObjectPool#getSoftMinEvictableIdleDuration()
     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleDuration()
     * @deprecated Use {@link #setSoftMinEvictableIdleDuration(Duration)}.
     */
    @Deprecated
    public void setSoftMinEvictableIdleTimeMillis(final long softMinEvictableIdleTimeMillis) {
        setSoftMinEvictableIdleTime(Duration.ofMillis(softMinEvictableIdleTimeMillis));
    }

    /**
     * Sets the value for the {@code testOnBorrow} configuration attribute for pools created with this configuration instance.
     *
     * @param testOnBorrow The new setting of {@code testOnBorrow} for this configuration instance
     * @see GenericObjectPool#getTestOnBorrow()
     * @see GenericKeyedObjectPool#getTestOnBorrow()
     */
    public void setTestOnBorrow(final boolean testOnBorrow) {
        this.testOnBorrow = testOnBorrow;
    }

    /**
     * Sets the value for the {@code testOnCreate} configuration attribute for pools created with this configuration instance.
     *
     * @param testOnCreate The new setting of {@code testOnCreate} for this configuration instance
     * @see GenericObjectPool#getTestOnCreate()
     * @see GenericKeyedObjectPool#getTestOnCreate()
     * @since 2.2
     */
    public void setTestOnCreate(final boolean testOnCreate) {
        this.testOnCreate = testOnCreate;
    }

    /**
     * Sets the value for the {@code testOnReturn} configuration attribute for pools created with this configuration instance.
     *
     * @param testOnReturn The new setting of {@code testOnReturn} for this configuration instance
     * @see GenericObjectPool#getTestOnReturn()
     * @see GenericKeyedObjectPool#getTestOnReturn()
     */
    public void setTestOnReturn(final boolean testOnReturn) {
        this.testOnReturn = testOnReturn;
    }

    /**
     * Sets the value for the {@code testWhileIdle} configuration attribute for pools created with this configuration instance.
     *
     * @param testWhileIdle The new setting of {@code testWhileIdle} for this configuration instance
     * @see GenericObjectPool#getTestWhileIdle()
     * @see GenericKeyedObjectPool#getTestWhileIdle()
     */
    public void setTestWhileIdle(final boolean testWhileIdle) {
        this.testWhileIdle = testWhileIdle;
    }

    /**
     * Sets the value for the {@code timeBetweenEvictionRuns} configuration attribute for pools created with this configuration instance.
     *
     * @param timeBetweenEvictionRuns The new setting of {@code timeBetweenEvictionRuns} for this configuration instance
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @since 2.10.0
     */
    public void setTimeBetweenEvictionRuns(final Duration timeBetweenEvictionRuns) {
        this.durationBetweenEvictionRuns = PoolImplUtils.nonNull(timeBetweenEvictionRuns, DEFAULT_DURATION_BETWEEN_EVICTION_RUNS);
    }

    /**
     * Sets the value for the {@code timeBetweenEvictionRuns} configuration attribute for pools created with this configuration instance.
     *
     * @param timeBetweenEvictionRunsMillis The new setting of {@code timeBetweenEvictionRuns} for this configuration instance
     * @see GenericObjectPool#getDurationBetweenEvictionRuns()
     * @see GenericKeyedObjectPool#getDurationBetweenEvictionRuns()
     * @deprecated Use {@link #setTimeBetweenEvictionRuns(Duration)}.
     */
    @Deprecated
    public void setTimeBetweenEvictionRunsMillis(final long timeBetweenEvictionRunsMillis) {
        setTimeBetweenEvictionRuns(Duration.ofMillis(timeBetweenEvictionRunsMillis));
    }

    @Override
    protected void toStringAppendFields(final StringBuilder builder) {
        builder.append("lifo=");
        builder.append(lifo);
        builder.append(", fairness=");
        builder.append(fairness);
        builder.append(", maxWaitDuration=");
        builder.append(maxWaitDuration);
        builder.append(", minEvictableIdleTime=");
        builder.append(minEvictableIdleDuration);
        builder.append(", softMinEvictableIdleTime=");
        builder.append(softMinEvictableIdleDuration);
        builder.append(", numTestsPerEvictionRun=");
        builder.append(numTestsPerEvictionRun);
        builder.append(", evictionPolicyClassName=");
        builder.append(evictionPolicyClassName);
        builder.append(", testOnCreate=");
        builder.append(testOnCreate);
        builder.append(", testOnBorrow=");
        builder.append(testOnBorrow);
        builder.append(", testOnReturn=");
        builder.append(testOnReturn);
        builder.append(", testWhileIdle=");
        builder.append(testWhileIdle);
        builder.append(", timeBetweenEvictionRuns=");
        builder.append(durationBetweenEvictionRuns);
        builder.append(", blockWhenExhausted=");
        builder.append(blockWhenExhausted);
        builder.append(", jmxEnabled=");
        builder.append(jmxEnabled);
        builder.append(", jmxNamePrefix=");
        builder.append(jmxNamePrefix);
        builder.append(", jmxNameBase=");
        builder.append(jmxNameBase);
    }
}