org.apache.mina.common
Class BaseSession

java.lang.Object
  extended by org.apache.mina.common.BaseSession
All Implemented Interfaces:
Session

public abstract class BaseSession
extends Object
implements Session

Base implementation of Session.

Version:
$Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
Author:
Trustin Lee (trustin@apache.org)

Constructor Summary
protected BaseSession()
           
 
Method Summary
 void close()
          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.
 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.
 long getReadBytes()
          Returns the total number of bytes which were read from 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.
 void increaseReadBytes(int increment)
           
 void increaseWrittenBytes(int increment)
           
 void increaseWrittenWriteRequests()
           
 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 setIdle(IdleStatus status, boolean value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.mina.common.Session
close, getConfig, getLocalAddress, getRemoteAddress, getScheduledWriteRequests, getTransportType, isConnected
 

Constructor Detail

BaseSession

protected BaseSession()
Method Detail

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

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

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

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

increaseReadBytes

public void increaseReadBytes(int increment)

increaseWrittenBytes

public void increaseWrittenBytes(int increment)

increaseWrittenWriteRequests

public void increaseWrittenWriteRequests()

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

setIdle

public void setIdle(IdleStatus status,
                    boolean value)


Copyright © 2004-2005 . All Rights Reserved.