mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/ClientConnectionManager.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial