Java Doc for IoSession.java in  » Net » mina-2.0.0-M1 » org » apache » mina » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » mina 2.0.0 M1 » org.apache.mina.common 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.mina.common.IoSession

All known Subclasses:   org.apache.mina.common.AbstractIoSession,
IoSession
public interface IoSession (Code)
A handle which represents connection between two end-points regardless of transport types.

IoSession 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.

Adjusting Transport Type Specific Properties

You can simply downcast the session to an appropriate subclass.

Thread Safety

IoSession is thread-safe. But please note that performing more than one IoSession.write(Object) calls at the same time will cause the IoFilter.filterWrite(IoFilter.NextFilterIoSessionWriteRequest) is executed simultaneously, and therefore you have to make sure the IoFilter implementations you're using are thread-safe, too.

Equality of Sessions

IoSession.equals(Object) and IoSession.hashCode() shall not be overriden to the default behavior that is defined in Object .
author:
   The Apache MINA Project (dev@mina.apache.org)
version:
   $Rev: 601679 $, $Date: 2007-12-06 03:13:21 -0700 (Thu, 06 Dec 2007) $




Method Summary
 CloseFutureclose()
     Closes this session immediately.
 CloseFutureclose(boolean immediately)
     Closes this session immediately or after all queued write requests are flushed.
 CloseFuturecloseOnFlush()
     Closes this session after all queued write requests are flushed. This operation is asynchronous.
 booleancontainsAttribute(Object key)
     Returns true if this session contains the attribute with the specified key.
 ObjectgetAttachment()
     Returns an attachment of this session.
 ObjectgetAttribute(Object key)
     Returns the value of the user-defined attribute of this session.
 ObjectgetAttribute(Object key, Object defaultValue)
     Returns the value of user defined attribute associated with the specified key.
 Set<Object>getAttributeKeys()
     Returns the set of keys of all user-defined attributes.
 intgetBothIdleCount()
     Returns the number of the fired continuous sessionIdle events for IdleStatus.BOTH_IDLE .
 CloseFuturegetCloseFuture()
     Returns the CloseFuture of this session.
 IoSessionConfiggetConfig()
     Returns the configuration of this session.
 longgetCreationTime()
     Returns the time in millis when this session is created.
 IoFilterChaingetFilterChain()
     Returns the filter chain that only affects this session.
 IoHandlergetHandler()
     Returns the IoHandler which handles this session.
 longgetId()
     Returns a unique identifier of this session.
 intgetIdleCount(IdleStatus status)
     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.

 longgetLastBothIdleTime()
     Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.BOTH_IDLE .
 longgetLastIdleTime(IdleStatus status)
     Returns the time in milliseconds when the last sessionIdle event is fired for the specified IdleStatus .
 longgetLastIoTime()
     Returns the time in millis when I/O occurred lastly.
 longgetLastReadTime()
     Returns the time in millis when read operation occurred lastly.
 longgetLastReaderIdleTime()
     Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.READER_IDLE .
 longgetLastWriteTime()
     Returns the time in millis when write operation occurred lastly.
 longgetLastWriterIdleTime()
     Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.WRITER_IDLE .
 SocketAddressgetLocalAddress()
     Returns the socket address of local machine which is associated with this session.
 longgetReadBytes()
     Returns the total number of bytes which were read from this session.
 doublegetReadBytesThroughput()
     Returns the number of read bytes per second.
 longgetReadMessages()
     Returns the total number of messages which were read and decoded from this session.
 doublegetReadMessagesThroughput()
     Returns the number of read messages per second.
 intgetReaderIdleCount()
     Returns the number of the fired continuous sessionIdle events for IdleStatus.READER_IDLE .
 SocketAddressgetRemoteAddress()
     Returns the socket address of remote peer.
 longgetScheduledWriteBytes()
     Returns the number of bytes which are scheduled to be written to this session.
 intgetScheduledWriteMessages()
     Returns the number of messages which are scheduled to be written to this session.
 IoServicegetService()
     Returns the IoService which provides I/O service to this session.
 SocketAddressgetServiceAddress()
     Returns the socket address of the IoService listens to to manage this session.
 TrafficMaskgetTrafficMask()
     Returns the current TrafficMask of this session.
 TransportMetadatagetTransportMetadata()
     Returns the TransportMetadata that this session runs on.
 intgetWriterIdleCount()
     Returns the number of the fired continuous sessionIdle events for IdleStatus.WRITER_IDLE .
 longgetWrittenBytes()
     Returns the total number of bytes which were written to this session.
 doublegetWrittenBytesThroughput()
     Returns the number of written bytes per second.
 longgetWrittenMessages()
     Returns the total number of messages which were written and encoded by this session.
 doublegetWrittenMessagesThroughput()
     Returns the number of written messages per second.
 booleanisClosing()
     Returns true if and only if this session is being closed (but not disconnected yet) or is closed.
 booleanisConnected()
     Returns true if this session is connected with remote peer.
 booleanisIdle(IdleStatus status)
     Returns true if this session is idle for the specified IdleStatus .
 ReadFutureread()
     Returns a ReadFuture which is notified when a new message is received, the connection is closed or an exception is caught.
 ObjectremoveAttribute(Object key)
     Removes a user-defined attribute with the specified key. The old value of the attribute.
 booleanremoveAttribute(Object key, Object value)
     Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value.
 booleanreplaceAttribute(Object key, Object oldValue, Object newValue)
     Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value.
 voidresumeRead()
     A shortcut method for IoSession.setTrafficMask(TrafficMask) that resumes read operations for this session.
 voidresumeWrite()
     A shortcut method for IoSession.setTrafficMask(TrafficMask) that resumes write operations for this session.
 ObjectsetAttachment(Object attachment)
     Sets an attachment of this session. This method is identical with setAttribute( "", attachment ). Old attachment.
 ObjectsetAttribute(Object key, Object value)
     Sets a user-defined attribute.
