Package org.apache.commons.pool

Examples of org.apache.commons.pool.ObjectPool.returnObject()


   * of its listener, back to the pool.
   */
  protected void serverSessionFinished(ServerSession serverSession, ListenerSessionManager sessionManager) {
    ObjectPool pool = (ObjectPool) this.serverSessionPools.get(sessionManager);
    try {
      pool.returnObject(serverSession);
    }
    catch (Exception ex) {
      logger.error("Failed to return ServerSession to pool", ex);
    }
  }
View Full Code Here


    ObjectPool pool = (ObjectPool) this.serverSessionPools.get(sessionManager);
    if (pool == null) {
      throw new IllegalStateException("No pool found for session manager [" + sessionManager + "]");
    }
    try {
      pool.returnObject(serverSession);
    }
    catch (Exception ex) {
      logger.error("Failed to return ServerSession to pool", ex);
    }
  }
View Full Code Here

    ObjectPool pool = (ObjectPool) this.serverSessionPools.get(sessionManager);
    if (pool == null) {
      throw new IllegalStateException("No pool found for session manager [" + sessionManager + "]");
    }
    try {
      pool.returnObject(serverSession);
    }
    catch (Exception ex) {
      logger.error("Failed to return ServerSession to pool", ex);
    }
  }
View Full Code Here

        }
       
        // ...and immediately return them to pool. In this way the pooled connection has been opened.
        for (int index = 0; index < howManyConnectionAtStartup; index++)
        {
            pool.returnObject(openStartupList[index]);
        }

        pools.put(brokerId,pool);
    }
}
View Full Code Here

             *
             * Destruction of pooled objects is performed by the actual Commons Pool
             * ObjectPool implementation when the object factory's validateObject method
             * returns false. See ConPoolFactory#validateObject.
             */
            op.returnObject(con);
        }
        catch (Exception e)
        {
            throw new LookupException(e);
        }
View Full Code Here

            active[i] = pool.borrowObject();
        }
        assertEquals(100,pool.getNumActive());
        assertEquals(0,pool.getNumIdle());
        for(int i=0;i<100;i++) {
            pool.returnObject(active[i]);
            assertEquals(99 - i,pool.getNumActive());
            assertEquals((i < 8 ? i+1 : 8),pool.getNumIdle());
        }
    }
View Full Code Here

    }

    public void testPoolWithNullFactory() throws Exception {
        ObjectPool pool = new StackObjectPool(10);
        for(int i=0;i<10;i++) {
            pool.returnObject(new Integer(i));
        }
        for(int j=0;j<3;j++) {
            Integer[] borrowed = new Integer[10];
            BitSet found = new BitSet();
            for(int i=0;i<10;i++) {
View Full Code Here

                assertNotNull(borrowed);
                assertTrue(!found.get(borrowed[i].intValue()));
                found.set(borrowed[i].intValue());
            }
            for(int i=0;i<10;i++) {
                pool.returnObject(borrowed[i]);
            }
        }
        pool.invalidateObject(pool.borrowObject());
        pool.invalidateObject(pool.borrowObject());
        pool.clear();       
View Full Code Here

            // expected
        }
        pool.setFactory(new SimpleFactory());
        Object obj = pool.borrowObject();
        assertNotNull(obj);
        pool.returnObject(obj);
    }

    public void testCantResetFactoryWithActiveObjects() throws Exception {
        ObjectPool pool = new StackObjectPool();
        pool.setFactory(new SimpleFactory());
View Full Code Here

        ObjectPool pool = new StackObjectPool();
        {
            pool.setFactory(new SimpleFactory());
            Object obj = pool.borrowObject();       
            assertNotNull(obj);
            pool.returnObject(obj);
        }
        {
            pool.setFactory(new SimpleFactory());
            Object obj = pool.borrowObject();       
            assertNotNull(obj);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.