View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.http.conn;
29  
30  import java.util.concurrent.TimeUnit;
31  
32  import org.apache.http.conn.routing.HttpRoute;
33  import org.apache.http.conn.scheme.SchemeRegistry;
34  
35  /**
36   * Management interface for {@link ManagedClientConnection client connections}.
37   * The purpose of an HTTP connection manager is to serve as a factory for new
38   * HTTP connections, manage persistent connections and synchronize access to
39   * persistent connections making sure that only one thread of execution can
40   * have access to a connection at a time.
41   * <p>
42   * Implementations of this interface must be thread-safe. Access to shared
43   * data must be synchronized as methods of this interface may be executed
44   * from multiple threads.
45   *
46   * @since 4.0
47   *
48   * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
49   */
50  @Deprecated
51  public interface ClientConnectionManager {
52  
53      /**
54       * Obtains the scheme registry used by this manager.
55       *
56       * @return  the scheme registry, never {@code null}
57       */
58      SchemeRegistry getSchemeRegistry();
59  
60      /**
61       * Returns a new {@link ClientConnectionRequest}, from which a
62       * {@link ManagedClientConnection} can be obtained or the request can be
63       * aborted.
64       */
65      ClientConnectionRequest requestConnection(HttpRoute route, Object state);
66  
67      /**
68       * Releases a connection for use by others.
69       * You may optionally specify how long the connection is valid
70       * to be reused.  Values &lt;= 0 are considered to be valid forever.
71       * If the connection is not marked as reusable, the connection will
72       * not be reused regardless of the valid duration.
73       *
74       * If the connection has been released before,
75       * the call will be ignored.
76       *
77       * @param conn      the connection to release
78       * @param validDuration the duration of time this connection is valid for reuse
79       * @param timeUnit the unit of time validDuration is measured in
80       *
81       * @see #closeExpiredConnections()
82       */
83      void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit);
84  
85      /**
86       * Closes idle connections in the pool.
87       * Open connections in the pool that have not been used for the
88       * timespan given by the argument will be closed.
89       * Currently allocated connections are not subject to this method.
90       * Times will be checked with milliseconds precision
91       *
92       * All expired connections will also be closed.
93       *
94       * @param idletime  the idle time of connections to be closed
95       * @param timeUnit     the unit for the {@code idletime}
96       *
97       * @see #closeExpiredConnections()
98       */
99      void closeIdleConnections(long idletime, TimeUnit timeUnit);
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 }