com.ning.http.client.providers.grizzly.ConnectionPool Maven / Gradle / Ivy
/*
* Copyright 2010 Ning, Inc.
*
* Ning licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package com.ning.http.client.providers.grizzly;
import org.glassfish.grizzly.Connection;
/**
* An interface used by an {@link AsyncHttpProvider} for caching http connections.
*/
public interface ConnectionPool {
/**
* Add a connection tpo the pool
*
* @param uri a uri used to retrieve the cached connection
* @param connection an I/O connection
* @return true if added.
*/
boolean offer(String uri, Connection connection);
/**
* Remove the connection associated with the uri.
*
* @param uri the uri used when invoking addConnection
* @return the connection associated with the uri
*/
Connection poll(String uri);
/**
* Remove all connections from the cache. A connection might have been associated with several uri.
*
* @param connection a connection
* @return the true if the connection has been removed
*/
boolean removeAll(Connection connection);
/**
* Return true if a connection can be cached. A implementation can decide based on some rules to allow caching
* Calling this method is equivalent of checking the returned value of {@link ConnectionPool#offer(Object, Object)}
*
* @return true if a connection can be cached.
*/
boolean canCacheConnection();
/**
* Destroy all connections that has been cached by this instance.
*/
void destroy();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy