001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.pool2.impl;
018
019import org.apache.commons.pool2.BaseObject;
020
021/**
022 * Provides the implementation for the common attributes shared by the
023 * sub-classes. New instances of this class will be created using the defaults
024 * defined by the public constants.
025 * <p>
026 * This class is not thread-safe.
027 * </p>
028 *
029 * @param <T> Type of element pooled.
030 * @since 2.0
031 */
032public abstract class BaseObjectPoolConfig<T> extends BaseObject implements Cloneable {
033
034    /**
035     * The default value for the {@code lifo} configuration attribute.
036     * @see GenericObjectPool#getLifo()
037     * @see GenericKeyedObjectPool#getLifo()
038     */
039    public static final boolean DEFAULT_LIFO = true;
040
041    /**
042     * The default value for the {@code fairness} configuration attribute.
043     * @see GenericObjectPool#getFairness()
044     * @see GenericKeyedObjectPool#getFairness()
045     */
046    public static final boolean DEFAULT_FAIRNESS = false;
047
048    /**
049     * The default value for the {@code maxWait} configuration attribute.
050     * @see GenericObjectPool#getMaxWaitMillis()
051     * @see GenericKeyedObjectPool#getMaxWaitMillis()
052     */
053    public static final long DEFAULT_MAX_WAIT_MILLIS = -1L;
054
055    /**
056     * The default value for the {@code minEvictableIdleTimeMillis}
057     * configuration attribute.
058     * @see GenericObjectPool#getMinEvictableIdleTimeMillis()
059     * @see GenericKeyedObjectPool#getMinEvictableIdleTimeMillis()
060     */
061    public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS =
062            1000L * 60L * 30L;
063
064    /**
065     * The default value for the {@code softMinEvictableIdleTimeMillis}
066     * configuration attribute.
067     * @see GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
068     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleTimeMillis()
069     */
070    public static final long DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS = -1;
071
072    /**
073     * The default value for {@code evictorShutdownTimeoutMillis} configuration
074     * attribute.
075     * @see GenericObjectPool#getEvictorShutdownTimeoutMillis()
076     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutMillis()
077     */
078    public static final long DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS =
079            10L * 1000L;
080
081    /**
082     * The default value for the {@code numTestsPerEvictionRun} configuration
083     * attribute.
084     * @see GenericObjectPool#getNumTestsPerEvictionRun()
085     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
086     */
087    public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = 3;
088
089    /**
090     * The default value for the {@code testOnCreate} configuration attribute.
091     * @see GenericObjectPool#getTestOnCreate()
092     * @see GenericKeyedObjectPool#getTestOnCreate()
093     *
094     * @since 2.2
095     */
096    public static final boolean DEFAULT_TEST_ON_CREATE = false;
097
098    /**
099     * The default value for the {@code testOnBorrow} configuration attribute.
100     * @see GenericObjectPool#getTestOnBorrow()
101     * @see GenericKeyedObjectPool#getTestOnBorrow()
102     */
103    public static final boolean DEFAULT_TEST_ON_BORROW = false;
104
105    /**
106     * The default value for the {@code testOnReturn} configuration attribute.
107     * @see GenericObjectPool#getTestOnReturn()
108     * @see GenericKeyedObjectPool#getTestOnReturn()
109     */
110    public static final boolean DEFAULT_TEST_ON_RETURN = false;
111
112    /**
113     * The default value for the {@code testWhileIdle} configuration attribute.
114     * @see GenericObjectPool#getTestWhileIdle()
115     * @see GenericKeyedObjectPool#getTestWhileIdle()
116     */
117    public static final boolean DEFAULT_TEST_WHILE_IDLE = false;
118
119    /**
120     * The default value for the {@code timeBetweenEvictionRunsMillis}
121     * configuration attribute.
122     * @see GenericObjectPool#getTimeBetweenEvictionRunsMillis()
123     * @see GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis()
124     */
125    public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = -1L;
126
127    /**
128     * The default value for the {@code blockWhenExhausted} configuration
129     * attribute.
130     * @see GenericObjectPool#getBlockWhenExhausted()
131     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
132     */
133    public static final boolean DEFAULT_BLOCK_WHEN_EXHAUSTED = true;
134
135    /**
136     * The default value for enabling JMX for pools created with a configuration
137     * instance.
138     */
139    public static final boolean DEFAULT_JMX_ENABLE = true;
140
141    /**
142     * The default value for the prefix used to name JMX enabled pools created
143     * with a configuration instance.
144     * @see GenericObjectPool#getJmxName()
145     * @see GenericKeyedObjectPool#getJmxName()
146     */
147    public static final String DEFAULT_JMX_NAME_PREFIX = "pool";
148
149    /**
150     * The default value for the base name to use to name JMX enabled pools
151     * created with a configuration instance. The default is {@code null}
152     * which means the pool will provide the base name to use.
153     * @see GenericObjectPool#getJmxName()
154     * @see GenericKeyedObjectPool#getJmxName()
155     */
156    public static final String DEFAULT_JMX_NAME_BASE = null;
157
158    /**
159     * The default value for the {@code evictionPolicyClassName} configuration
160     * attribute.
161     * @see GenericObjectPool#getEvictionPolicyClassName()
162     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
163     */
164    public static final String DEFAULT_EVICTION_POLICY_CLASS_NAME = DefaultEvictionPolicy.class.getName();
165
166    private boolean lifo = DEFAULT_LIFO;
167
168    private boolean fairness = DEFAULT_FAIRNESS;
169
170    private long maxWaitMillis = DEFAULT_MAX_WAIT_MILLIS;
171
172    private long minEvictableIdleTimeMillis =
173            DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
174
175    private long evictorShutdownTimeoutMillis =
176            DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS;
177
178    private long softMinEvictableIdleTimeMillis =
179            DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
180
181    private int numTestsPerEvictionRun =
182            DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
183
184    private EvictionPolicy<T> evictionPolicy = null; // Only 2.6.0 applications set this
185
186    private String evictionPolicyClassName = DEFAULT_EVICTION_POLICY_CLASS_NAME;
187
188    private boolean testOnCreate = DEFAULT_TEST_ON_CREATE;
189
190    private boolean testOnBorrow = DEFAULT_TEST_ON_BORROW;
191
192    private boolean testOnReturn = DEFAULT_TEST_ON_RETURN;
193
194    private boolean testWhileIdle = DEFAULT_TEST_WHILE_IDLE;
195
196    private long timeBetweenEvictionRunsMillis =
197            DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
198
199    private boolean blockWhenExhausted = DEFAULT_BLOCK_WHEN_EXHAUSTED;
200
201    private boolean jmxEnabled = DEFAULT_JMX_ENABLE;
202
203    // TODO Consider changing this to a single property for 3.x
204    private String jmxNamePrefix = DEFAULT_JMX_NAME_PREFIX;
205
206    private String jmxNameBase = DEFAULT_JMX_NAME_BASE;
207
208
209    /**
210     * Get the value for the {@code lifo} configuration attribute for pools
211     * created with this configuration instance.
212     *
213     * @return  The current setting of {@code lifo} for this configuration
214     *          instance
215     *
216     * @see GenericObjectPool#getLifo()
217     * @see GenericKeyedObjectPool#getLifo()
218     */
219    public boolean getLifo() {
220        return lifo;
221    }
222
223    /**
224     * Get the value for the {@code fairness} configuration attribute for pools
225     * created with this configuration instance.
226     *
227     * @return  The current setting of {@code fairness} for this configuration
228     *          instance
229     *
230     * @see GenericObjectPool#getFairness()
231     * @see GenericKeyedObjectPool#getFairness()
232     */
233    public boolean getFairness() {
234        return fairness;
235    }
236
237    /**
238     * Set the value for the {@code lifo} configuration attribute for pools
239     * created with this configuration instance.
240     *
241     * @param lifo The new setting of {@code lifo}
242     *        for this configuration instance
243     *
244     * @see GenericObjectPool#getLifo()
245     * @see GenericKeyedObjectPool#getLifo()
246     */
247    public void setLifo(final boolean lifo) {
248        this.lifo = lifo;
249    }
250
251    /**
252     * Set the value for the {@code fairness} configuration attribute for pools
253     * created with this configuration instance.
254     *
255     * @param fairness The new setting of {@code fairness}
256     *        for this configuration instance
257     *
258     * @see GenericObjectPool#getFairness()
259     * @see GenericKeyedObjectPool#getFairness()
260     */
261    public void setFairness(final boolean fairness) {
262        this.fairness = fairness;
263    }
264
265    /**
266     * Get the value for the {@code maxWait} configuration attribute for pools
267     * created with this configuration instance.
268     *
269     * @return  The current setting of {@code maxWait} for this
270     *          configuration instance
271     *
272     * @see GenericObjectPool#getMaxWaitMillis()
273     * @see GenericKeyedObjectPool#getMaxWaitMillis()
274     */
275    public long getMaxWaitMillis() {
276        return maxWaitMillis;
277    }
278
279    /**
280     * Set the value for the {@code maxWait} configuration attribute for pools
281     * created with this configuration instance.
282     *
283     * @param maxWaitMillis The new setting of {@code maxWaitMillis}
284     *        for this configuration instance
285     *
286     * @see GenericObjectPool#getMaxWaitMillis()
287     * @see GenericKeyedObjectPool#getMaxWaitMillis()
288     */
289    public void setMaxWaitMillis(final long maxWaitMillis) {
290        this.maxWaitMillis = maxWaitMillis;
291    }
292
293    /**
294     * Get the value for the {@code minEvictableIdleTimeMillis} configuration
295     * attribute for pools created with this configuration instance.
296     *
297     * @return  The current setting of {@code minEvictableIdleTimeMillis} for
298     *          this configuration instance
299     *
300     * @see GenericObjectPool#getMinEvictableIdleTimeMillis()
301     * @see GenericKeyedObjectPool#getMinEvictableIdleTimeMillis()
302     */
303    public long getMinEvictableIdleTimeMillis() {
304        return minEvictableIdleTimeMillis;
305    }
306
307    /**
308     * Set the value for the {@code minEvictableIdleTimeMillis} configuration
309     * attribute for pools created with this configuration instance.
310     *
311     * @param minEvictableIdleTimeMillis The new setting of
312     *        {@code minEvictableIdleTimeMillis} for this configuration instance
313     *
314     * @see GenericObjectPool#getMinEvictableIdleTimeMillis()
315     * @see GenericKeyedObjectPool#getMinEvictableIdleTimeMillis()
316     */
317    public void setMinEvictableIdleTimeMillis(final long minEvictableIdleTimeMillis) {
318        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
319    }
320
321    /**
322     * Get the value for the {@code softMinEvictableIdleTimeMillis}
323     * configuration attribute for pools created with this configuration
324     * instance.
325     *
326     * @return  The current setting of {@code softMinEvictableIdleTimeMillis}
327     *          for this configuration instance
328     *
329     * @see GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
330     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleTimeMillis()
331     */
332    public long getSoftMinEvictableIdleTimeMillis() {
333        return softMinEvictableIdleTimeMillis;
334    }
335
336    /**
337     * Set the value for the {@code softMinEvictableIdleTimeMillis}
338     * configuration attribute for pools created with this configuration
339     * instance.
340     *
341     * @param softMinEvictableIdleTimeMillis The new setting of
342     *        {@code softMinEvictableIdleTimeMillis} for this configuration
343     *        instance
344     *
345     * @see GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
346     * @see GenericKeyedObjectPool#getSoftMinEvictableIdleTimeMillis()
347     */
348    public void setSoftMinEvictableIdleTimeMillis(
349            final long softMinEvictableIdleTimeMillis) {
350        this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
351    }
352
353    /**
354     * Get the value for the {@code numTestsPerEvictionRun} configuration
355     * attribute for pools created with this configuration instance.
356     *
357     * @return  The current setting of {@code numTestsPerEvictionRun} for this
358     *          configuration instance
359     *
360     * @see GenericObjectPool#getNumTestsPerEvictionRun()
361     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
362     */
363    public int getNumTestsPerEvictionRun() {
364        return numTestsPerEvictionRun;
365    }
366
367    /**
368     * Set the value for the {@code numTestsPerEvictionRun} configuration
369     * attribute for pools created with this configuration instance.
370     *
371     * @param numTestsPerEvictionRun The new setting of
372     *        {@code numTestsPerEvictionRun} for this configuration instance
373     *
374     * @see GenericObjectPool#getNumTestsPerEvictionRun()
375     * @see GenericKeyedObjectPool#getNumTestsPerEvictionRun()
376     */
377    public void setNumTestsPerEvictionRun(final int numTestsPerEvictionRun) {
378        this.numTestsPerEvictionRun = numTestsPerEvictionRun;
379    }
380
381    /**
382     * Get the value for the {@code evictorShutdownTimeoutMillis} configuration
383     * attribute for pools created with this configuration instance.
384     *
385     * @return  The current setting of {@code evictorShutdownTimeoutMillis} for
386     *          this configuration instance
387     *
388     * @see GenericObjectPool#getEvictorShutdownTimeoutMillis()
389     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutMillis()
390     */
391    public long getEvictorShutdownTimeoutMillis() {
392        return evictorShutdownTimeoutMillis;
393    }
394
395    /**
396     * Set the value for the {@code evictorShutdownTimeoutMillis} configuration
397     * attribute for pools created with this configuration instance.
398     *
399     * @param evictorShutdownTimeoutMillis The new setting of
400     *        {@code evictorShutdownTimeoutMillis} for this configuration
401     *        instance
402     *
403     * @see GenericObjectPool#getEvictorShutdownTimeoutMillis()
404     * @see GenericKeyedObjectPool#getEvictorShutdownTimeoutMillis()
405     */
406    public void setEvictorShutdownTimeoutMillis(
407            final long evictorShutdownTimeoutMillis) {
408        this.evictorShutdownTimeoutMillis = evictorShutdownTimeoutMillis;
409    }
410
411    /**
412     * Get the value for the {@code testOnCreate} configuration attribute for
413     * pools created with this configuration instance.
414     *
415     * @return  The current setting of {@code testOnCreate} for this
416     *          configuration instance
417     *
418     * @see GenericObjectPool#getTestOnCreate()
419     * @see GenericKeyedObjectPool#getTestOnCreate()
420     *
421     * @since 2.2
422     */
423    public boolean getTestOnCreate() {
424        return testOnCreate;
425    }
426
427    /**
428     * Set the value for the {@code testOnCreate} configuration attribute for
429     * pools created with this configuration instance.
430     *
431     * @param testOnCreate The new setting of {@code testOnCreate}
432     *        for this configuration instance
433     *
434     * @see GenericObjectPool#getTestOnCreate()
435     * @see GenericKeyedObjectPool#getTestOnCreate()
436     *
437     * @since 2.2
438     */
439    public void setTestOnCreate(final boolean testOnCreate) {
440        this.testOnCreate = testOnCreate;
441    }
442
443    /**
444     * Get the value for the {@code testOnBorrow} configuration attribute for
445     * pools created with this configuration instance.
446     *
447     * @return  The current setting of {@code testOnBorrow} for this
448     *          configuration instance
449     *
450     * @see GenericObjectPool#getTestOnBorrow()
451     * @see GenericKeyedObjectPool#getTestOnBorrow()
452     */
453    public boolean getTestOnBorrow() {
454        return testOnBorrow;
455    }
456
457    /**
458     * Set the value for the {@code testOnBorrow} configuration attribute for
459     * pools created with this configuration instance.
460     *
461     * @param testOnBorrow The new setting of {@code testOnBorrow}
462     *        for this configuration instance
463     *
464     * @see GenericObjectPool#getTestOnBorrow()
465     * @see GenericKeyedObjectPool#getTestOnBorrow()
466     */
467    public void setTestOnBorrow(final boolean testOnBorrow) {
468        this.testOnBorrow = testOnBorrow;
469    }
470
471    /**
472     * Get the value for the {@code testOnReturn} configuration attribute for
473     * pools created with this configuration instance.
474     *
475     * @return  The current setting of {@code testOnReturn} for this
476     *          configuration instance
477     *
478     * @see GenericObjectPool#getTestOnReturn()
479     * @see GenericKeyedObjectPool#getTestOnReturn()
480     */
481    public boolean getTestOnReturn() {
482        return testOnReturn;
483    }
484
485    /**
486     * Set the value for the {@code testOnReturn} configuration attribute for
487     * pools created with this configuration instance.
488     *
489     * @param testOnReturn The new setting of {@code testOnReturn}
490     *        for this configuration instance
491     *
492     * @see GenericObjectPool#getTestOnReturn()
493     * @see GenericKeyedObjectPool#getTestOnReturn()
494     */
495    public void setTestOnReturn(final boolean testOnReturn) {
496        this.testOnReturn = testOnReturn;
497    }
498
499    /**
500     * Get the value for the {@code testWhileIdle} configuration attribute for
501     * pools created with this configuration instance.
502     *
503     * @return  The current setting of {@code testWhileIdle} for this
504     *          configuration instance
505     *
506     * @see GenericObjectPool#getTestWhileIdle()
507     * @see GenericKeyedObjectPool#getTestWhileIdle()
508     */
509    public boolean getTestWhileIdle() {
510        return testWhileIdle;
511    }
512
513    /**
514     * Set the value for the {@code testWhileIdle} configuration attribute for
515     * pools created with this configuration instance.
516     *
517     * @param testWhileIdle The new setting of {@code testWhileIdle}
518     *        for this configuration instance
519     *
520     * @see GenericObjectPool#getTestWhileIdle()
521     * @see GenericKeyedObjectPool#getTestWhileIdle()
522     */
523    public void setTestWhileIdle(final boolean testWhileIdle) {
524        this.testWhileIdle = testWhileIdle;
525    }
526
527    /**
528     * Get the value for the {@code timeBetweenEvictionRunsMillis} configuration
529     * attribute for pools created with this configuration instance.
530     *
531     * @return  The current setting of {@code timeBetweenEvictionRunsMillis} for
532     *          this configuration instance
533     *
534     * @see GenericObjectPool#getTimeBetweenEvictionRunsMillis()
535     * @see GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis()
536     */
537    public long getTimeBetweenEvictionRunsMillis() {
538        return timeBetweenEvictionRunsMillis;
539    }
540
541    /**
542     * Set the value for the {@code timeBetweenEvictionRunsMillis} configuration
543     * attribute for pools created with this configuration instance.
544     *
545     * @param timeBetweenEvictionRunsMillis The new setting of
546     *        {@code timeBetweenEvictionRunsMillis} for this configuration
547     *        instance
548     *
549     * @see GenericObjectPool#getTimeBetweenEvictionRunsMillis()
550     * @see GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis()
551     */
552    public void setTimeBetweenEvictionRunsMillis(
553            final long timeBetweenEvictionRunsMillis) {
554        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
555    }
556
557    /**
558     * Get the value for the {@code evictionPolicyClass} configuration
559     * attribute for pools created with this configuration instance.
560     *
561     * @return  The current setting of {@code evictionPolicyClass} for this
562     *          configuration instance
563     *
564     * @see GenericObjectPool#getEvictionPolicy()
565     * @see GenericKeyedObjectPool#getEvictionPolicy()
566     * @since 2.6.0
567     */
568    public EvictionPolicy<T> getEvictionPolicy() {
569        return evictionPolicy;
570    }
571
572    /**
573     * Get the value for the {@code evictionPolicyClassName} configuration
574     * attribute for pools created with this configuration instance.
575     *
576     * @return  The current setting of {@code evictionPolicyClassName} for this
577     *          configuration instance
578     *
579     * @see GenericObjectPool#getEvictionPolicyClassName()
580     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
581     */
582    public String getEvictionPolicyClassName() {
583        return evictionPolicyClassName;
584    }
585
586    /**
587     * Set the value for the {@code evictionPolicyClass} configuration
588     * attribute for pools created with this configuration instance.
589     *
590     * @param evictionPolicy The new setting of
591     *        {@code evictionPolicyClass} for this configuration instance
592     *
593     * @see GenericObjectPool#getEvictionPolicy()
594     * @see GenericKeyedObjectPool#getEvictionPolicy()
595     * @since 2.6.0
596     */
597    public void setEvictionPolicy(final EvictionPolicy<T> evictionPolicy) {
598        this.evictionPolicy = evictionPolicy;
599    }
600
601    /**
602     * Set the value for the {@code evictionPolicyClassName} configuration
603     * attribute for pools created with this configuration instance.
604     *
605     * @param evictionPolicyClassName The new setting of
606     *        {@code evictionPolicyClassName} for this configuration instance
607     *
608     * @see GenericObjectPool#getEvictionPolicyClassName()
609     * @see GenericKeyedObjectPool#getEvictionPolicyClassName()
610     */
611    public void setEvictionPolicyClassName(final String evictionPolicyClassName) {
612        this.evictionPolicyClassName = evictionPolicyClassName;
613    }
614
615    /**
616     * Get the value for the {@code blockWhenExhausted} configuration attribute
617     * for pools created with this configuration instance.
618     *
619     * @return  The current setting of {@code blockWhenExhausted} for this
620     *          configuration instance
621     *
622     * @see GenericObjectPool#getBlockWhenExhausted()
623     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
624     */
625    public boolean getBlockWhenExhausted() {
626        return blockWhenExhausted;
627    }
628
629    /**
630     * Set the value for the {@code blockWhenExhausted} configuration attribute
631     * for pools created with this configuration instance.
632     *
633     * @param blockWhenExhausted The new setting of {@code blockWhenExhausted}
634     *        for this configuration instance
635     *
636     * @see GenericObjectPool#getBlockWhenExhausted()
637     * @see GenericKeyedObjectPool#getBlockWhenExhausted()
638     */
639    public void setBlockWhenExhausted(final boolean blockWhenExhausted) {
640        this.blockWhenExhausted = blockWhenExhausted;
641    }
642
643    /**
644     * Gets the value of the flag that determines if JMX will be enabled for
645     * pools created with this configuration instance.
646     *
647     * @return  The current setting of {@code jmxEnabled} for this configuration
648     *          instance
649     */
650    public boolean getJmxEnabled() {
651        return jmxEnabled;
652    }
653
654    /**
655     * Sets the value of the flag that determines if JMX will be enabled for
656     * pools created with this configuration instance.
657     *
658     * @param jmxEnabled The new setting of {@code jmxEnabled}
659     *        for this configuration instance
660     */
661    public void setJmxEnabled(final boolean jmxEnabled) {
662        this.jmxEnabled = jmxEnabled;
663    }
664
665    /**
666     * Gets the value of the JMX name base that will be used as part of the
667     * name assigned to JMX enabled pools created with this configuration
668     * instance. A value of {@code null} means that the pool will define
669     * the JMX name base.
670     *
671     * @return  The current setting of {@code jmxNameBase} for this
672     *          configuration instance
673     */
674    public String getJmxNameBase() {
675        return jmxNameBase;
676    }
677
678    /**
679     * Sets the value of the JMX name base that will be used as part of the
680     * name assigned to JMX enabled pools created with this configuration
681     * instance. A value of {@code null} means that the pool will define
682     * the JMX name base.
683     *
684     * @param jmxNameBase The new setting of {@code jmxNameBase}
685     *        for this configuration instance
686     */
687    public void setJmxNameBase(final String jmxNameBase) {
688        this.jmxNameBase = jmxNameBase;
689    }
690
691    /**
692     * Gets the value of the JMX name prefix that will be used as part of the
693     * name assigned to JMX enabled pools created with this configuration
694     * instance.
695     *
696     * @return  The current setting of {@code jmxNamePrefix} for this
697     *          configuration instance
698     */
699    public String getJmxNamePrefix() {
700        return jmxNamePrefix;
701    }
702
703    /**
704     * Sets the value of the JMX name prefix that will be used as part of the
705     * name assigned to JMX enabled pools created with this configuration
706     * instance.
707     *
708     * @param jmxNamePrefix The new setting of {@code jmxNamePrefix}
709     *        for this configuration instance
710     */
711    public void setJmxNamePrefix(final String jmxNamePrefix) {
712        this.jmxNamePrefix = jmxNamePrefix;
713    }
714
715    @Override
716    protected void toStringAppendFields(final StringBuilder builder) {
717        builder.append("lifo=");
718        builder.append(lifo);
719        builder.append(", fairness=");
720        builder.append(fairness);
721        builder.append(", maxWaitMillis=");
722        builder.append(maxWaitMillis);
723        builder.append(", minEvictableIdleTimeMillis=");
724        builder.append(minEvictableIdleTimeMillis);
725        builder.append(", softMinEvictableIdleTimeMillis=");
726        builder.append(softMinEvictableIdleTimeMillis);
727        builder.append(", numTestsPerEvictionRun=");
728        builder.append(numTestsPerEvictionRun);
729        builder.append(", evictionPolicyClassName=");
730        builder.append(evictionPolicyClassName);
731        builder.append(", testOnCreate=");
732        builder.append(testOnCreate);
733        builder.append(", testOnBorrow=");
734        builder.append(testOnBorrow);
735        builder.append(", testOnReturn=");
736        builder.append(testOnReturn);
737        builder.append(", testWhileIdle=");
738        builder.append(testWhileIdle);
739        builder.append(", timeBetweenEvictionRunsMillis=");
740        builder.append(timeBetweenEvictionRunsMillis);
741        builder.append(", blockWhenExhausted=");
742        builder.append(blockWhenExhausted);
743        builder.append(", jmxEnabled=");
744        builder.append(jmxEnabled);
745        builder.append(", jmxNamePrefix=");
746        builder.append(jmxNamePrefix);
747        builder.append(", jmxNameBase=");
748        builder.append(jmxNameBase);
749    }
750}