Пример #1
0
 /**
  * Create a new <code>SimpleKeyedObjectPool</code> using
  * the specified <code>factory</code> to create new instances.
  * capping the number of "sleeping" instances to <code>max</code>,
  * and initially allocating a container capable of containing
  * at least <code>init</code> instances.
  *
  * @param factory the {@link KeyedPoolableObjectFactory} used to populate the pool
  * @param max cap on the number of "sleeping" instances in the pool
  * @param init initial size of the pool (this specifies the size of the container,
  *             it does not cause the pool to be pre-populated.)
  */
 public StackKeyedObjectPool(KeyedPoolableObjectFactory <K, V> factory, int max, int init)
 {
     _factory              = factory;
     _maxSleeping          = (max < 0 ? DEFAULT_MAX_SLEEPING : max);
     _initSleepingCapacity = (init < 1 ? DEFAULT_INIT_SLEEPING_CAPACITY : init);
     _pools       = new java.util.HashMap <K, java.util.Stack <V> >();
     _activeCount = new java.util.HashMap <K, java.lang.Integer>();
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory)
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory) :
     this(factory, GenericKeyedObjectPool <K, V> .DEFAULT_MAX_ACTIVE,
          GenericKeyedObjectPool <K, V> .DEFAULT_WHEN_EXHAUSTED_ACTION,
          GenericKeyedObjectPool <K, V> .DEFAULT_MAX_WAIT,
          GenericKeyedObjectPool <K, V> .DEFAULT_MAX_IDLE,
          GenericKeyedObjectPool <K, V> .DEFAULT_TEST_ON_BORROW, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_ON_RETURN, GenericKeyedObjectPool <K, V> .DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_NUM_TESTS_PER_EVICTION_RUN, GenericKeyedObjectPool <K, V> .DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_WHILE_IDLE)
 {
 }
Пример #3
0
 public void setFactory(KeyedPoolableObjectFactory <K, V> factory)
 {// throws IllegalStateException {
     lock (this)
     {
         if (0 < getNumActive())
         {
             throw new java.lang.IllegalStateException("Objects are already active");
         }
         else
         {
             clear();
             _factory = factory;
         }
     }
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
  * @param whenExhaustedAction the action to take when the pool is exhausted.
  * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
  * @param maxIdle the maximum number of idle objects in the pools.
  * @param maxTotal the maximum number of objects that can exists at one time.
  * @param minIdle the minimum number of idle objects to have in the pool at any one time.
  * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
  * @param testOnReturn whether to validate objects after they are returned to returnObject.
  * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
  * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
  * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
  * @param testWhileIdle whether to validate objects in the idle object eviction thread.
  * @param lifo whether or not objects are returned in last-in-first-out order from the idle object pool.
  * @since Pool 1.4
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, bool, bool, long, int, long, bool, bool)
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, bool testOnBorrow, bool testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, bool testWhileIdle, bool lifo)
 {
     _maxIdle                       = maxIdle;
     _maxActive                     = maxActive;
     _maxTotal                      = maxTotal;
     _minIdle                       = minIdle;
     _maxWait                       = maxWait;
     _whenExhaustedAction           = whenExhaustedAction;
     _testOnBorrow                  = testOnBorrow;
     _testOnReturn                  = testOnReturn;
     _testWhileIdle                 = testWhileIdle;
     _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
     _numTestsPerEvictionRun        = numTestsPerEvictionRun;
     _minEvictableIdleTimeMillis    = minEvictableIdleTimeMillis;
     _factory                       = factory;
     _lifo = lifo;
 }
Пример #5
0
 /**
  * Create a new <code>SimpleKeyedObjectPool</code> using
  * the specified <code>factory</code> to create new instances.
  *
  * @param factory the {@link KeyedPoolableObjectFactory} used to populate the pool
  */
 public StackKeyedObjectPool(KeyedPoolableObjectFactory <K, V> factory) :
     this(factory, DEFAULT_MAX_SLEEPING)
 {
 }
