org.apache.mina.protocol.io
Class IoProtocolSession

java.lang.Object
  extended by org.apache.mina.protocol.io.IoProtocolSession
All Implemented Interfaces:
Session, ProtocolSession

public class IoProtocolSession
extends Object
implements ProtocolSession

A ProtocolSession that is backed by IoSession.

Version:
$Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
Author:
The Apache Directory Project (dev@directory.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 getCreationTime()
          Returns the time in millis when this session is created.
 ProtocolDecoder getDecoder()
          Returns the ProtocolDecoder for this session.
 ProtocolEncoder getEncoder()
          Returns the ProtocolEncoder for this session.
 ProtocolFilterChain getFilterChain()
          Returns the filter chain that only affects this session.
 ProtocolHandler getHandler()
          Returns the ProtocolHandler which handles this session.
 int getIdleCount(IdleStatus status)
          Returns the number of the fired continuous sessionIdle events for the specified IdleStatus.
 IoSession getIoSession()
          Returns the IoSession this session is backed by.
 long getLastIdleTime(IdleStatus status)
          Returns the time in millis when the last sessionIdle event is fired for the specified IdleStatus.
 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.
 void write(Object message)
          Writes the specified message to remote peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getIoSession

public IoSession getIoSession()
Returns the IoSession this session is backed by.


getFilterChain

public ProtocolFilterChain getFilterChain()
Description copied from interface: ProtocolSession
Returns the filter chain that only affects this session.

Specified by:
getFilterChain in interface ProtocolSession

getHandler

public ProtocolHandler getHandler()
Description copied from interface: ProtocolSession
Returns the ProtocolHandler which handles this session.

Specified by:
getHandler in interface ProtocolSession

getEncoder

public ProtocolEncoder getEncoder()
Description copied from interface: ProtocolSession
Returns the ProtocolEncoder for this session.

Specified by:
getEncoder in interface ProtocolSession

getDecoder

public ProtocolDecoder getDecoder()
Description copied from interface: ProtocolSession
Returns the ProtocolDecoder for this session.

Specified by:
getDecoder in interface ProtocolSession

close

public void close()
Description copied from interface: Session
Closes this session immediately. Calling method is identical with calling close( false ).

Specified by:
close in interface Session

close

public void close(boolean wait)
Description copied from interface: Session
Closes this session immediately.

Specified by:
close in interface Session
Parameters:
wait - true if you want to wait until closing process is complete.

getAttachment

public Object getAttachment()
Description copied from interface: Session
Returns an attachment of this session. This method is identical with getAttribute( "" ).

Specified by:
getAttachment in interface Session

setAttachment

public Object setAttachment(Object attachment)
Description copied from interface: Session
Sets an attachment of this session. This method is identical with setAttribute( "", attachment ).

Specified by:
setAttachment in interface Session
Returns:
Old attachment. null if it is new.

getAttribute

public Object getAttribute(String key)
Description copied from interface: Session
Returns the value of user-defined attribute of this session.

Specified by:
getAttribute in interface Session
Parameters:
key - the key of the attribute
Returns:
null if there is no attribute with the specified key

setAttribute

public Object setAttribute(String key,
                           Object value)
Description copied from interface: Session
Sets a user-defined attribute.

Specified by:
setAttribute in interface Session
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

public Object removeAttribute(String key)
Description copied from interface: Session
Removes a user-defined attribute with the specified key.

Specified by:
removeAttribute in interface Session
Returns:
The old value of the attribute. null if not found.

getAttributeKeys

public Set getAttributeKeys()
Description copied from interface: Session
Returns the set of keys of all user-defined attributes.

Specified by:
getAttributeKeys in interface Session

write

public void write(Object message)
Description copied from interface: ProtocolSession
Writes the specified message to remote peer. This operation is asynchronous; ProtocolHandler.messageSent(ProtocolSession, Object) will be invoked when the message is actually sent to remote peer.

Specified by:
write in interface ProtocolSession

getWrittenWriteRequests

public long getWrittenWriteRequests()
Description copied from interface: Session
Returns the total number of write requests which were written to this session.

Specified by:
getWrittenWriteRequests in interface Session

getScheduledWriteRequests

public int getScheduledWriteRequests()
Description copied from interface: Session
Returns the number of write requests which are scheduled to be written to this session.

Specified by:
getScheduledWriteRequests in interface Session

getTransportType

public TransportType getTransportType()
Description copied from interface: Session
Returns transport type of this session.

Specified by:
getTransportType in interface Session

isConnected

public boolean isConnected()
Description copied from interface: Session
Returns true if this session is connected with remote peer.

Specified by:
isConnected in interface Session

getConfig

public SessionConfig getConfig()
Description copied from interface: Session
Returns the configuration of this session.

Specified by:
getConfig in interface Session

getRemoteAddress

public SocketAddress getRemoteAddress()
Description copied from interface: Session
Returns the socket address of remote peer.

Specified by:
getRemoteAddress in interface Session

getLocalAddress

public SocketAddress getLocalAddress()
Description copied from interface: Session
Returns the socket address of local machine which is associated with this session.

Specified by:
getLocalAddress in interface Session

getReadBytes

public long getReadBytes()
Description copied from interface: Session
Returns the total number of bytes which were read from this session.

Specified by:
getReadBytes in interface Session

getWrittenBytes

public long getWrittenBytes()
Description copied from interface: Session
Returns the total number of bytes which were written to this session.

Specified by:
getWrittenBytes in interface Session

getCreationTime

public long getCreationTime()
Description copied from interface: Session
Returns the time in millis when this session is created.

Specified by:
getCreationTime in interface Session

getLastIoTime

public long getLastIoTime()
Description copied from interface: Session
Returns the time in millis when I/O occurred lastly.

Specified by:
getLastIoTime in interface Session

getLastReadTime

public long getLastReadTime()
Description copied from interface: Session
Returns the time in millis when read operation occurred lastly.

Specified by:
getLastReadTime in interface Session

getLastWriteTime

public long getLastWriteTime()
Description copied from interface: Session
Returns the time in millis when write operation occurred lastly.

Specified by:
getLastWriteTime in interface Session

isIdle

public boolean isIdle(IdleStatus status)
Description copied from interface: Session
Returns true if this session is idle for the specified IdleStatus.

Specified by:
isIdle in interface Session

getIdleCount

public int getIdleCount(IdleStatus status)
Description copied from interface: Session
Returns the number of the fired continuous sessionIdle events for the specified IdleStatus.

If sessionIdle event is fired first after some time after I/O, idleCount becomes 1. idleCount resets to 0 if any I/O occurs again, otherwise it increases to 2 and so on if sessionIdle event is fired again without any I/O between two (or more) sessionIdle events.

Specified by:
getIdleCount in interface Session

getLastIdleTime

public long getLastIdleTime(IdleStatus status)
Description copied from interface: Session
Returns the time in millis when the last sessionIdle event is fired for the specified IdleStatus.

Specified by:
getLastIdleTime in interface Session


Copyright © 2004-2005 . All Rights Reserved.