ks.common.network
Class CommunicationAgent

java.lang.Object
  extended byks.common.network.CommunicationAgent
All Implemented Interfaces:
ICommunicator

public class CommunicationAgent
extends java.lang.Object
implements ICommunicator

Maintains Input and Output streams, and knows how to writeObject to the Output and readObject from Input, on demand.


Constructor Summary
CommunicationAgent(java.io.InputStream in, java.io.OutputStream out)
          Agent to manage communication where writing an object to OutputStream while reading from InputStream.
 
Method Summary
 void close()
          Shutdown communication agent.
 java.lang.Object readObject()
          Blocks for an object to be read.
 boolean writeObject(java.lang.Object o)
          Writes an object to the OutputStream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommunicationAgent

public CommunicationAgent(java.io.InputStream in,
                          java.io.OutputStream out)
Agent to manage communication where writing an object to OutputStream while reading from InputStream.

Parameters:
in -
out -
Method Detail

close

public void close()
Shutdown communication agent.


readObject

public java.lang.Object readObject()
Blocks for an object to be read. Note that the very fact of opening an ObjectInputStream actually forces a read of the stream header; this is why we need to cleanly encapsulate it here.

Specified by:
readObject in interface ICommunicator
Returns:
Object read or null if an exception occured.

writeObject

public boolean writeObject(java.lang.Object o)
Writes an object to the OutputStream. Note that the very fact of opening an ObjectOutputStream actually forces a write of a stream header; this is why we need to cleanly encapsulate it here.

Specified by:
writeObject in interface ICommunicator
Parameters:
o - Object to be written.