org.quickconnectfamily.json
Class JSONStreamProtector

java.lang.Object
  extended by org.quickconnectfamily.json.JSONStreamProtector

public class JSONStreamProtector
extends java.lang.Object

The JSONStreamProtector class is used to make any read or write object calls to a JSONOutputStream or a JSONInputStream thread safe. If you are working in a multi-threaded environment you must use this class to ensure that your reads and writes to the underlying resources are not interleaved. If you are working in a single threaded environment you can ignore this class.

To make your subsequent read or write object calls safe, instantiate a JSONStreamProtector and pass the JSONStreams to be protected to the protectJSONStream method.

You can use one protector for multiple write streams, multiple read streams, read/write pairs that belong to the same underlying resource( a file, socket, etc.) or any other combination that is appropriate for your application.

Author:
Lee S. Barney

Constructor Summary
JSONStreamProtector()
           
 
Method Summary
 void protectJSONStream(JSONStream aJsonStream)
          This method protects JSONStreams from having concurrent write or read errors due to multiple threads doing concurrent access.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONStreamProtector

public JSONStreamProtector()
Method Detail

protectJSONStream

public void protectJSONStream(JSONStream aJsonStream)
This method protects JSONStreams from having concurrent write or read errors due to multiple threads doing concurrent access.

Parameters:
aJsonStream - - The JSONOutputStream or JSONInputStream to be protected