@Contract(threading=SAFE_CONDITIONAL) public class SessionRequestImpl extends java.lang.Object implements SessionRequest
SessionRequest.| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object |
attachment |
private SessionRequestCallback |
callback |
private boolean |
completed |
private int |
connectTimeout |
private java.io.IOException |
exception |
private java.nio.channels.SelectionKey |
key |
private java.net.SocketAddress |
localAddress |
private java.net.SocketAddress |
remoteAddress |
private IOSession |
session |
| Constructor and Description |
|---|
SessionRequestImpl(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
java.lang.Object attachment,
SessionRequestCallback callback) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the request.
|
void |
completed(IOSession session) |
void |
failed(java.io.IOException exception) |
java.lang.Object |
getAttachment()
Returns attachment object will be added to the session's context upon
initialization.
|
int |
getConnectTimeout()
Returns connect timeout value in milliseconds.
|
java.io.IOException |
getException()
Returns
IOException instance if the request could not be
successfully executed due to an I/O error or null if no
error occurred to this point. |
java.net.SocketAddress |
getLocalAddress()
Returns local socket address.
|
java.net.SocketAddress |
getRemoteAddress()
Returns socket address of the remote host.
|
IOSession |
getSession()
Returns
IOSession instance created as a result of this request
or null if the request is still pending. |
boolean |
isCompleted()
Determines whether the request has been completed (either successfully
or unsuccessfully).
|
void |
setConnectTimeout(int timeout)
Sets connect timeout value in milliseconds.
|
protected void |
setKey(java.nio.channels.SelectionKey key) |
void |
timeout() |
void |
waitFor()
Waits for completion of this session request.
|
private volatile boolean completed
private volatile java.nio.channels.SelectionKey key
private final java.net.SocketAddress remoteAddress
private final java.net.SocketAddress localAddress
private final java.lang.Object attachment
private final SessionRequestCallback callback
private volatile int connectTimeout
private volatile IOSession session
private volatile java.io.IOException exception
public SessionRequestImpl(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
java.lang.Object attachment,
SessionRequestCallback callback)
public java.net.SocketAddress getRemoteAddress()
SessionRequestgetRemoteAddress in interface SessionRequestpublic java.net.SocketAddress getLocalAddress()
SessionRequestgetLocalAddress in interface SessionRequestpublic java.lang.Object getAttachment()
SessionRequestgetAttachment in interface SessionRequestpublic boolean isCompleted()
SessionRequestisCompleted in interface SessionRequesttrue if the request has been completed,
false if still pending.protected void setKey(java.nio.channels.SelectionKey key)
public void waitFor()
throws java.lang.InterruptedException
SessionRequestwaitFor in interface SessionRequestjava.lang.InterruptedException - in case the execution process was
interrupted.public IOSession getSession()
SessionRequestIOSession instance created as a result of this request
or null if the request is still pending.getSession in interface SessionRequestnull if the request is still pending.public java.io.IOException getException()
SessionRequestIOException instance if the request could not be
successfully executed due to an I/O error or null if no
error occurred to this point.getException in interface SessionRequestnull if no error occurred to
this point.public void completed(IOSession session)
public void failed(java.io.IOException exception)
public void timeout()
public int getConnectTimeout()
SessionRequestgetConnectTimeout in interface SessionRequestpublic void setConnectTimeout(int timeout)
SessionRequestsetConnectTimeout in interface SessionRequesttimeout - connect timeout value in milliseconds.public void cancel()
SessionRequestSessionRequest.waitFor()} method.cancel in interface SessionRequest