Search in sources :

Example 1 with BaseKeyedPooledObjectFactory

use of org.apache.commons.pool2.BaseKeyedPooledObjectFactory in project cuba by cuba-platform.

the class AbstractScripting method getPool.

private synchronized GenericKeyedObjectPool<String, Script> getPool() {
    if (pool == null) {
        GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
        poolConfig.setMaxTotalPerKey(-1);
        poolConfig.setMaxIdlePerKey(globalConfig.getGroovyEvaluationPoolMaxIdle());
        pool = new GenericKeyedObjectPool<>(new BaseKeyedPooledObjectFactory<String, Script>() {

            @Override
            public Script create(String key) throws Exception {
                return createScript(key);
            }

            @Override
            public PooledObject<Script> wrap(Script value) {
                return new DefaultPooledObject<>(value);
            }
        }, poolConfig);
    }
    return pool;
}
Also used : GenericKeyedObjectPoolConfig(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig) Script(groovy.lang.Script) DefaultPooledObject(org.apache.commons.pool2.impl.DefaultPooledObject) BaseKeyedPooledObjectFactory(org.apache.commons.pool2.BaseKeyedPooledObjectFactory)

Aggregations

Script (groovy.lang.Script)1 BaseKeyedPooledObjectFactory (org.apache.commons.pool2.BaseKeyedPooledObjectFactory)1 DefaultPooledObject (org.apache.commons.pool2.impl.DefaultPooledObject)1 GenericKeyedObjectPoolConfig (org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig)1