edu.cuny.cat.comm
Class CallBasedCatpConnection

java.lang.Object
  extended by edu.cuny.cat.comm.CallBasedCatpConnection
All Implemented Interfaces:
Connection<CatpMessage>, ReactiveConnection<CatpMessage>

public class CallBasedCatpConnection
extends java.lang.Object
implements ReactiveConnection<CatpMessage>

The implementation of Connection when CallBasedInfrastructureImpl is used.

Version:
$Revision: 1.7 $
Author:
Jinzhong Niu

Field Summary
protected  java.lang.Object connector
          the Connector that requested to create this connection
protected  java.lang.String id
          an identifier for this connection
protected  ConnectionListener<CatpMessage> listener
          object listening to the incoming messages
protected  CallBasedCatpConnection peer
          the other side of the connection where outgoing messages go
 
Constructor Summary
CallBasedCatpConnection(java.lang.Object connector, java.lang.String id)
           
 
Method Summary
 void close()
          closes this connection.
 java.lang.Object getConnector()
           
 ConnectionListener<CatpMessage> getListener()
           
 java.lang.String getLocalAddressInfo()
           
 CallBasedCatpConnection getPeer()
           
 java.lang.String getRemoteAddressInfo()
           
 boolean isClosed()
          checks whether the connection is closed or not.
 void open()
          opens the connection before sending or receiving any message.
 void relayMessage(CatpMessage msg)
           
 void sendMessage(CatpMessage msg)
          sends a Message through this connection.
 void setConnector(java.lang.Object connector)
           
 void setListener(ConnectionListener<CatpMessage> listener)
           
 void setPeer(CallBasedCatpConnection peer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

protected ConnectionListener<CatpMessage> listener
object listening to the incoming messages


connector

protected java.lang.Object connector
the Connector that requested to create this connection


peer

protected CallBasedCatpConnection peer
the other side of the connection where outgoing messages go


id

protected java.lang.String id
an identifier for this connection

Constructor Detail

CallBasedCatpConnection

public CallBasedCatpConnection(java.lang.Object connector,
                               java.lang.String id)
Method Detail

getConnector

public java.lang.Object getConnector()

setConnector

public void setConnector(java.lang.Object connector)

getPeer

public CallBasedCatpConnection getPeer()

setPeer

public void setPeer(CallBasedCatpConnection peer)

sendMessage

public void sendMessage(CatpMessage msg)
                 throws CatException
Description copied from interface: Connection
sends a Message through this connection.

Specified by:
sendMessage in interface Connection<CatpMessage>
Parameters:
msg - message to be sent.
Throws:
CatException

relayMessage

public void relayMessage(CatpMessage msg)
                  throws CatException
Throws:
CatException

setListener

public void setListener(ConnectionListener<CatpMessage> listener)
Specified by:
setListener in interface ReactiveConnection<CatpMessage>

getListener

public ConnectionListener<CatpMessage> getListener()
Specified by:
getListener in interface ReactiveConnection<CatpMessage>

open

public void open()
          throws ConnectionException
Description copied from interface: Connection
opens the connection before sending or receiving any message.

Specified by:
open in interface Connection<CatpMessage>
Throws:
ConnectionException

close

public void close()
           throws ConnectionException
Description copied from interface: Connection
closes this connection.

Specified by:
close in interface Connection<CatpMessage>
Throws:
ConnectionException

isClosed

public boolean isClosed()
Description copied from interface: Connection
checks whether the connection is closed or not.

Specified by:
isClosed in interface Connection<CatpMessage>
Returns:
true if closed; false otherwise.

getLocalAddressInfo

public java.lang.String getLocalAddressInfo()
Specified by:
getLocalAddressInfo in interface Connection<CatpMessage>
Returns:
a string describing the address of the local end of this connection

getRemoteAddressInfo

public java.lang.String getRemoteAddressInfo()
Specified by:
getRemoteAddressInfo in interface Connection<CatpMessage>
Returns:
a string describing the address of the remote end of this connection