Parameters:
  key - the key of the attribute
Parameters:
  value - the value of the attribute The old value of the attribute.
 ObjectsetAttribute(Object key)
     Sets a user defined attribute without a value.
 ObjectsetAttributeIfAbsent(Object key, Object value)
     Sets a user defined attribute if the attribute with the specified key is not set yet.
 ObjectsetAttributeIfAbsent(Object key)
     Sets a user defined attribute without a value if the attribute with the specified key is not set yet.
 voidsetTrafficMask(TrafficMask trafficMask)
     Sets the TrafficMask of this session which will result the parent IoService to start to control the traffic of this session immediately.
 voidsuspendRead()
     A shortcut method for IoSession.setTrafficMask(TrafficMask) that suspends read operations for this session.
 voidsuspendWrite()
     A shortcut method for IoSession.setTrafficMask(TrafficMask) that suspends write operations for this session.
 WriteFuturewrite(Object message)
     Writes the specified message to remote peer.
 WriteFuturewrite(Object message, SocketAddress destination)
     (Optional) Writes the specified message to the specified destination. This operation is asynchronous; IoHandler.messageSent(IoSessionObject) will be invoked when the message is actually sent to remote peer.



Method Detail
close
CloseFuture close()(Code)
Closes this session immediately. This operation is asynchronous. Wait for the returned CloseFuture if you want to wait for the session actually closed.



close
CloseFuture close(boolean immediately)(Code)
Closes this session immediately or after all queued write requests are flushed. This operation is asynchronous. Wait for the returned CloseFuture if you want to wait for the session actually closed.
Parameters:
  immediately - true to close this session immediately(i.e. IoSession.close()). false to close this session after all queuedwrite requests are flushed (i.e. IoSession.closeOnFlush()).



closeOnFlush
CloseFuture closeOnFlush()(Code)
Closes this session after all queued write requests are flushed. This operation is asynchronous. Wait for the returned CloseFuture if you want to wait for the session actually closed.



containsAttribute
boolean containsAttribute(Object key)(Code)
Returns true if this session contains the attribute with the specified key.



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



getAttribute
Object getAttribute(Object key)(Code)
Returns the value of the user-defined attribute of this session.
Parameters:
  key - the key of the attribute null if there is no attribute with the specified key



getAttribute
Object getAttribute(Object key, Object defaultValue)(Code)
Returns the value of user defined attribute associated with the specified key. If there's no such attribute, the specified default value is associated with the specified key, and the default value is returned. This method is same with the following code except that the operation is performed atomically.
 if (containsAttribute(key)) {
 return getAttribute(key);
 } else {
 setAttribute(key, defaultValue);
 return defaultValue;
 }
 



