~ubuntu-branches/ubuntu/trusty/httpcomponents-core/trusty

« back to all changes in this revision

Viewing changes to httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionRequest.java

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2010-06-12 08:37:34 UTC
  • Revision ID: james.westby@ubuntu.com-20100612083734-1y8kp6qm4sjk60az
Tags: upstream-4.0.1
ImportĀ upstreamĀ versionĀ 4.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionRequest.java $
 
3
 * $Revision: 744545 $
 
4
 * $Date: 2009-02-14 18:34:58 +0100 (Sat, 14 Feb 2009) $
 
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
 
 
32
package org.apache.http.nio.reactor;
 
33
 
 
34
import java.io.IOException;
 
35
import java.net.SocketAddress;
 
36
 
 
37
/**
 
38
 * SessionRequest interface represents a request to establish a new connection
 
39
 * (or session) to a remote host. It can be used to monitor the status of the 
 
40
 * request, to block waiting for its completion, or to cancel the request. 
 
41
 * <p>
 
42
 * Implementations of this interface are expected to be threading safe.
 
43
 * 
 
44
 *
 
45
 * @version $Revision: 744545 $
 
46
 *
 
47
 * @since 4.0
 
48
 */
 
49
public interface SessionRequest {
 
50
 
 
51
    /**
 
52
     * Returns socket address of the remote host.
 
53
     * 
 
54
     * @return socket address of the remote host
 
55
     */
 
56
    SocketAddress getRemoteAddress();
 
57
    
 
58
    /**
 
59
     * Returns local socket address.
 
60
     * 
 
61
     * @return local socket address.
 
62
     */
 
63
    SocketAddress getLocalAddress();
 
64
    
 
65
    /**
 
66
     * Returns attachment object will be added to the session's context upon 
 
67
     * initialization. This object can be used to pass an initial processing 
 
68
     * state to the protocol handler.
 
69
     * 
 
70
     * @return attachment object.
 
71
     */
 
72
    Object getAttachment();
 
73
    
 
74
    /**
 
75
     * Determines whether the request has been completed (either successfully
 
76
     * or unsuccessfully).
 
77
     * 
 
78
     * @return <code>true</true> if the request has been completed,
 
79
     *  <code>false</true> if still pending.
 
80
     */
 
81
    boolean isCompleted();
 
82
    
 
83
    /**
 
84
     * Returns {@link IOSession} instance created as a result of this request
 
85
     * or <code>null</code> if the request is still pending.
 
86
     * 
 
87
     * @return I/O session or <code>null</code> if the request is still pending.
 
88
     */
 
89
    IOSession getSession();
 
90
    
 
91
    /**
 
92
     * Returns {@link IOException} instance if the request could not be 
 
93
     * successfully executed due to an I/O error or <code>null</code> if no
 
94
     * error occurred to this point.
 
95
     * 
 
96
     * @return I/O exception or <code>null</code> if no error occurred to 
 
97
     * this point.
 
98
     */
 
99
    IOException getException();
 
100
 
 
101
    /**
 
102
     * Waits for completion of this session request.
 
103
     * 
 
104
     * @throws InterruptedException in case the execution process was 
 
105
     *   interrupted.
 
106
     */
 
107
    void waitFor() throws InterruptedException;
 
108
    
 
109
    /**
 
110
     * Sets connect timeout value in milliseconds.
 
111
     * 
 
112
     * @param timeout connect timeout value in milliseconds.
 
113
     */
 
114
    void setConnectTimeout(int timeout);
 
115
    
 
116
    /**
 
117
     * Returns connect timeout value in milliseconds.
 
118
     * 
 
119
     * @return connect timeout value in milliseconds.
 
120
     */
 
121
    int getConnectTimeout();
 
122
    
 
123
    /**
 
124
     * Cancels the request. Invocation of this method will set the status of 
 
125
     * the request to completed and will unblock threads blocked in 
 
126
     * the {{@link #waitFor()}} method.
 
127
     */
 
128
    void cancel();
 
129
    
 
130
}