public abstract class AbstractIoSession extends Object implements IoSession, ReadFilterChainController, WriteFilterChainController
IoSession shared with all the different transports.IoSession.SessionState| Modifier and Type | Field and Description |
|---|---|
protected IoSessionConfig |
config
The session config
|
protected IdleChecker |
idleChecker
the
IdleChecker in charge of detecting idle event for this session |
protected boolean |
secured
Tells if the session is secured or not
|
protected IoSession.SessionState |
state
The session's state : one of CREATED, CONNECTED, CLOSING, CLOSED, SECURING, CONNECTED_SECURED
|
SSL_HELPER| Constructor and Description |
|---|
AbstractIoSession(IoService service,
IdleChecker idleChecker)
|
| Modifier and Type | Method and Description |
|---|---|
void |
callReadNextFilter(Object message) |
void |
callWriteNextFilter(WriteRequest message)
process session message received event using the filter chain.
|
void |
changeState(IoSession.SessionState to)
Changes the session's state from the current state to a new state.
|
<T> T |
getAttribute(AttributeKey<T> key)
Returns the value of the user-defined attribute for the given
key.If the there is no attribute with
the specified key null will be returned. |
<T> T |
getAttribute(AttributeKey<T> key,
T defaultValue)
Returns the value of the user-defined attribute for the given
key.If the there is no attribute with
the specified key the defaultValue will be returned. |
Set<AttributeKey<?>> |
getAttributeKeys()
|
long |
getCreationTime()
The session's creation time.
|
long |
getId()
The unique identifier of this session.
|
long |
getLastIoTime()
Returns the time in millisecond when I/O occurred lastly (either read or write).
|
long |
getLastReadTime()
Returns the time in millisecond when the last I/O read occurred.
|
long |
getLastWriteTime()
Returns the time in millisecond when the last I/O write occurred.
|
long |
getReadBytes()
Gets the total number of bytes read for this session since it was created.
|
IoService |
getService()
Gets the service this session is attached to.
|
long |
getWrittenBytes()
Gets the total number of bytes written for this session since it was created.
|
void |
incrementWrittenBytes(int bytesCount)
To be called by the internal plumber when some bytes are written on the socket
|
void |
initSecure(SSLContext sslContext)
Initializes the SSL/TLS environment for this session.
|
boolean |
isClosed()
Tells if the session is currently closed.
|
boolean |
isClosing()
Tells if the session is being closed.
|
boolean |
isConnected()
Tells if the session is currently connected and able to process incoming requests and to send outgoing responses.
|
boolean |
isConnectedSecured()
Tells if the session is using SSL/TLS.
|
boolean |
isCreated()
Tells if the session is created.
|
boolean |
isSecured()
Tells if the session is belonging to a secured connection.
|
boolean |
isSecuring()
Tells if the session is processing a SSL/TLS handshake.
|
protected void |
processException(Exception t)
send a caught exception to the
IoHandler (if any) |
void |
processMessageReceived(ByteBuffer message)
process session message received event using the filter chain.
|
void |
processMessageSent(Object highLevelMessage) |
void |
processMessageWriting(WriteRequest writeRequest,
IoFuture<Void> future)
process session message writing event using the filter chain.
|
void |
processSessionClosed()
process session closed event using the filter chain.
|
void |
processSessionIdle(IdleStatus status)
process session idle event using the filter chain.
|
void |
processSessionOpen()
process session open event using the filter chain.
|
<T> T |
removeAttribute(AttributeKey<T> key)
Removes the specified Attribute from this container.
|
<T> T |
setAttribute(AttributeKey<? extends T> key,
T value)
Sets a user-defined attribute.
|
void |
setSecured(boolean secured) |
String |
toString() |
void |
write(Object message)
Enqueue a message for writing.
|
IoFuture<Void> |
writeWithFuture(Object message)
Same as
IoSession.write(Object), but provide a IoFuture for tracking the completion of this
write. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, enqueueWriteRequest, getConfig, getLocalAddress, getRemoteAddress, isReadSuspended, isWriteSuspended, resumeRead, resumeWrite, suspendRead, suspendWriteprotected final IdleChecker idleChecker
IdleChecker in charge of detecting idle event for this sessionprotected IoSessionConfig config
protected volatile IoSession.SessionState state
protected volatile boolean secured
public AbstractIoSession(IoService service, IdleChecker idleChecker)
service - the service this session is associated withidleChecker - the checker for idle sessionpublic boolean isClosed()
public boolean isClosing()
public boolean isConnected()
isConnected in interface IoSessiontrue if this session is connected with remote peer.public boolean isCreated()
public boolean isSecuring()
isSecuring in interface IoSessiontrue if and only if this session is processing a SSL/TLS handshake.public boolean isConnectedSecured()
isConnectedSecured in interface IoSessiontrue if and only if this session is exchanging data over a SSL/TLS connectionpublic void changeState(IoSession.SessionState to)
changeState in interface IoSessionto - The final SessionStatepublic boolean isSecured()
public void setSecured(boolean secured)
public void initSecure(SSLContext sslContext)
initSecure in interface IoSessionsslContext - The SLLCOntext instance to use.public long getId()
public long getCreationTime()
getCreationTime in interface IoSessionpublic long getReadBytes()
getReadBytes in interface IoSessionpublic void incrementWrittenBytes(int bytesCount)
bytesCount - number of extra bytes writtenpublic long getWrittenBytes()
getWrittenBytes in interface IoSessionpublic long getLastReadTime()
getLastReadTime in interface IoSessionpublic long getLastWriteTime()
getLastWriteTime in interface IoSessionpublic final long getLastIoTime()
getLastIoTime in interface IoSessionpublic IoService getService()
getService in interface IoSessionIoService which provides IoSession to this session.public final <T> T getAttribute(AttributeKey<T> key, T defaultValue)
key.If the there is no attribute with
the specified key the defaultValue will be returned.getAttribute in interface IoSessionkey - the attribute's key, must not be nullIllegalArgumentException - if key==nullsetAttribute(AttributeKey, Object)public final <T> T getAttribute(AttributeKey<T> key)
key.If the there is no attribute with
the specified key null will be returned.getAttribute in interface IoSessionkey - the attribute's key, must not be nullnull if there is no attribute with the specified keyIllegalArgumentException - if key==nullsetAttribute(AttributeKey, Object)public final <T> T setAttribute(AttributeKey<? extends T> key, T value)
value is null the attribute will be removed from
this IoSession.setAttribute in interface IoSessionkey - the attribute's key, must not be nullvalue - the attribute's value, null to remove the attributenull if there is no previous valueIllegalArgumentException - key==nullvalue is not null and not an instance of type that is specified in by the
given key (see AttributeKey.getType())getAttribute(AttributeKey)public Set<AttributeKey<?>> getAttributeKeys()
Set of all Keys of this IoSession. If this IoSession contains no
attributes an empty Set will be returned.getAttributeKeys in interface IoSessionnullCollections.unmodifiableSet(Set)public <T> T removeAttribute(AttributeKey<T> key)
null will be
rutrnen if there is no such attribute in this container.setAttribute(key,null).removeAttribute in interface IoSessionkey - of the attribute to be removed,must not be nullnull if this container doesn't contain the specified attributeIllegalArgumentException - if key==nullpublic void write(Object message)
SelectorLooppublic IoFuture<Void> writeWithFuture(Object message)
IoSession.write(Object), but provide a IoFuture for tracking the completion of this
write.writeWithFuture in interface IoSessionmessage - the message to be processed and writtenIoFuture for tracking this asynchronous operationprotected void processException(Exception t)
IoHandler (if any)public void processSessionOpen()
SelectorLoop .public void processSessionClosed()
SelectorLoop .public void processSessionIdle(IdleStatus status)
SelectorLoop .public void processMessageReceived(ByteBuffer message)
SelectorLoop .message - the received messagepublic void processMessageWriting(WriteRequest writeRequest, IoFuture<Void> future)
SelectorLoop .message - the wrote message, should be transformed into ByteBuffer at the end of the filter chainpublic void processMessageSent(Object highLevelMessage)
public void callWriteNextFilter(WriteRequest message)
SelectorLoop .callWriteNextFilter in interface WriteFilterChainControllermessage - the received messagepublic void callReadNextFilter(Object message)
callReadNextFilter in interface ReadFilterChainControllerCopyright © 2009–2013 Apache MINA Project. All rights reserved.