@Override public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) { boolean wasEnabled = getPoolProperties().isPoolSweeperEnabled(); getPoolProperties().setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); boolean shouldBeEnabled = getPoolProperties().isPoolSweeperEnabled(); // make sure pool cleaner starts/stops when it should if (!wasEnabled && shouldBeEnabled) { pool.initializePoolCleaner(getPoolProperties()); } else if (wasEnabled) { pool.terminatePoolCleaner(); if (shouldBeEnabled) { pool.initializePoolCleaner(getPoolProperties()); } } }
@Override public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) { boolean wasEnabled = getPoolProperties().isPoolSweeperEnabled(); getPoolProperties().setRemoveAbandonedTimeout(removeAbandonedTimeout); boolean shouldBeEnabled = getPoolProperties().isPoolSweeperEnabled(); // make sure pool cleaner starts/stops when it should if (!wasEnabled && shouldBeEnabled) pool.initializePoolCleaner(getPoolProperties()); else if (wasEnabled && !shouldBeEnabled) pool.terminatePoolCleaner(); }
@Override public void setTestWhileIdle(boolean testWhileIdle) { boolean wasEnabled = getPoolProperties().isPoolSweeperEnabled(); getPoolProperties().setTestWhileIdle(testWhileIdle); boolean shouldBeEnabled = getPoolProperties().isPoolSweeperEnabled(); // make sure pool cleaner starts/stops when it should if (!wasEnabled && shouldBeEnabled) pool.initializePoolCleaner(getPoolProperties()); else if (wasEnabled && !shouldBeEnabled) pool.terminatePoolCleaner(); }
@Override public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) { boolean wasEnabled = getPoolProperties().isPoolSweeperEnabled(); getPoolProperties().setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); boolean shouldBeEnabled = getPoolProperties().isPoolSweeperEnabled(); // make sure pool cleaner starts/stops when it should if (!wasEnabled && shouldBeEnabled) pool.initializePoolCleaner(getPoolProperties()); else if (wasEnabled && !shouldBeEnabled) pool.terminatePoolCleaner(); }