org.elkoserver.foundation.net
Class JSONByteIOFramerFactory

java.lang.Object
  extended by org.elkoserver.foundation.net.JSONByteIOFramerFactory
All Implemented Interfaces:
ByteIOFramerFactory

public class JSONByteIOFramerFactory
extends Object
implements ByteIOFramerFactory

Byte I/O framer factory for JSON messaging over a byte stream. The framing rule used is: a block of one or more non-empty lines terminated by an empty line (i.e., by two successive newlines).

On input, each block matching this framing rule is regarded as a parseable unit; that is, it is expected to contain one or more syntactically complete JSON messages. The entire block is read into an internal buffer, then parsed for JSON messages that are fed to the receiver.

On output, each message being sent is framed according to this rule.


Constructor Summary
JSONByteIOFramerFactory(Trace msgTrace)
          Constructor.
 
Method Summary
 ByteIOFramer provideFramer(MessageReceiver receiver, String label)
          Provide an I/O framer for a new connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONByteIOFramerFactory

public JSONByteIOFramerFactory(Trace msgTrace)
Constructor.

Parameters:
msgTrace - Trace object for logging message traffic.
Method Detail

provideFramer

public ByteIOFramer provideFramer(MessageReceiver receiver,
                                  String label)
Provide an I/O framer for a new connection.

Specified by:
provideFramer in interface ByteIOFramerFactory
Parameters:
receiver - Object to deliver received messages to.
label - A printable label identifying the associated connection.