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.io.IOException;
31  import java.net.InetAddress;
32  import java.net.Socket;
33  
34  import org.apache.http.HttpHost;
35  import org.apache.http.conn.scheme.SchemeSocketFactory;
36  import org.apache.http.params.HttpParams;
37  import org.apache.http.protocol.HttpContext;
38  
39  /**
40   * ClientConnectionOperator represents a strategy for creating
41   * {@link OperatedClientConnection} instances and updating the underlying
42   * {@link Socket} of those objects. Implementations will most likely make use
43   * of {@link SchemeSocketFactory}s to create {@link Socket} instances.
44   * <p>
45   * The methods in this interface allow the creation of plain and layered
46   * sockets. Creating a tunnelled connection through a proxy, however,
47   * is not within the scope of the operator.
48   * <p>
49   * Implementations of this interface must be thread-safe. Access to shared
50   * data must be synchronized as methods of this interface may be executed
51   * from multiple threads.
52   *
53   * @since 4.0
54   *
55   * @deprecated (4.3) replaced by {@link HttpClientConnectionManager}.
56   */
57  @Deprecated
58  public interface ClientConnectionOperator {
59  
60      /**
61       * Creates a new connection that can be operated.
62       *
63       * @return  a new, unopened connection for use with this operator
64       */
65      OperatedClientConnection createConnection();
66  
67      /**
68       * Opens a connection to the given target host.
69       *
70       * @param conn      the connection to open
71       * @param target    the target host to connect to
72       * @param local     the local address to route from, or
73       *                  <code>null</code> for the default
74       * @param context   the context for the connection
75       * @param params    the parameters for the connection
76       *
77       * @throws IOException      in case of a problem
78       */
79      void openConnection(OperatedClientConnection conn,
80                          HttpHost target,
81                          InetAddress local,
82                          HttpContext context,
83                          HttpParams params)
84          throws IOException;
85  
86      /**
87       * Updates a connection with a layered secure connection.
88       * The typical use of this method is to update a tunnelled plain
89       * connection (HTTP) to a secure TLS/SSL connection (HTTPS).
90       *
91       * @param conn      the open connection to update
92       * @param target    the target host for the updated connection.
93       *                  The connection must already be open or tunnelled
94       *                  to the host and port, but the scheme of the target
95       *                  will be used to create a layered connection.
96       * @param context   the context for the connection
97       * @param params    the parameters for the updated connection
98       *
99       * @throws IOException      in case of a problem
100      */
101     void updateSecureConnection(OperatedClientConnection conn,
102                                 HttpHost target,
103                                 HttpContext context,
104                                 HttpParams params)
105         throws IOException;
106 
107 }
108