getAttributeKeys
Set<Object> getAttributeKeys()(Code)
Returns the set of keys of all user-defined attributes.



getBothIdleCount
int getBothIdleCount()(Code)
Returns the number of the fired continuous sessionIdle events for IdleStatus.BOTH_IDLE .
See Also:   IoSession.getIdleCount(IdleStatus)



getCloseFuture
CloseFuture getCloseFuture()(Code)
Returns the CloseFuture of this session. This method returns the same instance whenever user calls it.



getConfig
IoSessionConfig getConfig()(Code)
Returns the configuration of this session.



getCreationTime
long getCreationTime()(Code)
Returns the time in millis when this session is created.



getFilterChain
IoFilterChain getFilterChain()(Code)
Returns the filter chain that only affects this session.



getHandler
IoHandler getHandler()(Code)
Returns the IoHandler which handles this session.



getId
long getId()(Code)
Returns a unique identifier of this session. Every session has its own ID which is different from each other.



getIdleCount
int getIdleCount(IdleStatus status)(Code)
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.




getLastBothIdleTime
long getLastBothIdleTime()(Code)
Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.BOTH_IDLE .
See Also:   IoSession.getLastIdleTime(IdleStatus)



getLastIdleTime
long getLastIdleTime(IdleStatus status)(Code)
Returns the time in milliseconds when the last sessionIdle event is fired for the specified IdleStatus .



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



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



getLastReaderIdleTime
long getLastReaderIdleTime()(Code)
Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.READER_IDLE .
See Also:   IoSession.getLastIdleTime(IdleStatus)



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



getLastWriterIdleTime
long getLastWriterIdleTime()(Code)
Returns the time in milliseconds when the last sessionIdle event is fired for IdleStatus.WRITER_IDLE .
See Also:   IoSession.getLastIdleTime(IdleStatus)



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



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



getReadBytesThroughput
double getReadBytesThroughput()(Code)
Returns the number of read bytes per second.



getReadMessages
long getReadMessages()(Code)
Returns the total number of messages which were read and decoded from this session.



getReadMessagesThroughput
double getReadMessagesThroughput()(Code)
Returns the number of read messages per second.



getReaderIdleCount
int getReaderIdleCount()(Code)
Returns the number of the fired continuous sessionIdle events for IdleStatus.READER_IDLE .
See Also:   IoSession.getIdleCount(IdleStatus)



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



getScheduledWriteBytes
long getScheduledWriteBytes()(Code)
Returns the number of bytes which are scheduled to be written to this session.



getScheduledWriteMessages
int getScheduledWriteMessages()(Code)
Returns the number of messages which are scheduled to be written to this session.



getService
IoService getService()(Code)
Returns the IoService which provides I/O service to this session.



getServiceAddress
SocketAddress getServiceAddress()(Code)
Returns the socket address of the IoService listens to to manage this session. If this session is managed by IoAcceptor , it returns the SocketAddress which is specified as a parameter of IoAcceptor.bind . If this session is managed by IoConnector , this method returns the same address with that of IoSession.getRemoteAddress() .



getTrafficMask
TrafficMask getTrafficMask()(Code)
Returns the current TrafficMask of this session.



getTransportMetadata
TransportMetadata getTransportMetadata()(Code)
Returns the TransportMetadata that this session runs on.



getWriterIdleCount
int getWriterIdleCount()(Code)
Returns the number of the fired continuous sessionIdle events for IdleStatus.WRITER_IDLE .
See Also:   IoSession.getIdleCount(IdleStatus)



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



getWrittenBytesThroughput
double getWrittenBytesThroughput()(Code)
Returns the number of written bytes per second.



getWrittenMessages
long getWrittenMessages()(Code)
Returns the total number of messages which were written and encoded by this session.



getWrittenMessagesThroughput
double getWrittenMessagesThroughput()(Code)
Returns the number of written messages per second.



isClosing
boolean isClosing()(Code)
Returns true if and only if this session is being closed (but not disconnected yet) or is closed.



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



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



read
ReadFuture read()(Code)
Returns a ReadFuture which is notified when a new message is received, the connection is closed or an exception is caught. This operation is especially useful when you implement a client application. However, please note that this operation is disabled by default and throw IllegalStateException because all received events must be queued somewhere to support this operation, possibly leading to memory leak. This means you have to keep calling IoSession.read() once you enabled this operation. To enable this operation, please call IoSessionConfig.setUseReadOperation(boolean) with true.
throws:
  IllegalStateException - ifIoSessionConfig.setUseReadOperation(boolean) useReadOperationoption has not been enabled.



