ClientConnectionOperator.java revision 417f3b92ba4549b2f22340e3107d869d2b9c5bb8
1/*
2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionOperator.java $
3 * $Revision: 645850 $
4 * $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
5 *
6 * ====================================================================
7 * Licensed to the Apache Software Foundation (ASF) under one
8 * or more contributor license agreements.  See the NOTICE file
9 * distributed with this work for additional information
10 * regarding copyright ownership.  The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License.  You may obtain a copy of the License at
14 *
15 *   http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied.  See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 * ====================================================================
24 *
25 * This software consists of voluntary contributions made by many
26 * individuals on behalf of the Apache Software Foundation.  For more
27 * information on the Apache Software Foundation, please see
28 * <http://www.apache.org/>.
29 *
30 */
31
32package org.apache.http.conn;
33
34import java.io.IOException;
35import java.net.InetAddress;
36
37import org.apache.http.HttpHost;
38import org.apache.http.conn.scheme.SocketFactory;
39import org.apache.http.params.HttpParams;
40import org.apache.http.protocol.HttpContext;
41
42
43
44/**
45 * Interface for opening {@link OperatedClientConnection connections}.
46 * This interface encapsulates the logic to create sockets and to
47 * open or update the connection with the new socket.
48 * Implementations will most likely make use of
49 * {@link SocketFactory socket factories}.
50 * <br/>
51 * The methods in this interface allow the creation of plain and layered
52 * sockets. Creating a tunnelled connection through a proxy, however,
53 * is not within the scope of the operator.
54 *
55 * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
56 *
57 *
58 * <!-- empty lines to avoid svn diff problems -->
59 * @version   $Revision: 645850 $ $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
60 *
61 * @since 4.0
62 */
63public interface ClientConnectionOperator {
64
65
66    /**
67     * Creates a new connection that can be operated.
68     *
69     * @return  a new, unopened connection for use with this operator
70     */
71    OperatedClientConnection createConnection()
72        ;
73
74
75    /**
76     * Opens a connection to the given target host.
77     *
78     * @param conn      the connection to open
79     * @param target    the target host to connect to
80     * @param local     the local address to route from, or
81     *                  <code>null</code> for the default
82     * @param context   the context for the connection
83     * @param params    the parameters for the connection
84     *
85     * @throws IOException      in case of a problem
86     */
87    void openConnection(OperatedClientConnection conn,
88                        HttpHost target,
89                        InetAddress local,
90                        HttpContext context,
91                        HttpParams params)
92        throws IOException
93        ;
94
95
96    /**
97     * Updates a connection with a layered secure connection.
98     * The typical use of this method is to update a tunnelled plain
99     * connection (HTTP) to a secure TLS/SSL connection (HTTPS).
100     *
101     * @param conn      the open connection to update
102     * @param target    the target host for the updated connection.
103     *                  The connection must already be open or tunnelled
104     *                  to the host and port, but the scheme of the target
105     *                  will be used to create a layered connection.
106     * @param context   the context for the connection
107     * @param params    the parameters for the updated connection
108     *
109     * @throws IOException      in case of a problem
110     */
111    void updateSecureConnection(OperatedClientConnection conn,
112                                HttpHost target,
113                                HttpContext context,
114                                HttpParams params)
115        throws IOException
116        ;
117
118
119} // interface ClientConnectionOperator
120
121