當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。