decrementActiveCount(key); if (null != _factory) { if (_factory.validateObject(key, obj)) { try { _factory.passivateObject(key, obj); } catch (Exception ex) { _factory.destroyObject(key, obj); return; if (null != _factory) { try { _factory.destroyObject(key, obj); } catch (Exception e) { _factory.destroyObject(key, staleObj); } catch (Exception e) {
throw new NoSuchElementException("pools without a factory cannot create new objects as needed."); } else { obj = _factory.makeObject(key); newlyMade = true; _factory.activateObject(key, obj); if (!_factory.validateObject(key, obj)) { throw new Exception("ValidateObject failed"); PoolUtils.checkRethrow(t); try { _factory.destroyObject(key,obj); } catch (Throwable t2) { PoolUtils.checkRethrow(t2);
throw new IllegalStateException("Cannot add objects without a factory."); V obj = _factory.makeObject(key); try { if (!_factory.validateObject(key, obj)) { return; _factory.destroyObject(key, obj); } catch (Exception e2) { _factory.passivateObject(key, obj); _factory.destroyObject(key, staleObj); } catch (Exception e) {
/** * Create an object using the {@link KeyedPoolableObjectFactory#makeObject factory}, * passivate it, and then place it in the idle object pool. * <code>addObject</code> is useful for "pre-loading" a pool with idle objects. * * @param key the key a new instance should be added to * @throws Exception when {@link KeyedPoolableObjectFactory#makeObject} fails. * @throws IllegalStateException when no {@link #setFactory factory} has been set or after {@link #close} has been * called on this pool. */ @Override public void addObject(K key) throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } V obj = _factory.makeObject(key); try { assertOpen(); addObjectToPool(key, obj, false); } catch (IllegalStateException ex) { // Pool closed try { _factory.destroyObject(key, obj); } catch (Exception ex2) { // swallow } throw ex; } }
boolean active = false; try { _factory.activateObject(key,pair.value); active = true; } catch(Exception e) { if (!_factory.validateObject(key,pair.value)) { removeObject=true; } else { try { _factory.passivateObject(key,pair.value); } catch(Exception e) { removeObject=true; _factory.destroyObject(key, pair.value); } catch(Exception e) {
/** * {@inheritDoc} */ public void destroyObject(final K key, final V obj) throws Exception { synchronized (lock) { keyedFactory.destroyObject(key, obj); } }
/** * Passivate the object, passing the fixed key to the factory. * * @param obj object to passivate */ public void passivateObject(final V obj) throws Exception { keyedFactory.passivateObject(key, obj); }
/** * Activate the object, passing the fixed key to the factory. * * @param obj object to activate */ public void activateObject(final V obj) throws Exception { keyedFactory.activateObject(key, obj); }
/** * {@inheritDoc} */ public boolean validateObject(final K key, final V obj) { synchronized (lock) { return keyedFactory.validateObject(key, obj); } }
/** * Create an object instance using the configured factory and key. * * @return new object instance */ public V makeObject() throws Exception { return keyedFactory.makeObject(key); }
boolean active = false; try { _factory.activateObject(key,pair.value); active = true; } catch(Exception e) { if(!_factory.validateObject(key,pair.value)) { removeObject=true; } else { try { _factory.passivateObject(key,pair.value); } catch(Exception e) { removeObject=true; _evictionCursor.remove(); _totalIdle--; _factory.destroyObject(key, pair.value);
throw new IllegalStateException("Cannot add objects without a factory."); Object obj = _factory.makeObject(key); try { if (!_factory.validateObject(key, obj)) { return; _factory.destroyObject(key, obj); } catch (Exception e2) { _factory.passivateObject(key, obj); _factory.destroyObject(key, staleObj); } catch (Exception e) {
/** * Create an object using the {@link KeyedPoolableObjectFactory#makeObject factory}, * passivate it, and then place it in the idle object pool. * <code>addObject</code> is useful for "pre-loading" a pool with idle objects. * * @param key the key a new instance should be added to * @throws Exception when {@link KeyedPoolableObjectFactory#makeObject} fails. * @throws IllegalStateException when no {@link #setFactory factory} has been set or after {@link #close} has been * called on this pool. */ public void addObject(Object key) throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } Object obj = _factory.makeObject(key); try { assertOpen(); addObjectToPool(key, obj, false); } catch (IllegalStateException ex) { // Pool closed try { _factory.destroyObject(key, obj); } catch (Exception ex2) { // swallow } throw ex; } }
/** * Destroy the object, passing the fixed key to the factory. * * @param obj object to destroy */ public void destroyObject(final V obj) throws Exception { keyedFactory.destroyObject(key, obj); }
/** * {@inheritDoc} */ public void passivateObject(final K key, final V obj) throws Exception { synchronized (lock) { keyedFactory.passivateObject(key, obj); } }
/** * {@inheritDoc} */ public void activateObject(final K key, final V obj) throws Exception { synchronized (lock) { keyedFactory.activateObject(key, obj); } }
/** * Validate the object, passing the fixed key to the factory. * * @param obj object to validate * @return true if validation is successful */ public boolean validateObject(final V obj) { return keyedFactory.validateObject(key, obj); }
/** * {@inheritDoc} */ public V makeObject(final K key) throws Exception { synchronized (lock) { return keyedFactory.makeObject(key); } }
if (null == latch.getPair()) { try { V obj = _factory.makeObject(key); latch.setPair(new ObjectTimestampPair<V>(obj)); newlyCreated = true; _factory.activateObject(key, latch.getPair().value); if (_testOnBorrow && !_factory.validateObject(key, latch.getPair().value)) { throw new Exception("ValidateObject failed"); _factory.destroyObject(key, latch.getPair().value); } catch (Throwable e2) { PoolUtils.checkRethrow(e2);
boolean active = false; try { _factory.activateObject(key,pair.value); active = true; } catch(Exception e) { if (!_factory.validateObject(key,pair.value)) { removeObject=true; } else { try { _factory.passivateObject(key,pair.value); } catch(Exception e) { removeObject=true; _factory.destroyObject(key, pair.value); } catch(Exception e) {