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: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
Author:
The Apache Directory Project (dev@directory.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 getCreationTime()
          Returns the time in millis when this session is created.
 int getIdleCount(IdleStatus status)
          Returns the number of the fired continuous sessionIdle events for the specified IdleStatus.
 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.
 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 increaseIdleCount(IdleStatus status)
           
 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.
 void resetIdleCount(IdleStatus status)
           
 Object setAttachment(Object attachment)
          Sets an attachment of this session.
 Object setAttribute(String key, Object value)
          Sets a user-defined attribute.
 
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()

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

increaseIdleCount

public void increaseIdleCount(IdleStatus status)

resetIdleCount

public void resetIdleCount(IdleStatus status)


Copyright © 2004-2005 . All Rights Reserved.