Example usage for org.apache.commons.pool2 PoolUtils synchronizedPool

List of usage examples for org.apache.commons.pool2 PoolUtils synchronizedPool

Introduction

In this page you can find the example usage for org.apache.commons.pool2 PoolUtils synchronizedPool.

Prototype

public static <K, V> KeyedObjectPool<K, V> synchronizedPool(final KeyedObjectPool<K, V> keyedPool) 

Source Link

Document

Returns a synchronized (thread-safe) KeyedObjectPool backed by the specified KeyedObjectPool.

Usage

From source file:org.dspace.event.EventServiceImpl.java

private void initPool() {

    if (dispatcherPool == null) {

        // TODO EVENT Some of these pool configuration
        // parameters can live in dspace.cfg or a
        // separate configuration file

        // TODO EVENT Eviction parameters should be set

        poolConfig = new GenericKeyedObjectPoolConfig();
        poolConfig.setMaxTotalPerKey(100);
        poolConfig.setMaxIdlePerKey(5);//from   w w  w . j a  va  2s .  c  o m
        poolConfig.setMaxTotal(100);

        try {
            dispatcherFactory = new DispatcherPoolFactory();

            dispatcherPool = PoolUtils
                    .synchronizedPool(new GenericKeyedObjectPool(dispatcherFactory, poolConfig));

            enumerateConsumers();

        } catch (Exception e) {
            log.error("Could not initialize EventService dispatcher pool", e);
        }

    }
}