gumbo.net.msg
Class ObjectMessageReader

java.lang.Object
  |
  +--gumbo.net.msg.AbstractMessageIO
        |
        +--gumbo.net.msg.ObjectMessageReader
All Implemented Interfaces:
MessageIO, MessageReader

public class ObjectMessageReader
extends AbstractMessageIO
implements MessageReader

Reads a message as a Java object from an object stream.

Version:
$Revision: 1.6 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
ObjectMessageReader(java.io.ObjectInputStream stream)
           
 
Method Summary
 void close()
          Closes this message reader.
 Message readMessage()
          Reads a message, including its end delimiter, in a thread-safe manner.
 void readMessageEnd()
          Reads the message end delimiter, skipping any white space.
 void syncMessageEnd()
          Reads the current message to its end.
 
Methods inherited from class gumbo.net.msg.AbstractMessageIO
addMessageIOListener, fireMessageRead, fireMessageWrite, getMessageIOListeners, removeMessageIOListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.net.msg.MessageIO
addMessageIOListener, getMessageIOListeners, removeMessageIOListener
 

Constructor Detail

ObjectMessageReader

public ObjectMessageReader(java.io.ObjectInputStream stream)
Method Detail

readMessageEnd

public void readMessageEnd()
                    throws java.io.IOException,
                           MessageIOException
Reads the message end delimiter, skipping any white space. Blocks until the message end is received.

Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message is not at the end (i.e. other data found).

close

public void close()
           throws java.io.IOException
Description copied from interface: MessageReader
Closes this message reader.

Specified by:
close in interface MessageReader
java.io.IOException

readMessage

public Message readMessage()
                    throws java.io.IOException,
                           MessageIOException,
                           MessageDataException
Description copied from interface: MessageReader
Reads a message, including its end delimiter, in a thread-safe manner. Blocks until a message is completely received. Typically, this method is synchronized on this message reader, which is used by all threads in the application to receive messages.

Specified by:
readMessage in interface MessageReader
Returns:
The message. Never null.
Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message end not found.
MessageDataException - Message data corrupted.

syncMessageEnd

public void syncMessageEnd()
                    throws java.io.IOException,
                           MessageIOException
Description copied from interface: MessageReader
Reads the current message to its end. Blocks until the end is received. Ignores everything but the message end delimiter. Useful for syncing the message stream following a message exception.

Specified by:
syncMessageEnd in interface MessageReader
Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message end not found (which should never happen).