/** * Creates and holds an ObjectPool instance. * @see #createObjectPool() */ @Override protected final void createPool() { logger.debug("Creating Commons object pool"); this.pool = createObjectPool(); }
@Override public Object makeObject() throws BeansException { return newPrototypeInstance(); }
/** * Create a CommonsPoolTargetSource with default settings. * Default maximum size of the pool is 8. * @see #setMaxSize * @see GenericObjectPool#setMaxActive */ public CommonsPoolTargetSource() { setMaxSize(GenericObjectPool.DEFAULT_MAX_ACTIVE); }
/** * Subclasses can override this if they want to return a specific Commons pool. * They should apply any configuration properties to the pool here. * <p>Default is a GenericObjectPool instance with the given pool size. * @return an empty Commons {@code ObjectPool}. * @see org.apache.commons.pool.impl.GenericObjectPool * @see #setMaxSize */ protected ObjectPool createObjectPool() { GenericObjectPool gop = new GenericObjectPool(this); gop.setMaxActive(getMaxSize()); gop.setMaxIdle(getMaxIdle()); gop.setMinIdle(getMinIdle()); gop.setMaxWait(getMaxWait()); gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis()); gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); gop.setWhenExhaustedAction(getWhenExhaustedAction()); return gop; }
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( Class beanClass, String beanName) { if (beanName.startsWith(PREFIX_COMMONS_POOL)) { CommonsPoolTargetSource cpts = new CommonsPoolTargetSource(); cpts.setMaxSize(25); return cpts; } else if (beanName.startsWith(PREFIX_THREAD_LOCAL)) { return new ThreadLocalTargetSource(); } else if (beanName.startsWith(PREFIX_PROTOTYPE)) { return new PrototypeTargetSource(); } else { // No match. Don't create a custom target source. return null; } }
/** * Subclasses can override this if they want to return a specific Commons pool. * They should apply any configuration properties to the pool here. * <p>Default is a GenericObjectPool instance with the given pool size. * @return an empty Commons <code>ObjectPool</code>. * @see org.apache.commons.pool.impl.GenericObjectPool * @see #setMaxSize */ protected ObjectPool createObjectPool() { GenericObjectPool gop = new GenericObjectPool(this); gop.setMaxActive(getMaxSize()); gop.setMaxIdle(getMaxIdle()); gop.setMinIdle(getMinIdle()); gop.setMaxWait(getMaxWait()); gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis()); gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); gop.setWhenExhaustedAction(getWhenExhaustedAction()); return gop; }
/** * Creates and holds an ObjectPool instance. * @see #createObjectPool() */ protected final void createPool(BeanFactory beanFactory) { logger.info("Creating Commons object pool"); this.pool = createObjectPool(); }
/** * Create a CommonsPoolTargetSource with default settings. * Default maximum size of the pool is 8. * @see #setMaxSize * @see GenericObjectPool#setMaxActive */ public CommonsPoolTargetSource() { setMaxSize(GenericObjectPool.DEFAULT_MAX_ACTIVE); }
public Object makeObject() throws BeansException { return newPrototypeInstance(); }