Package org.apache.commons.pool2.impl

Examples of org.apache.commons.pool2.impl.BaseGenericObjectPool


        // See if we end up with dead man walking
        SimpleTestThread<Waiter> t2 = new SimpleTestThread<Waiter>(waiterPool, "51");
        Thread thread2 = new Thread(t2);
        thread2.start()// Triggers clearOldest, killing all of the 0's and the 2 oldest 1's
        Thread.sleep(50); // Wait for clearOldest to kick off, but not long enough to reach the 1's
        Waiter waiter = waiterPool.borrowObject("1");
        Thread.sleep(200); // Wait for execution to happen
        waiterPool.returnObject("1", waiter)// Will throw IllegalStateException if dead
        waiterPool.close();
    }
View Full Code Here


        objectPoolConfig.setMinEvictableIdleTimeMillis(TimeUnit.HOURS.toMillis(1)); // arbitrary, but positive so objects do get evicted
        objectPoolConfig.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES.toMillis(10)); // arbitrary, but positive so objects do get evicted
        objectPoolConfig.setJmxEnabled(false);
        objectPoolConfig.setBlockWhenExhausted(false);
        objectPoolConfig.setMaxTotal(-1); // uncapped number of objects in the pool
        final AbandonedConfig abandonedConfig = new AbandonedConfig();
        abandonedConfig.setRemoveAbandonedOnBorrow(true);
        abandonedConfig.setRemoveAbandonedTimeout((int) TimeUnit.MINUTES.toSeconds(30));
        return new GenericObjectPool<T>(factory, objectPoolConfig, abandonedConfig);
    }
View Full Code Here

    @Before
    public void setUp() {
        log = new StringWriter();

        PrintWriter pw = new PrintWriter(log);
        AbandonedConfig abandonedConfig = new AbandonedConfig();
        abandonedConfig.setLogAbandoned(true);
        abandonedConfig.setRemoveAbandonedOnBorrow(true);
        abandonedConfig.setUseUsageTracking(true);
        abandonedConfig.setRemoveAbandonedTimeout(ABANDONED_TIMEOUT_SECS);
        abandonedConfig.setLogWriter(pw);

        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setMaxTotal(3);

        PooledObjectFactory<TestObject> factory = new TestObjectFactory();
View Full Code Here

     *                                     invoked
     */
    public void setRemoveAbandonedOnMaintenance(
            boolean removeAbandonedOnMaintenance) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setRemoveAbandonedOnMaintenance(
                removeAbandonedOnMaintenance);
    }
View Full Code Here

     * @param removeAbandonedOnBorrow true means abandoned connections will be
     *                                removed during pool maintenance
     */
    public void setRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setRemoveAbandonedOnBorrow(removeAbandonedOnBorrow);
    }
View Full Code Here

     * @see #getRemoveAbandonedOnBorrow()
     * @see #getRemoveAbandonedOnMaintenance()
     */
    public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setRemoveAbandonedTimeout(removeAbandonedTimeout);
    }
View Full Code Here

    /**
     * @param logAbandoned new logAbandoned property value
     */
    public void setLogAbandoned(boolean logAbandoned) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setLogAbandoned(logAbandoned);
    }
View Full Code Here

     *
     * @param logWriter The new log writer
     */
    public void setAbandonedLogWriter(PrintWriter logWriter) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setLogWriter(logWriter);
    }
View Full Code Here

     *                              the recording of a stack trace on every use
     *                              of a pooled connection
     */
    public void setAbandonedUsageTracking(boolean usageTracking) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setUseUsageTracking(usageTracking);
    }
View Full Code Here

     *                                     invoked
     */
    public void setRemoveAbandonedOnMaintenance(
            boolean removeAbandonedOnMaintenance) {
        if (abandonedConfig == null) {
            abandonedConfig = new AbandonedConfig();
        }
        abandonedConfig.setRemoveAbandonedOnMaintenance(
                removeAbandonedOnMaintenance);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.pool2.impl.BaseGenericObjectPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.