001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027 028package org.apache.http.conn; 029 030import java.util.concurrent.TimeUnit; 031 032import org.apache.http.conn.routing.HttpRoute; 033import org.apache.http.conn.scheme.SchemeRegistry; 034 035/** 036 * Management interface for {@link ManagedClientConnection client connections}. 037 * The purpose of an HTTP connection manager is to serve as a factory for new 038 * HTTP connections, manage persistent connections and synchronize access to 039 * persistent connections making sure that only one thread of execution can 040 * have access to a connection at a time. 041 * <p> 042 * Implementations of this interface must be thread-safe. Access to shared 043 * data must be synchronized as methods of this interface may be executed 044 * from multiple threads. 045 * 046 * @since 4.0 047 * 048 * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}. 049 */ 050@Deprecated 051public interface ClientConnectionManager { 052 053 /** 054 * Obtains the scheme registry used by this manager. 055 * 056 * @return the scheme registry, never {@code null} 057 */ 058 SchemeRegistry getSchemeRegistry(); 059 060 /** 061 * Returns a new {@link ClientConnectionRequest}, from which a 062 * {@link ManagedClientConnection} can be obtained or the request can be 063 * aborted. 064 */ 065 ClientConnectionRequest requestConnection(HttpRoute route, Object state); 066 067 /** 068 * Releases a connection for use by others. 069 * You may optionally specify how long the connection is valid 070 * to be reused. Values <= 0 are considered to be valid forever. 071 * If the connection is not marked as reusable, the connection will 072 * not be reused regardless of the valid duration. 073 * 074 * If the connection has been released before, 075 * the call will be ignored. 076 * 077 * @param conn the connection to release 078 * @param validDuration the duration of time this connection is valid for reuse 079 * @param timeUnit the unit of time validDuration is measured in 080 * 081 * @see #closeExpiredConnections() 082 */ 083 void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit); 084 085 /** 086 * Closes idle connections in the pool. 087 * Open connections in the pool that have not been used for the 088 * timespan given by the argument will be closed. 089 * Currently allocated connections are not subject to this method. 090 * Times will be checked with milliseconds precision 091 * 092 * All expired connections will also be closed. 093 * 094 * @param idletime the idle time of connections to be closed 095 * @param tunit the unit for the {@code idletime} 096 * 097 * @see #closeExpiredConnections() 098 */ 099 void closeIdleConnections(long idletime, TimeUnit tunit); 100 101 /** 102 * Closes all expired connections in the pool. 103 * Open connections in the pool that have not been used for 104 * the timespan defined when the connection was released will be closed. 105 * Currently allocated connections are not subject to this method. 106 * Times will be checked with milliseconds precision. 107 */ 108 void closeExpiredConnections(); 109 110 /** 111 * Shuts down this connection manager and releases allocated resources. 112 * This includes closing all connections, whether they are currently 113 * used or not. 114 */ 115 void shutdown(); 116 117}