当前位置: 首页>>代码示例>>Java>>正文


Java PooledObjectFactory类代码示例

本文整理汇总了Java中org.apache.commons.pool2.PooledObjectFactory的典型用法代码示例。如果您正苦于以下问题:Java PooledObjectFactory类的具体用法?Java PooledObjectFactory怎么用?Java PooledObjectFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PooledObjectFactory类属于org.apache.commons.pool2包,在下文中一共展示了PooledObjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GenericObjectPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
/**
 * 使用特定的配置来创建一个新的"通用对象池"实例。
 * <p>
 * Create a new <code>GenericObjectPool</code> using a specific
 * configuration.
 *
 * @param factory   The object factory to be used to create object instances
 *                  used by this pool (用于创建"池对象"实例的对象工厂)
 * @param config    The configuration to use for this pool instance. (用于该对象池实例的配置信息)
 *                  The configuration is used by value. Subsequent changes to
 *                  the configuration object will not be reflected in the
 *                  pool. (随后对配置对象的更改将不会反映到对象池中)
 */
public GenericObjectPool(PooledObjectFactory<T> factory,
        GenericObjectPoolConfig config) {

    super(config, ONAME_BASE, config.getJmxNamePrefix());

    if (factory == null) {
        jmxUnregister(); // tidy up
        throw new IllegalArgumentException("factory may not be null");
    }
    this.factory = factory;

    this.setConfig(config);
    // 启动"驱逐者线程"
    this.startEvictor(this.getTimeBetweenEvictionRunsMillis());
}
 
开发者ID:EdwardLee03,项目名称:commons-pool2-sr,代码行数:29,代码来源:GenericObjectPool.java

示例2: GenericObjectPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
/**
 * Create a new <code>GenericObjectPool</code> using a specific
 * configuration.
 *
 * @param factory   The object factory to be used to create object instances
 *                  used by this pool
 * @param config    The configuration to use for this pool instance. The
 *                  configuration is used by value. Subsequent changes to
 *                  the configuration object will not be reflected in the
 *                  pool.
 */
public GenericObjectPool(final PooledObjectFactory<T> factory,
        final GenericObjectPoolConfig config) {

    super(config, ONAME_BASE, config.getJmxNamePrefix());

    if (factory == null) {
        jmxUnregister(); // tidy up
        throw new IllegalArgumentException("factory may not be null");
    }
    this.factory = factory;

    idleObjects = new LinkedBlockingDeque<>(config.getFairness());

    setConfig(config);

    startEvictor(getTimeBetweenEvictionRunsMillis());
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:29,代码来源:GenericObjectPool.java

示例3: setUp

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
@Before
public void setUp() {
    log = new StringWriter();

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

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

    final PooledObjectFactory<TestObject> factory = new TestObjectFactory();

    final ObjectPool<TestObject> innerPool =
            new GenericObjectPool<>(factory, config, abandonedConfig);

    pool = new ProxiedObjectPool<>(innerPool, getproxySource());
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:23,代码来源:BaseTestProxiedObjectPool.java

示例4: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public void initPool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<T> factory) {

		if (this.internalPool != null) {
			try {
				closeInternalPool();
			} catch (Exception e) {
			}
		}

		this.internalPool = new GenericObjectPool<T>(factory, poolConfig);
	}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:Pool.java

示例5: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public void initPool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<T> factory) {

    if (this.internalPool != null) {
      try {
        closeInternalPool();
      } catch (Exception e) {
      }
    }

    this.internalPool = new GenericObjectPool<T>(factory, poolConfig);
  }
 
开发者ID:x7-framework,项目名称:x7,代码行数:12,代码来源:Pool.java

示例6: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public void initPool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<KuduClient> factory)
{
    if (this.internalPool != null) {
        try {
            closeInternalPool();
        }
        catch (Exception e) {
        }
    }

    this.internalPool = new GenericObjectPool<KuduClient>(factory, poolConfig);
}
 
开发者ID:trackingio,项目名称:presto-kudu,代码行数:13,代码来源:KuduClientPool.java

示例7: Pool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public Pool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<T> factory) {
  initPool(poolConfig, factory);
}
 
开发者ID:Wangab,项目名称:Jedis,代码行数:4,代码来源:Pool.java

示例8: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
/**
 * <p>Title: initPool</p>
 * <p>Description: 初始化对象池</p>
 *
 * @param poolConfig 池配置
 * @param factory    池对象工厂
 */
protected void initPool(final GenericObjectPoolConfig poolConfig,
                        PooledObjectFactory<T> factory) {
    if (this.internalPool != null)
        this.destroy();

    this.internalPool = new GenericObjectPool<T>(factory, poolConfig);
}
 
开发者ID:DarkPhoenixs,项目名称:connection-pool-client,代码行数:15,代码来源:PoolBase.java

示例9: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public void initPool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<Client> factory) {
    if (this.internalPool != null) {
        try {
            closeInternalPool();
        } catch (Exception e) {
            //ignore
        }
    }
    this.internalPool = new GenericObjectPool<Client>(factory, poolConfig);
}
 
开发者ID:rguiu,项目名称:BStalkJ,代码行数:11,代码来源:BeanstalkPool.java

示例10: initPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
/**
 * 初始化"连接池"。
 * 
 * @param poolConfig
 *            连接池配置信息
 * @param factory
 *            连接池对象的工厂
 */
public void initPool(GenericObjectPoolConfig poolConfig,
		PooledObjectFactory<R> factory) {
	// 若原有的连接池资源未被释放,则先关闭
	if (this.internalPool != null) {
		try {
			this.closeInternalPool();
		} catch (Exception e) {
		}
	}

	this.internalPool = new GenericObjectPool<R>(factory, poolConfig);
}
 
开发者ID:EdwardLee03,项目名称:jedis-sr,代码行数:21,代码来源:Pool.java

示例11: createObjectPool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
private static <T> ObjectPool<T> createObjectPool(final PooledObjectFactory<T> factory) {
    final GenericObjectPoolConfig objectPoolConfig = new GenericObjectPoolConfig();
    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);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:13,代码来源:SvnObjectPools.java

示例12: Pool

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public Pool(final GenericObjectPoolConfig poolConfig, PooledObjectFactory<T> factory) {
	initPool(poolConfig, factory);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:4,代码来源:Pool.java

示例13: KryoPoolCommonsImpl

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public KryoPoolCommonsImpl(GenericObjectPoolConfig genericObjectPoolConfig, PooledObjectFactory<Kryo> pooledObjectFactory, AbandonedConfig abandonedConfig, FKCExceptionHandler fkcExceptionHandler) {
    this.kryoPool = new GenericObjectPool<Kryo>(pooledObjectFactory, genericObjectPoolConfig, abandonedConfig);
    this.fkcExceptionHandler = fkcExceptionHandler;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:5,代码来源:KryoPoolCommonsImpl.java

示例14: CommonsBuilder

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public CommonsBuilder(PooledObjectFactory<Kryo> kryoPooledObjectFactory) {
    if (kryoPooledObjectFactory == null) {
        throw new IllegalArgumentException("pooledObjectFactory must not be null");
    }
    this.pooledObjectFactory = kryoPooledObjectFactory;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:7,代码来源:KryoPool.java

示例15: setPooledObjectFactory

import org.apache.commons.pool2.PooledObjectFactory; //导入依赖的package包/类
public void setPooledObjectFactory(PooledObjectFactory<Kryo> pooledObjectFactory) {
    this.pooledObjectFactory = pooledObjectFactory;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:4,代码来源:KryoPoolConfig.java


注:本文中的org.apache.commons.pool2.PooledObjectFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。