All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cg.eventbus.producer.EventProducerPool Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
/**
 * 
 */
package org.cg.eventbus.producer;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.apache.commons.pool2.impl.GenericObjectPool;

/**
 * @author yanlinwang
 *
 */
public class EventProducerPool extends GenericObjectPool>{

	public static final String POOL_SIZE = "pool.size";
	public static final String IDLE_SIZE = "idle.size";

	
	public EventProducerPool (Class poolType, Configuration conf) throws Exception{		
		super(new PooledEventProducerFactory(poolType, conf));
		this.setMaxIdle(conf.getInt(IDLE_SIZE,GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY));
		this.setMaxTotal(conf.getInt(POOL_SIZE,GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY));
		this.setTestOnBorrow(true);
		this.setTestOnReturn(true);		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy