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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/ClientConnectionManager.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,114 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib.conn;
    1.32 +
    1.33 +import java.util.concurrent.TimeUnit;
    1.34 +
    1.35 +import ch.boye.httpclientandroidlib.conn.routing.HttpRoute;
    1.36 +import ch.boye.httpclientandroidlib.conn.scheme.SchemeRegistry;
    1.37 +
    1.38 +/**
    1.39 + * Management interface for {@link ManagedClientConnection client connections}.
    1.40 + * The purpose of an HTTP connection manager is to serve as a factory for new
    1.41 + * HTTP connections, manage persistent connections and synchronize access to
    1.42 + * persistent connections making sure that only one thread of execution can
    1.43 + * have access to a connection at a time.
    1.44 + * <p>
    1.45 + * Implementations of this interface must be thread-safe. Access to shared
    1.46 + * data must be synchronized as methods of this interface may be executed
    1.47 + * from multiple threads.
    1.48 + *
    1.49 + * @since 4.0
    1.50 + */
    1.51 +public interface ClientConnectionManager {
    1.52 +
    1.53 +    /**
    1.54 +     * Obtains the scheme registry used by this manager.
    1.55 +     *
    1.56 +     * @return  the scheme registry, never <code>null</code>
    1.57 +     */
    1.58 +    SchemeRegistry getSchemeRegistry();
    1.59 +
    1.60 +    /**
    1.61 +     * Returns a new {@link ClientConnectionRequest}, from which a
    1.62 +     * {@link ManagedClientConnection} can be obtained or the request can be
    1.63 +     * aborted.
    1.64 +     */
    1.65 +    ClientConnectionRequest requestConnection(HttpRoute route, Object state);
    1.66 +
    1.67 +    /**
    1.68 +     * Releases a connection for use by others.
    1.69 +     * You may optionally specify how long the connection is valid
    1.70 +     * to be reused.  Values <= 0 are considered to be valid forever.
    1.71 +     * If the connection is not marked as reusable, the connection will
    1.72 +     * not be reused regardless of the valid duration.
    1.73 +     *
    1.74 +     * If the connection has been released before,
    1.75 +     * the call will be ignored.
    1.76 +     *
    1.77 +     * @param conn      the connection to release
    1.78 +     * @param validDuration the duration of time this connection is valid for reuse
    1.79 +     * @param timeUnit the unit of time validDuration is measured in
    1.80 +     *
    1.81 +     * @see #closeExpiredConnections()
    1.82 +     */
    1.83 +    void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit);
    1.84 +
    1.85 +    /**
    1.86 +     * Closes idle connections in the pool.
    1.87 +     * Open connections in the pool that have not been used for the
    1.88 +     * timespan given by the argument will be closed.
    1.89 +     * Currently allocated connections are not subject to this method.
    1.90 +     * Times will be checked with milliseconds precision
    1.91 +     *
    1.92 +     * All expired connections will also be closed.
    1.93 +     *
    1.94 +     * @param idletime  the idle time of connections to be closed
    1.95 +     * @param tunit     the unit for the <code>idletime</code>
    1.96 +     *
    1.97 +     * @see #closeExpiredConnections()
    1.98 +     */
    1.99 +    void closeIdleConnections(long idletime, TimeUnit tunit);
   1.100 +
   1.101 +    /**
   1.102 +     * Closes all expired connections in the pool.
   1.103 +     * Open connections in the pool that have not been used for
   1.104 +     * the timespan defined when the connection was released will be closed.
   1.105 +     * Currently allocated connections are not subject to this method.
   1.106 +     * Times will be checked with milliseconds precision.
   1.107 +     */
   1.108 +    void closeExpiredConnections();
   1.109 +
   1.110 +    /**
   1.111 +     * Shuts down this connection manager and releases allocated resources.
   1.112 +     * This includes closing all connections, whether they are currently
   1.113 +     * used or not.
   1.114 +     */
   1.115 +    void shutdown();
   1.116 +
   1.117 +}

mercurial