/** * Create a <code>SoftReferenceObjectPool</code> with the specified factory and initial idle object count. * * @param factory object factory to use. * @param initSize initial size to attempt to prefill the pool. * @throws Exception when there is a problem prefilling the pool. * @throws IllegalArgumentException when <code>factory</code> is <code>null</code>. * @deprecated because this is a SoftReference pool, prefilled idle obejects may be garbage collected before they are used. * To be removed in Pool 2.0. */ @Deprecated public SoftReferenceObjectPool(PoolableObjectFactory<T> factory, int initSize) throws Exception, IllegalArgumentException { if (factory == null) { throw new IllegalArgumentException("factory required to prefill the pool."); } _pool = new ArrayList<SoftReference<T>>(initSize); _factory = factory; PoolUtils.prefill(this, initSize); }
/** * Call <code>addObject(Object)</code> on <code>keyedPool</code> with each key in <code>keys</code> for * <code>count</code> number of times. This has the same effect as calling * {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection. * * @param <K> the type of key * @param <V> the type of object * @param keyedPool the keyedPool to prefill. * @param keys {@link Collection} of keys to add objects for. * @param count the number of idle objects to add for each <code>key</code>. * @throws Exception when {@link KeyedObjectPool#addObject(Object)} fails. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or * any value in <code>keys</code> is <code>null</code>. * @see #prefill(KeyedObjectPool, Object, int) * @since Pool 1.3 */ public static <K, V> void prefill(final KeyedObjectPool<K, V> keyedPool, final Collection<? extends K> keys, final int count) throws Exception, IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Iterator<? extends K> iter = keys.iterator(); while (iter.hasNext()) { prefill(keyedPool, iter.next(), count); } }
/** * Create a <code>SoftReferenceObjectPool</code> with the specified factory and initial idle object count. * * @param factory object factory to use. * @param initSize initial size to attempt to prefill the pool. * @throws Exception when there is a problem prefilling the pool. * @throws IllegalArgumentException when <code>factory</code> is <code>null</code>. * @deprecated because this is a SoftReference pool, prefilled idle obejects may be garbage collected before they are used. * To be removed in Pool 3.0. */ public SoftReferenceObjectPool(PoolableObjectFactory factory, int initSize) throws Exception, IllegalArgumentException { if (factory == null) { throw new IllegalArgumentException("factory required to prefill the pool."); } _pool = new ArrayList(initSize); _factory = factory; PoolUtils.prefill(this, initSize); }
/** * Create a <code>SoftReferenceObjectPool</code> with the specified factory and initial idle object count. * * @param factory object factory to use. * @param initSize initial size to attempt to prefill the pool. * @throws Exception when there is a problem prefilling the pool. * @throws IllegalArgumentException when <code>factory</code> is <code>null</code>. * @deprecated because this is a SoftReference pool, prefilled idle obejects may be garbage collected before they are used. * To be removed in Pool 3.0. */ public SoftReferenceObjectPool(PoolableObjectFactory factory, int initSize) throws Exception, IllegalArgumentException { if (factory == null) { throw new IllegalArgumentException("factory required to prefill the pool."); } _pool = new ArrayList(initSize); _factory = factory; PoolUtils.prefill(this, initSize); }
/** * Create a <code>SoftReferenceObjectPool</code> with the specified factory and initial idle object count. * * @param factory object factory to use. * @param initSize initial size to attempt to prefill the pool. * @throws Exception when there is a problem prefilling the pool. * @throws IllegalArgumentException when <code>factory</code> is <code>null</code>. * @deprecated because this is a SoftReference pool, prefilled idle obejects may be garbage collected before they are used. * To be removed in Pool 2.0. */ @Deprecated public SoftReferenceObjectPool(PoolableObjectFactory<T> factory, int initSize) throws Exception, IllegalArgumentException { if (factory == null) { throw new IllegalArgumentException("factory required to prefill the pool."); } _pool = new ArrayList<SoftReference<T>>(initSize); _factory = factory; PoolUtils.prefill(this, initSize); }
/** * Create a <code>SoftReferenceObjectPool</code> with the specified factory and initial idle object count. * * @param factory object factory to use. * @param initSize initial size to attempt to prefill the pool. * @throws Exception when there is a problem prefilling the pool. * @throws IllegalArgumentException when <code>factory</code> is <code>null</code>. * @deprecated because this is a SoftReference pool, prefilled idle obejects may be garbage collected before they are used. * To be removed in Pool 2.0. */ @Deprecated public SoftReferenceObjectPool(PoolableObjectFactory<T> factory, int initSize) throws Exception, IllegalArgumentException { if (factory == null) { throw new IllegalArgumentException("factory required to prefill the pool."); } _pool = new ArrayList<SoftReference<T>>(initSize); _factory = factory; PoolUtils.prefill(this, initSize); }
/** * Call <code>addObject(Object)</code> on <code>keyedPool</code> with each key in <code>keys</code> for * <code>count</code> number of times. This has the same effect as calling * {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection. * * @param <K> the type of key * @param <V> the type of object * @param keyedPool the keyedPool to prefill. * @param keys {@link Collection} of keys to add objects for. * @param count the number of idle objects to add for each <code>key</code>. * @throws Exception when {@link KeyedObjectPool#addObject(Object)} fails. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or * any value in <code>keys</code> is <code>null</code>. * @see #prefill(KeyedObjectPool, Object, int) * @since Pool 1.3 */ public static <K, V> void prefill(final KeyedObjectPool<K, V> keyedPool, final Collection<? extends K> keys, final int count) throws Exception, IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Iterator<? extends K> iter = keys.iterator(); while (iter.hasNext()) { prefill(keyedPool, iter.next(), count); } }
/** * Call <code>addObject(Object)</code> on <code>keyedPool</code> with each key in <code>keys</code> for * <code>count</code> number of times. This has the same effect as calling * {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection. * * @param keyedPool the keyedPool to prefill. * @param keys {@link Collection} of keys to add objects for. * @param count the number of idle objects to add for each <code>key</code>. * @throws Exception when {@link KeyedObjectPool#addObject(Object)} fails. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or * any value in <code>keys</code> is <code>null</code>. * @see #prefill(KeyedObjectPool, Object, int) * @since Pool 1.3 */ public static void prefill(final KeyedObjectPool keyedPool, final Collection keys, final int count) throws Exception, IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Iterator iter = keys.iterator(); while (iter.hasNext()) { prefill(keyedPool, iter.next(), count); } }
/** * Call <code>addObject(Object)</code> on <code>keyedPool</code> with each key in <code>keys</code> for * <code>count</code> number of times. This has the same effect as calling * {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection. * * @param keyedPool the keyedPool to prefill. * @param keys {@link Collection} of keys to add objects for. * @param count the number of idle objects to add for each <code>key</code>. * @throws Exception when {@link KeyedObjectPool#addObject(Object)} fails. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or * any value in <code>keys</code> is <code>null</code>. * @see #prefill(KeyedObjectPool, Object, int) * @since Pool 1.3 */ public static void prefill(final KeyedObjectPool keyedPool, final Collection keys, final int count) throws Exception, IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Iterator iter = keys.iterator(); while (iter.hasNext()) { prefill(keyedPool, iter.next(), count); } }
/** * Call <code>addObject(Object)</code> on <code>keyedPool</code> with each key in <code>keys</code> for * <code>count</code> number of times. This has the same effect as calling * {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection. * * @param <K> the type of key * @param <V> the type of object * @param keyedPool the keyedPool to prefill. * @param keys {@link Collection} of keys to add objects for. * @param count the number of idle objects to add for each <code>key</code>. * @throws Exception when {@link KeyedObjectPool#addObject(Object)} fails. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or * any value in <code>keys</code> is <code>null</code>. * @see #prefill(KeyedObjectPool, Object, int) * @since Pool 1.3 */ public static <K, V> void prefill(final KeyedObjectPool<K, V> keyedPool, final Collection<? extends K> keys, final int count) throws Exception, IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Iterator<? extends K> iter = keys.iterator(); while (iter.hasNext()) { prefill(keyedPool, iter.next(), count); } }
/** * Sets the size of the pool. * @param size * @throws IllegalArgumentException if the passed size is lower than the * number of current active clients. * @throws Exception in case of trouble manipulating the underlying pool. */ public static void setSize(int size) throws IllegalArgumentException, Exception { if (size < instance.getNumActive()){ throw new IllegalArgumentException( instance.getNumActive() + " active clients in the pool"); } if (size > instance.getNumActive()){ instance.clear(); PoolUtils.prefill(instance, size - instance.getNumActive()); } ((GenericObjectPool<FeaturesClient>) instance).setMaxActive(size); }
PoolUtils.prefill(sessionPool, initialSize); } catch (Exception e) { throw new RepositoryException("Failed to prefill initial sessions.", e);