| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.cuny.cat.comm.SocketBasedConnection<M>
M - the type of messages that can be transmitted through the connection.public abstract class SocketBasedConnection<M extends Message>
 An abstract implementation of Connection when the communication is
 socket-based. Child classes should be defined to support concrete message
 parsing, e.g., SocketBasedCatpConnection and TelnetConnection
 .
 
| Field Summary | |
|---|---|
protected static int | 
BUFFER_SIZE
 | 
protected static org.apache.log4j.Logger | 
logger
 | 
protected  java.nio.ByteBuffer | 
readBuffer
 | 
protected  boolean | 
skipLF
 | 
protected  java.nio.channels.SocketChannel | 
socketChannel
 | 
| Constructor Summary | |
|---|---|
SocketBasedConnection(java.nio.channels.SocketChannel socketChannel)
 | 
|
| Method Summary | |
|---|---|
 void | 
close()
closes this connection.  | 
 java.lang.String | 
getLocalAddressInfo()
 | 
 java.lang.String | 
getRemoteAddressInfo()
 | 
protected  void | 
initBuffer()
 | 
 boolean | 
isClosed()
checks whether the connection is closed or not.  | 
 void | 
open()
opens the connection before sending or receiving any message.  | 
protected  java.lang.String | 
readLine()
read a plain-text line from the socket channel.  | 
 void | 
sendMessage(M msg)
sends a Message through this connection. | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Methods inherited from interface edu.cuny.cat.comm.ProactiveConnection | 
|---|
getMessage | 
| Field Detail | 
|---|
protected static org.apache.log4j.Logger logger
protected java.nio.channels.SocketChannel socketChannel
protected static final int BUFFER_SIZE
protected java.nio.ByteBuffer readBuffer
protected boolean skipLF
| Constructor Detail | 
|---|
public SocketBasedConnection(java.nio.channels.SocketChannel socketChannel)
| Method Detail | 
|---|
protected void initBuffer()
public void sendMessage(M msg)
                 throws CatException
ConnectionMessage through this connection.
sendMessage in interface Connection<M extends Message>msg - message to be sent.
CatException
protected java.lang.String readLine()
                             throws java.io.IOException
BufferedReader.readLine().
java.io.IOException
public void open()
          throws ConnectionException
Connection
open in interface Connection<M extends Message>ConnectionException
public void close()
           throws ConnectionException
Connection
close in interface Connection<M extends Message>ConnectionExceptionpublic boolean isClosed()
Connection
isClosed in interface Connection<M extends Message>public java.lang.String getLocalAddressInfo()
getLocalAddressInfo in interface Connection<M extends Message>public java.lang.String getRemoteAddressInfo()
getRemoteAddressInfo in interface Connection<M extends Message>
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||