Пример #6
0
 /**
  * Create a new <code>SimpleKeyedObjectPool</code> using
  * the specified <code>factory</code> to create new instances.
  * capping the number of "sleeping" instances to <code>max</code>
  *
  * @param factory the {@link KeyedPoolableObjectFactory} used to populate the pool
  * @param max cap on the number of "sleeping" instances in the pool
  */
 public StackKeyedObjectPool(KeyedPoolableObjectFactory <K, V> factory, int max) :
     this(factory, max, DEFAULT_INIT_SLEEPING_CAPACITY)
 {
 }
 /**
  * Create a new StackKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory used by created pools.
  * @param maxSleeping cap on the number of "sleeping" instances in the pool.
  * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory, int)
  */
 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxSleeping) :
     this(factory, maxSleeping, StackKeyedObjectPool <K, V> .DEFAULT_INIT_SLEEPING_CAPACITY)
 {
 }
 /**
  * Create a new StackKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory used by created pools.
  * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory)
  */
 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory) :
     this(factory, StackKeyedObjectPool <K, V> .DEFAULT_MAX_SLEEPING, StackKeyedObjectPool <K, V> .DEFAULT_INIT_SLEEPING_CAPACITY)
 {
 }
 /**
  * Create a new StackKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory used by created pools.
  * @param maxSleeping cap on the number of "sleeping" instances in the pool.
  * @param initialCapacity initial size of the pool (this specifies the size of the container,
  * it does not cause the pool to be pre-populated.)
  * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory, int, int)
  */
 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxSleeping, int initialCapacity)
 {
     _factory      = factory;
     _maxSleeping  = maxSleeping;
     _initCapacity = initialCapacity;
 }
Пример #10
0
 public virtual void setFactory(KeyedPoolableObjectFactory <K, V> factory)
 {// throws IllegalStateException, UnsupportedOperationException {
     throw new java.lang.UnsupportedOperationException();
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
  * @param whenExhaustedAction the action to take when the pool is exhausted.
  * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long)
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait) :
     this(factory, maxActive, whenExhaustedAction, maxWait, GenericKeyedObjectPool <K, V> .DEFAULT_MAX_IDLE, GenericKeyedObjectPool <K, V> .DEFAULT_MAX_TOTAL, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_ON_BORROW, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_ON_RETURN, GenericKeyedObjectPool <K, V> .DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_NUM_TESTS_PER_EVICTION_RUN, GenericKeyedObjectPool <K, V> .DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_WHILE_IDLE)
 {
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @param config a non-null GenericKeyedObjectPool<K,V>.Config describing the configuration.
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, GenericKeyedObjectPool<K,V>.Config)
  * @throws NullPointerException when config is <code>null</code>.
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, GenericKeyedObjectPool <K, V> .Config config) ://throws NullPointerException {
     this(factory, config.maxActive, config.whenExhaustedAction, config.maxWait, config.maxIdle, config.maxTotal, config.minIdle, config.testOnBorrow, config.testOnReturn, config.timeBetweenEvictionRunsMillis, config.numTestsPerEvictionRun, config.minEvictableIdleTimeMillis, config.testWhileIdle, config.lifo)
 {
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
  * @param whenExhaustedAction the action to take when the pool is exhausted.
  * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
  * @param maxIdle the maximum number of idle objects in the pools.
  * @param maxTotal the maximum number of objects that can exists at one time.
  * @param minIdle the minimum number of idle objects to have in the pool at any one time.
  * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
  * @param testOnReturn whether to validate objects after they are returned to returnObject.
  * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
  * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
  * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
  * @param testWhileIdle whether to validate objects in the idle object eviction thread.
  * @since Pool 1.3
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, bool, bool, long, int, long, bool)
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, bool testOnBorrow, bool testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, bool testWhileIdle) :
     this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle, GenericKeyedObjectPool <K, V> .DEFAULT_LIFO)
 {
 }
 /**
  * Create a new GenericKeyedObjectPoolFactory.
  *
  * @param factory the KeyedPoolableObjectFactory to used by created pools.
  * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
  * @param whenExhaustedAction the action to take when the pool is exhausted.
  * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
  * @param maxIdle the maximum number of idle objects in the pools.
  * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
  * @param testOnReturn whether to validate objects after they are returned to returnObject.
  * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, bool, bool)
  */
 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory <K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, bool testOnBorrow, bool testOnReturn) :
     this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, GenericKeyedObjectPool <K, V> .DEFAULT_MAX_TOTAL, testOnBorrow, testOnReturn, GenericKeyedObjectPool <K, V> .DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_NUM_TESTS_PER_EVICTION_RUN, GenericKeyedObjectPool <K, V> .DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericKeyedObjectPool <K, V> .DEFAULT_TEST_WHILE_IDLE)
 {
 }
Пример #15
0
 /// <summary>
 /// Create an KeyedObjectPool with the specified factory.  The pool should be in a
 /// default configuration and conform to the expected behaviors described in KeyedObjectPool.
 /// Generally speaking there should be no limits on the various object counts.
 /// </summary>
 protected abstract KeyedObjectPool <Object, Object> MakeEmptyPool(KeyedPoolableObjectFactory <Object, Object> factory);
Пример #16
0
 protected abstract KeyedObjectPoolFactory <Object, Object> MakeFactory(KeyedPoolableObjectFactory <Object, Object> objectFactory);