gumbo.net.msg
Class ObjectMessageWriter

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

public class ObjectMessageWriter
extends AbstractMessageIO
implements MessageWriter

Writes a message as a Java object to an object stream. Note that the output stream is reset before and flushed after writing a message. This assures that a message is always sent in its entirety even if it or a component was previously sent (and in the cache), and that the message is immediately received and available in its entirety at the receiver.

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

Constructor Summary
ObjectMessageWriter(java.io.ObjectOutputStream stream)
           
 
Method Summary
 void close()
          Closes this writer.
 void flush()
          Flushes this writer.
 void writeMessage(Message msg)
          Resets the output stream before writing the message, and flushes the output stream after writing the message.
 void writeMessageEnd()
          Writes the message end delimiter.
 
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

ObjectMessageWriter

public ObjectMessageWriter(java.io.ObjectOutputStream stream)
Method Detail

writeMessageEnd

public void writeMessageEnd()
                     throws java.io.IOException,
                            MessageIOException
Writes the message end delimiter.

Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message end object is ill-formed.

flush

public void flush()
           throws java.io.IOException
Description copied from interface: MessageWriter
Flushes this writer.

Specified by:
flush in interface MessageWriter
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: MessageWriter
Closes this writer.

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

writeMessage

public void writeMessage(Message msg)
                  throws java.io.IOException,
                         MessageIOException,
                         MessageDataException
Resets the output stream before writing the message, and flushes the output stream after writing the message.

Specified by:
writeMessage in interface MessageWriter
Throws:
MessageDataException - Message is ill-formed for writing.
java.io.IOException - Writer is closed.
MessageIOException - Message stream is out of sync.