ca.sqlpower.wabit.dao.json
Class WabitJSONMessageDecoder

java.lang.Object
  extended by ca.sqlpower.wabit.dao.json.WabitJSONMessageDecoder
All Implemented Interfaces:
MessageDecoder<java.lang.String>

public class WabitJSONMessageDecoder
extends java.lang.Object
implements MessageDecoder<java.lang.String>

An implementation of MessageDecoder that takes in a String that is intended to be a JSON-formatted message, and constructs a JSONObject from it. It then expects JSONObject key values that map to WabitPersister methods and their expected parameters. It then extracts this information from the JSONObject and makes the appropriate method calls to a WabitPersister provided in the constructor.


Constructor Summary
WabitJSONMessageDecoder(WabitPersister persister)
          Creates a WabitMessageDecoder with the given WabitPersister.
 
Method Summary
 void decode(java.lang.String message)
          Takes in a message in the form of String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WabitJSONMessageDecoder

public WabitJSONMessageDecoder(@Nonnull
                               WabitPersister persister)
Creates a WabitMessageDecoder with the given WabitPersister. The messages that this class decodes will contain WabitPersister method calls with their parameters. This decoder will use the messages to make method calls to the given WabitPersister.

Parameters:
persister - The WabitPersister that this decoder will make method calls to
Method Detail

decode

public void decode(@Nonnull
                   java.lang.String message)
            throws WabitPersistenceException
Takes in a message in the form of String. The message is expected to be in JSON format. The JSON message is expected to be a JSONArray of JSONObjects. Each JSONObject contains details for making a WabitPersister method call. It expects the following key-value pairs in each JSONObject message: Other possible key-value pairs (depending on the intended method call) include: See the method documentation of WabitPersister for full details on the expected values

Specified by:
decode in interface MessageDecoder<java.lang.String>
Throws:
WabitPersistenceException


Copyright © 2009. All Rights Reserved.