org.apache.mina.common
Interface Session

All Known Subinterfaces:
IoSession, ProtocolSession
All Known Implementing Classes:
BaseSession, IoProtocolSession

public interface Session

A handle which represents connection between two endpoints regardless of transport types.

Session provides user-defined attributes. User-defined attributes are application-specific data which is associated with a session. It often contains objects that represents the state of a higher-level protocol and becomes a way to exchange data between filters and handlers.

Version:
$Rev: 264677 $, $Date: 2005-08-30 11:44:35 +0900 $
Author:
Trustin Lee (trustin@apache.org)

Method Summary
 void close()
          Closes this session immediately.
 void close(boolean wait)
          Closes this session immediately.
 Object getAttachment()
          Returns an attachment of this session.
 Object getAttribute(String key)
          Returns the value of user-defined attribute of this session.
 Set getAttributeKeys()
          Returns the set of keys of all user-defined attributes.
 SessionConfig getConfig()
          Returns the configuration of this session.
 long getLastIoTime()
          Returns the time in millis when I/O occurred lastly.
 long getLastReadTime()
          Returns the time in millis when read operation occurred lastly.
 long getLastWriteTime()
          Returns the time in millis when write operation occurred lastly.
 SocketAddress getLocalAddress()
          Returns the socket address of local machine which is associated with this session.
 long getReadBytes()
          Returns the total number of bytes which were read from this session.
 SocketAddress getRemoteAddress()
          Returns the socket address of remote peer.
 int getScheduledWriteRequests()
          Returns the number of write requests which are scheduled to be written to this session.
 TransportType getTransportType()
          Returns transport type of this session.
 long getWrittenBytes()
          Returns the total number of bytes which were written to this session.
 long getWrittenWriteRequests()
          Returns the total number of write requests which were written to this session.
 boolean isConnected()
          Returns true if this session is connected with remote peer.
 boolean isIdle(IdleStatus status)
          Returns true if this session is idle for the specified IdleStatus.
 Object removeAttribute(String key)
          Removes a user-defined attribute with the specified key.
 Object setAttachment(Object attachment)
          Sets an attachment of this session.
 Object setAttribute(String key, Object value)
          Sets a user-defined attribute.
 

Method Detail

close

void close()
Closes this session immediately. Calling method is identical with calling close( false ).


close

void close(boolean wait)
Closes this session immediately.

Parameters:
wait - true if you want to wait until closing process is complete.

getAttachment

Object getAttachment()
Returns an attachment of this session. This method is identical with getAttribute( "" ).


setAttachment

Object setAttachment(Object attachment)
Sets an attachment of this session. This method is identical with setAttribute( "", attachment ).

Returns:
Old attachment. null if it is new.

getAttribute

Object getAttribute(String key)
Returns the value of user-defined attribute of this session.

Parameters:
key - the key of the attribute
Returns:
null if there is no attribute with the specified key

setAttribute

Object setAttribute(String key,
                    Object value)
Sets a user-defined attribute.

Parameters:
key - the key of the attribute
value - the value of the attribute
Returns:
The old value of the attribute. null if it is new.

removeAttribute

Object removeAttribute(String key)
Removes a user-defined attribute with the specified key.

Returns:
The old value of the attribute. null if not found.

getAttributeKeys

Set getAttributeKeys()
Returns the set of keys of all user-defined attributes.


getTransportType

TransportType getTransportType()
Returns transport type of this session.


isConnected

boolean isConnected()
Returns true if this session is connected with remote peer.


getConfig

SessionConfig getConfig()
Returns the configuration of this session.


getRemoteAddress

SocketAddress getRemoteAddress()
Returns the socket address of remote peer.


getLocalAddress

SocketAddress getLocalAddress()
Returns the socket address of local machine which is associated with this session.


getReadBytes

long getReadBytes()
Returns the total number of bytes which were read from this session.


getWrittenBytes

long getWrittenBytes()
Returns the total number of bytes which were written to this session.


getWrittenWriteRequests

long getWrittenWriteRequests()
Returns the total number of write requests which were written to this session.


getScheduledWriteRequests

int getScheduledWriteRequests()
Returns the number of write requests which are scheduled to be written to this session.


getLastIoTime

long getLastIoTime()
Returns the time in millis when I/O occurred lastly.


getLastReadTime

long getLastReadTime()
Returns the time in millis when read operation occurred lastly.


getLastWriteTime

long getLastWriteTime()
Returns the time in millis when write operation occurred lastly.


isIdle

boolean isIdle(IdleStatus status)
Returns true if this session is idle for the specified IdleStatus.



Copyright © 2004-2005 . All Rights Reserved.