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 $
4
* $Date: 2009-02-14 18:34:58 +0100 (Sat, 14 Feb 2009) $
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
15
* http://www.apache.org/licenses/LICENSE-2.0
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
23
* ====================================================================
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/>.
32
package org.apache.http.nio.reactor;
34
import java.io.IOException;
35
import java.net.SocketAddress;
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.
42
* Implementations of this interface are expected to be threading safe.
45
* @version $Revision: 744545 $
49
public interface SessionRequest {
52
* Returns socket address of the remote host.
54
* @return socket address of the remote host
56
SocketAddress getRemoteAddress();
59
* Returns local socket address.
61
* @return local socket address.
63
SocketAddress getLocalAddress();
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.
70
* @return attachment object.
72
Object getAttachment();
75
* Determines whether the request has been completed (either successfully
78
* @return <code>true</true> if the request has been completed,
79
* <code>false</true> if still pending.
81
boolean isCompleted();
84
* Returns {@link IOSession} instance created as a result of this request
85
* or <code>null</code> if the request is still pending.
87
* @return I/O session or <code>null</code> if the request is still pending.
89
IOSession getSession();
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.
96
* @return I/O exception or <code>null</code> if no error occurred to
99
IOException getException();
102
* Waits for completion of this session request.
104
* @throws InterruptedException in case the execution process was
107
void waitFor() throws InterruptedException;
110
* Sets connect timeout value in milliseconds.
112
* @param timeout connect timeout value in milliseconds.
114
void setConnectTimeout(int timeout);
117
* Returns connect timeout value in milliseconds.
119
* @return connect timeout value in milliseconds.
121
int getConnectTimeout();
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.