Package org.apache.commons.pool

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


        pool = createObjectPool(sessionManager);
        this.serverSessionPools.put(sessionManager, pool);
      }
    }
    try {
      return (ServerSession) pool.borrowObject();
    }
    catch (Exception ex) {
      JMSException jmsEx = new JMSException("Failed to borrow ServerSession from pool");
      jmsEx.setLinkedException(ex);
      throw jmsEx;
View Full Code Here


            ObjectPool pool = getConnectionPool(url.substring(URL_PREFIX_LEN));
            if(null == pool) {
                throw new SQLException("No pool found for " + url + ".");
            } else {
                try {
                    Connection conn = (Connection)(pool.borrowObject());
                    if (conn != null) {
                        conn = new PoolGuardConnectionWrapper(pool, conn);
                    }
                    return conn;
                } catch(SQLException e) {
View Full Code Here

            ObjectPool pool = getConnectionPool(url.substring(URL_PREFIX_LEN));
            if(null == pool) {
                throw new SQLException("No pool found for " + url + ".");
            } else {
                try {
                    Connection conn = (Connection)(pool.borrowObject());
                    if (conn != null) {
                        conn = new PoolGuardConnectionWrapper(pool, conn);
                    }
                    return conn;
                } catch(SQLException e) {
View Full Code Here

            pool = ((CPDSConnectionFactory) manager).getPool();
        }

        PooledConnectionAndInfo info = null;
        try {
            info = (PooledConnectionAndInfo) pool.borrowObject();
        }
        catch (NoSuchElementException ex) {
            throw new SQLNestedException(
                    "Could not retrieve connection info from pool", ex);
        }
View Full Code Here

        Object [] openStartupList = new Object[howManyConnectionAtStartup];
       
        // Open...
        for (int index  = 0; index < howManyConnectionAtStartup; index++)
        {
            openStartupList[index] = pool.borrowObject();
        }
       
        // ...and immediately return them to pool. In this way the pooled connection has been opened.
        for (int index = 0; index < howManyConnectionAtStartup; index++)
        {
View Full Code Here

            ObjectPool pool = getPool(url.substring(URL_PREFIX_LEN));
            if(null == pool) {
                throw new SQLException("No pool found for " + url + ".");
            } else {
                try {
                    return (Connection)(pool.borrowObject());
                } catch(SQLException e) {
                    throw e;
                } catch(RuntimeException e) {
                    throw e;
                } catch(Exception e) {
View Full Code Here

            ObjectPool pool = getConnectionPool(url.substring(URL_PREFIX_LEN));
            if(null == pool) {
                throw new SQLException("No pool found for " + url + ".");
            } else {
                try {
                    Connection conn = (Connection)(pool.borrowObject());
                    if (conn != null) {
                        conn = new PoolGuardConnectionWrapper(conn);
                    }
                    return conn;
                } catch(SQLException e) {
View Full Code Here

            }
        }
        final Connection conn;
        try
        {
            conn = (Connection) op.borrowObject();
        }
        catch (NoSuchElementException e)
        {
            int active = 0;
            int idle = 0;
View Full Code Here

    public void testIdleCap() throws Exception {
        ObjectPool pool = makeEmptyPool(8);
        Object[] active = new Object[100];
        for(int i=0;i<100;i++) {
            active[i] = pool.borrowObject();
        }
        assertEquals(100,pool.getNumActive());
        assertEquals(0,pool.getNumIdle());
        for(int i=0;i<100;i++) {
            pool.returnObject(active[i]);
View Full Code Here

        }
        for(int j=0;j<3;j++) {
            Integer[] borrowed = new Integer[10];
            BitSet found = new BitSet();
            for(int i=0;i<10;i++) {
                borrowed[i] = (Integer)(pool.borrowObject());
                assertNotNull(borrowed);
                assertTrue(!found.get(borrowed[i].intValue()));
                found.set(borrowed[i].intValue());
            }
            for(int i=0;i<10;i++) {
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.