throw new NoSuchElementException(); } else { obj = _factory.makeObject(); newlyCreated = true; if (obj == null) { _factory.activateObject(obj); if (!_factory.validateObject(obj)) { throw new Exception("ValidateObject failed"); PoolUtils.checkRethrow(t); try { _factory.destroyObject(obj); } catch (Throwable t2) { PoolUtils.checkRethrow(t2);
throw new IllegalStateException("Cannot add objects without a factory."); T obj = _factory.makeObject(); if(!_factory.validateObject(obj)) { success = false; } else { _factory.passivateObject(obj); _factory.destroyObject(obj); } catch(Exception e) {
boolean success = !isClosed(); if (_factory != null) { if(!_factory.validateObject(obj)) { success = false; } else { try { _factory.passivateObject(obj); } catch(Exception e) { success = false; _factory.destroyObject(obj); } catch(Exception e) {
/** * Create an object, and place it into the pool. * addObject() is useful for "pre-loading" a pool with idle objects. */ @Override public void addObject() throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } T obj = _factory.makeObject(); try { assertOpen(); addObjectToPool(obj, false); } catch (IllegalStateException ex) { // Pool closed try { _factory.destroyObject(obj); } catch (Exception ex2) { // swallow } throw ex; } }
boolean active = false; try { _factory.activateObject(pair.value); active = true; } catch(Exception e) { if(!_factory.validateObject(pair.value)) { removeObject=true; } else { try { _factory.passivateObject(pair.value); } catch(Exception e) { removeObject=true; _factory.destroyObject(pair.value); } catch(Exception e) {
/** * Create a new object instance, ignoring the key * * @param key ignored * @return newly created object instance */ public V makeObject(final K key) throws Exception { return factory.makeObject(); }
/** * Destroy the object, ignoring the key. * * @param key ignored * @param obj instance to destroy */ public void destroyObject(final K key, final V obj) throws Exception { factory.destroyObject(obj); }
@Override public synchronized T borrowObject() throws Exception, NoSuchElementException, IllegalStateException { if (t != null) { // ensure the object is validate before we borrow it if (!factory.validateObject(t)) { invalidateObject(t); LOG.info("Recreating new connection as current connection is invalid: {}", t); t = null; } } if (t == null) { t = factory.makeObject(); } return t; }
/** * {@inheritDoc} */ public boolean validateObject(final T obj) { synchronized (lock) { return factory.validateObject(obj); } }
/** * Activate the object, ignoring the key. * * @param key ignored * @param obj object to be activated */ public void activateObject(final K key, final V obj) throws Exception { factory.activateObject(obj); }
/** * Passivate the object, ignoring the key. * * @param key ignored * @param obj object to passivate */ public void passivateObject(final K key, final V obj) throws Exception { factory.passivateObject(obj); }
boolean success = !isClosed(); if(null != _factory) { if(!_factory.validateObject(obj)) { success = false; } else { try { _factory.passivateObject(obj); } catch(Exception e) { success = false; _factory.destroyObject(obj); } catch(Exception e) {
boolean active = false; try { _factory.activateObject(pair.value); active = true; } catch(Exception e) { if(!_factory.validateObject(pair.value)) { removeObject=true; } else { try { _factory.passivateObject(pair.value); } catch(Exception e) { removeObject=true; _factory.destroyObject(pair.value); } catch(Exception e) {
/** * Create an object, and place it into the pool. * addObject() is useful for "pre-loading" a pool with idle objects. */ public void addObject() throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } Object obj = _factory.makeObject(); try { assertOpen(); addObjectToPool(obj, false); } catch (IllegalStateException ex) { // Pool closed try { _factory.destroyObject(obj); } catch (Exception ex2) { // swallow } throw ex; } }
/** * {@inheritDoc} */ public T makeObject() throws Exception { synchronized (lock) { return factory.makeObject(); } }
/** * {@inheritDoc} */ public void destroyObject(final T obj) throws Exception { synchronized (lock) { factory.destroyObject(obj); } }
/** * Validate the object, ignoring the key * * @param key ignored * @param obj object to validate * @return true if validation is successful */ public boolean validateObject(final K key, final V obj) { return factory.validateObject(obj); }
/** * {@inheritDoc} */ public void activateObject(final T obj) throws Exception { synchronized (lock) { factory.activateObject(obj); } }
/** * {@inheritDoc} */ public void passivateObject(final T obj) throws Exception { synchronized (lock) { factory.passivateObject(obj); } }
} else { newlyCreated = true; obj = _factory.makeObject(); _factory.activateObject(obj); if (!_factory.validateObject(obj)) { throw new Exception("ValidateObject failed"); PoolUtils.checkRethrow(t); try { _factory.destroyObject(obj); } catch (Throwable t2) { PoolUtils.checkRethrow(t2);