removeAttribute
Object removeAttribute(Object key)(Code)
Removes a user-defined attribute with the specified key. The old value of the attribute. null if not found.



removeAttribute
boolean removeAttribute(Object key, Object value)(Code)
Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value. This method is same with the following code except that the operation is performed atomically.
 if (containsAttribute(key) && getAttribute(key).equals(value)) {
 removeAttribute(key);
 return true;
 } else {
 return false;
 }
 



replaceAttribute
boolean replaceAttribute(Object key, Object oldValue, Object newValue)(Code)
Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value. This method is same with the following code except that the operation is performed atomically.
 if (containsAttribute(key) && getAttribute(key).equals(oldValue)) {
 setAttribute(key, newValue);
 return true;
 } else {
 return false;
 }
 



resumeRead
void resumeRead()(Code)
A shortcut method for IoSession.setTrafficMask(TrafficMask) that resumes read operations for this session.



resumeWrite
void resumeWrite()(Code)
A shortcut method for IoSession.setTrafficMask(TrafficMask) that resumes write operations for this session.



setAttachment
Object setAttachment(Object attachment)(Code)
Sets an attachment of this session. This method is identical with setAttribute( "", attachment ). Old attachment. null if it is new.IoSession.setAttribute(Object,Object)



setAttribute
Object setAttribute(Object key, Object value)(Code)
Sets a user-defined attribute.
Parameters:
  key - the key of the attribute
Parameters:
  value - the value of the attribute The old value of the attribute. null if it is new.



setAttribute
Object setAttribute(Object key)(Code)
Sets a user defined attribute without a value. This is useful when you just want to put a 'mark' attribute. Its value is set to Boolean.TRUE .
Parameters:
  key - the key of the attribute The old value of the attribute. null if it is new.



setAttributeIfAbsent
Object setAttributeIfAbsent(Object key, Object value)(Code)
Sets a user defined attribute if the attribute with the specified key is not set yet. This method is same with the following code except that the operation is performed atomically.
 if (containsAttribute(key)) {
 return getAttribute(key);
 } else {
 return setAttribute(key, value);
 }
 



setAttributeIfAbsent
Object setAttributeIfAbsent(Object key)(Code)
Sets a user defined attribute without a value if the attribute with the specified key is not set yet. This is useful when you just want to put a 'mark' attribute. Its value is set to Boolean.TRUE . This method is same with the following code except that the operation is performed atomically.
 if (containsAttribute(key)) {
 return getAttribute(key);  // might not always be Boolean.TRUE.
 } else {
 return setAttribute(key);
 }
 



setTrafficMask
void setTrafficMask(TrafficMask trafficMask)(Code)
Sets the TrafficMask of this session which will result the parent IoService to start to control the traffic of this session immediately.



suspendRead
void suspendRead()(Code)
A shortcut method for IoSession.setTrafficMask(TrafficMask) that suspends read operations for this session.



suspendWrite
void suspendWrite()(Code)
A shortcut method for IoSession.setTrafficMask(TrafficMask) that suspends write operations for this session.



write
WriteFuture write(Object message)(Code)
Writes the specified message to remote peer. This operation is asynchronous; IoHandler.messageSent(IoSessionObject) will be invoked when the message is actually sent to remote peer. You can also wait for the returned WriteFuture if you want to wait for the message actually written.



write
WriteFuture write(Object message, SocketAddress destination)(Code)
(Optional) Writes the specified message to the specified destination. This operation is asynchronous; IoHandler.messageSent(IoSessionObject) will be invoked when the message is actually sent to remote peer. You can also wait for the returned WriteFuture if you want to wait for the message actually written.

When you implement a client that receives a broadcast message from a server such as DHCP server, the client might need to send a response message for the broadcast message the server sent. Because the remote address of the session is not the address of the server in case of broadcasting, there should be a way to specify the destination when you write the response message. This interface provides IoSession.write(Object,SocketAddress) method so you can specify the destination.
Parameters:
  destination - null if you want the message sent to thedefault remote address
throws:
  UnsupportedOperationException - if this operation is not supported




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.