|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.impl.nio.reactor.IOSessionImpl
@Contract(threading=SAFE) public class IOSessionImpl
Default implementation of IOSession
.
Field Summary |
---|
Fields inherited from interface org.apache.http.nio.reactor.IOSession |
---|
ACTIVE, ATTACHMENT_KEY, CLOSED, CLOSING |
Constructor Summary | |
---|---|
IOSessionImpl(SelectionKey key,
org.apache.http.impl.nio.reactor.InterestOpsCallback interestOpsCallback,
SessionClosedCallback sessionClosedCallback)
Creates new instance of IOSessionImpl. |
|
IOSessionImpl(SelectionKey key,
SessionClosedCallback sessionClosedCallback)
Creates new instance of IOSessionImpl. |
Method Summary | |
---|---|
ByteChannel |
channel()
Returns the underlying I/O channel associated with this session. |
void |
clearEvent(int op)
Clears interest in a particular I/O event type by updating the event mask associated with the session. |
void |
close()
Terminates the session gracefully and closes the underlying I/O channel. |
Object |
getAttribute(String name)
Returns the value of the attribute with the given name. |
int |
getEventMask()
Returns mask of I/O evens this session declared interest in. |
long |
getLastAccessTime()
|
long |
getLastReadTime()
|
long |
getLastWriteTime()
|
SocketAddress |
getLocalAddress()
Returns local address. |
SocketAddress |
getRemoteAddress()
Returns address of the remote peer. |
Socket |
getSocket()
Return the underlying socket |
int |
getSocketTimeout()
Returns value of the socket timeout in milliseconds. |
long |
getStartedTime()
|
int |
getStatus()
Returns status of the session: |
boolean |
hasBufferedInput()
Determines if the input buffer associated with the session contains data. |
boolean |
hasBufferedOutput()
Determines if the output buffer associated with the session contains data. |
boolean |
isClosed()
Determines if the session has been terminated. |
Object |
removeAttribute(String name)
Removes attribute with the given name. |
void |
setAttribute(String name,
Object obj)
This method can be used to associate a particular object with the session by the given attribute name. |
void |
setBufferStatus(SessionBufferStatus bufferStatus)
Quite often I/O sessions need to maintain internal I/O buffers in order to transform input / output data prior to returning it to the consumer or writing it to the underlying channel. |
void |
setEvent(int op)
Declares interest in a particular I/O event type by updating the event mask associated with the session. |
void |
setEventMask(int ops)
Declares interest in I/O event notifications by setting the event mask associated with the session |
void |
setSocketTimeout(int timeout)
Sets value of the socket timeout in milliseconds. |
void |
shutdown()
Terminates the session by shutting down the underlying I/O channel. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IOSessionImpl(SelectionKey key, org.apache.http.impl.nio.reactor.InterestOpsCallback interestOpsCallback, SessionClosedCallback sessionClosedCallback)
key
- the selection key.interestOpsCallback
- interestOps callback.sessionClosedCallback
- session closed callback.public IOSessionImpl(SelectionKey key, SessionClosedCallback sessionClosedCallback)
key
- the selection key.sessionClosedCallback
- session closed callback.Method Detail |
---|
public ByteChannel channel()
IOSession
channel
in interface IOSession
public SocketAddress getLocalAddress()
IOSession
getLocalAddress
in interface IOSession
public SocketAddress getRemoteAddress()
IOSession
getRemoteAddress
in interface IOSession
public int getEventMask()
IOSession
getEventMask
in interface IOSession
public void setEventMask(int ops)
IOSession
setEventMask
in interface IOSession
ops
- new I/O event mask.public void setEvent(int op)
IOSession
setEvent
in interface IOSession
op
- I/O event type.public void clearEvent(int op)
IOSession
clearEvent
in interface IOSession
op
- I/O event type.public int getSocketTimeout()
IOSession
0
signifies the session cannot time out.
getSocketTimeout
in interface IOSession
public void setSocketTimeout(int timeout)
IOSession
0
signifies the session cannot time out.
setSocketTimeout
in interface IOSession
timeout
- socket timeout.public void close()
IOSession
close
in interface IOSession
public int getStatus()
IOSession
IOSession.ACTIVE
: session is active.
IOSession.CLOSING
: session is being closed.
IOSession.CLOSED
: session has been terminated.
getStatus
in interface IOSession
public boolean isClosed()
IOSession
isClosed
in interface IOSession
true
if the session has been terminated,
false
otherwise.public void shutdown()
IOSession
shutdown
in interface IOSession
public boolean hasBufferedInput()
IOSession
hasBufferedInput
in interface IOSession
true
if the session input buffer contains data,
false
otherwise.public boolean hasBufferedOutput()
IOSession
hasBufferedOutput
in interface IOSession
true
if the session output buffer contains data,
false
otherwise.public void setBufferStatus(SessionBufferStatus bufferStatus)
IOSession
I/O sessions can be made aware of the status of external session buffers
using the SessionBufferStatus
interface.
setBufferStatus
in interface IOSession
public Object getAttribute(String name)
IOSession
null
if not set.
The value of the session attachment object can be obtained using
IOSession.ATTACHMENT_KEY
name.
getAttribute
in interface IOSession
name
- name of the attribute.
IOSession.setAttribute(String, Object)
public Object removeAttribute(String name)
IOSession
removeAttribute
in interface IOSession
name
- name of the attribute to be removed.
IOSession.setAttribute(String, Object)
public void setAttribute(String name, Object obj)
IOSession
I/O sessions are not bound to an execution thread, therefore one cannot use the context of the thread to store a session's state. All details about a particular session must be stored within the session itself.
setAttribute
in interface IOSession
name
- name of the attribute.obj
- value of the attribute.public long getStartedTime()
public long getLastReadTime()
public long getLastWriteTime()
public long getLastAccessTime()
public String toString()
toString
in class Object
public Socket getSocket()
SocketAccessor
getSocket
in interface SocketAccessor
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |