Examples of ObjectPool


Examples of org.apache.commons.pool.ObjectPool

     */
    private synchronized ObjectPool getPool(
        Object key,
        ConnectionFactory connectionFactory)
    {
        ObjectPool connectionPool = mapConnectKeyToPool.get(key);
        if (connectionPool == null) {
            // use GenericObjectPool, which provides for resource limits
            connectionPool = new GenericObjectPool(
                null, // PoolableObjectFactory, can be null
                50, // max active
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool

            throw new DbcpException(e);
        }
    }
   
    synchronized protected ObjectPool getConnectionPool(String name) throws SQLException {
        ObjectPool pool = (ObjectPool)(_pools.get(name));
        if(null == pool) {
            InputStream in = this.getClass().getResourceAsStream(String.valueOf(name) + ".jocl");
            if(null != in) {
                JOCLContentHandler jocl = null;
                try {
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool

        }
    }

    public Connection connect(String url, Properties info) throws SQLException {
        if(acceptsURL(url)) {
            ObjectPool pool = getConnectionPool(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(Throwable e) {
                    throw new SQLNestedException("Connect failed", e);
                }
View Full Code Here

Examples of org.apache.commons.pool.ObjectPool

        } catch(IllegalArgumentException e) {
            // expected
        }

        try {
            ObjectPool pool = new GenericObjectPool(
                new SimpleFactory(),
                GenericObjectPool.DEFAULT_MAX_ACTIVE,
                Byte.MAX_VALUE,
                GenericObjectPool.DEFAULT_MAX_WAIT,
                GenericObjectPool.DEFAULT_MAX_IDLE,
View Full Code Here

Examples of org.apache.tapestry.services.ObjectPool

{
    public void testStoreAndGet()
    {
        String key = "POOLED-KEY";
        String pooled = "POOLED";
        ObjectPool p = new ObjectPoolImpl();

        assertNull(p.get(key));

        p.store(key, pooled);

        assertSame(pooled, p.get(key));

        assertNull(p.get(key));
    }
View Full Code Here

Examples of org.datanucleus.store.rdbms.datasource.dbcp.pool.ObjectPool

            throw new DbcpException(e);
        }
    }
   
    public synchronized ObjectPool getConnectionPool(String name) throws SQLException {
        ObjectPool pool = (ObjectPool)(_pools.get(name));
        if(null == pool) {
            InputStream in = this.getClass().getResourceAsStream(String.valueOf(name) + ".jocl");
            if (in == null) {
                in = Thread.currentThread().getContextClassLoader(
                        ).getResourceAsStream(String.valueOf(name) + ".jocl");
View Full Code Here

Examples of org.datanucleus.store.rdbms.datasource.dbcp.pool.ObjectPool

    public synchronized void registerPool(String name, ObjectPool pool) {
        _pools.put(name,pool);
    }

    public synchronized void closePool(String name) throws SQLException {
        ObjectPool pool = (ObjectPool) _pools.get(name);
        if (pool != null) {
            _pools.remove(name);
            try {
                pool.close();
            }
            catch (Exception e) {
                throw (SQLException) new SQLException("Error closing pool " + name).initCause(e);
            }
        }
View Full Code Here

Examples of org.datanucleus.store.rdbms.datasource.dbcp.pool.ObjectPool

        }
    }

    public Connection connect(String url, Properties info) throws SQLException {
        if(acceptsURL(url)) {
            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

Examples of org.datanucleus.store.rdbms.datasource.dbcp.pool.ObjectPool

     * @since 1.2.2
     */
    public void invalidateConnection(Connection conn) throws SQLException {
        if (conn instanceof PoolGuardConnectionWrapper) { // normal case
            PoolGuardConnectionWrapper pgconn = (PoolGuardConnectionWrapper) conn;
            ObjectPool pool = pgconn.pool;
            Connection delegate = pgconn.delegate;
            try {
                pool.invalidateObject(delegate);
            }
            catch (Exception e) {
            }
            pgconn.delegate = null;
        }
View Full Code Here

Examples of org.datanucleus.store.rdbms.datasource.dbcp.pool.ObjectPool

    /**
     * Get the number of active connections in the pool for a given user.
     */
    public int getNumActive(String username, String password) {
        ObjectPool pool = getPool(getPoolKey(username,password));
        return (pool == null) ? 0 : pool.getNumActive();
    }
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.