Package org.apache.http.impl.nio.reactor
Class SessionRequestImpl
java.lang.Object
org.apache.http.impl.nio.reactor.SessionRequestImpl
- All Implemented Interfaces:
SessionRequest
@Contract(threading=SAFE_CONDITIONAL)
public class SessionRequestImpl
extends Object
implements SessionRequest
Default implementation of
SessionRequest
.- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object
private final SessionRequestCallback
private int
private IOException
private SelectionKey
private final SocketAddress
private final SocketAddress
private IOSession
private final AtomicReference
<SessionRequestImpl.SessionRequestState> -
Constructor Summary
ConstructorsConstructorDescriptionSessionRequestImpl
(SocketAddress remoteAddress, SocketAddress localAddress, Object attachment, SessionRequestCallback callback) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the request.void
void
failed
(IOException exception) Returns attachment object will be added to the session's context upon initialization.int
Returns connect timeout value in milliseconds.ReturnsIOException
instance if the request could not be successfully executed due to an I/O error ornull
if no error occurred to this point.Returns local socket address.Returns socket address of the remote host.ReturnsIOSession
instance created as a result of this request ornull
if the request is still pending.boolean
Determines whether the request has been completed (either successfully or unsuccessfully).(package private) boolean
void
setConnectTimeout
(int timeout) Sets connect timeout value in milliseconds.protected void
setKey
(SelectionKey key) void
timeout()
void
waitFor()
Waits for completion of this session request.
-
Field Details
-
remoteAddress
-
localAddress
-
attachment
-
callback
-
state
-
key
-
connectTimeout
private volatile int connectTimeout -
session
-
exception
-
-
Constructor Details
-
SessionRequestImpl
public SessionRequestImpl(SocketAddress remoteAddress, SocketAddress localAddress, Object attachment, SessionRequestCallback callback)
-
-
Method Details
-
getRemoteAddress
Description copied from interface:SessionRequest
Returns socket address of the remote host.- Specified by:
getRemoteAddress
in interfaceSessionRequest
- Returns:
- socket address of the remote host
-
getLocalAddress
Description copied from interface:SessionRequest
Returns local socket address.- Specified by:
getLocalAddress
in interfaceSessionRequest
- Returns:
- local socket address.
-
getAttachment
Description copied from interface:SessionRequest
Returns attachment object will be added to the session's context upon initialization. This object can be used to pass an initial processing state to the protocol handler.- Specified by:
getAttachment
in interfaceSessionRequest
- Returns:
- attachment object.
-
isCompleted
public boolean isCompleted()Description copied from interface:SessionRequest
Determines whether the request has been completed (either successfully or unsuccessfully).- Specified by:
isCompleted
in interfaceSessionRequest
- Returns:
true
if the request has been completed,false
if still pending.
-
isTerminated
boolean isTerminated() -
setKey
-
waitFor
Description copied from interface:SessionRequest
Waits for completion of this session request.- Specified by:
waitFor
in interfaceSessionRequest
- Throws:
InterruptedException
- in case the execution process was interrupted.
-
getSession
Description copied from interface:SessionRequest
ReturnsIOSession
instance created as a result of this request ornull
if the request is still pending.- Specified by:
getSession
in interfaceSessionRequest
- Returns:
- I/O session or
null
if the request is still pending.
-
getException
Description copied from interface:SessionRequest
ReturnsIOException
instance if the request could not be successfully executed due to an I/O error ornull
if no error occurred to this point.- Specified by:
getException
in interfaceSessionRequest
- Returns:
- I/O exception or
null
if no error occurred to this point.
-
completed
-
failed
-
timeout
public void timeout() -
getConnectTimeout
public int getConnectTimeout()Description copied from interface:SessionRequest
Returns connect timeout value in milliseconds.- Specified by:
getConnectTimeout
in interfaceSessionRequest
- Returns:
- connect timeout value in milliseconds.
-
setConnectTimeout
public void setConnectTimeout(int timeout) Description copied from interface:SessionRequest
Sets connect timeout value in milliseconds.- Specified by:
setConnectTimeout
in interfaceSessionRequest
- Parameters:
timeout
- connect timeout value in milliseconds.
-
cancel
public void cancel()Description copied from interface:SessionRequest
Cancels the request. Invocation of this method will set the status of the request to completed and will unblock threads blocked in the {SessionRequest.waitFor()
} method.- Specified by:
cancel
in interfaceSessionRequest
-