Changes

Jump to: navigation, search

JSON Integration Adapter

2,135 bytes added, 09:23, 23 June 2011
Technical information regarding NexJ Messages and Integration Layer
BitBucket : https://bitbucket.org/b_lim/nexj-express-json-integration-adapter/
 
== Technical Notes ==
 
=== Message Details ===
 
Message - Messages can contain values or other messages. The red nodes are messages, the green nodes are values.
 
[[File:NexJExpressMessages.gif|NexJ Express Messages]]
 
Internally, messages are Transfer Objects. To determine if a node is a message, use instanceof on CompositeMessagePartInstance after retrieving the MessagePart. For example,
 
<pre>
public void format(TransferObject tobj, Message message, Output out) throws IntegrationException
{
...
CompositeMessagePart root = message.getRoot(); // Gets the root of the message.
Iterator it = root.getPartIterator();
while (it.hasNext())
{
part = (MessagePart)it.next());
if (isCompositeMessagePartInstance(part))
{
// This part is a message
}
else if (isPrimitiveMessagePart(part))
{
// This part is a value
}
...
}
...
</pre>
 
MessagePart.java - Parts of a message. Messages can contain values or other messages.
 
Currently NexJ Express has two types of message parts, CompositeMessagePart.java and PrimitiveMessagePart.java .
 
CompositeMessagePart.java implementation is CompositeMessagePartInstance . The relationship between CompositeMessagePartInstance and PrimitiveMessagePart with the above picture is as follows : CompositeMessagePartInstance are messages (the red nodes) and PrimitiveMessagePart are values (the green nodes).
 
To determine multiplicity of MessageParts, use isCollection() method of MessagePart .
 
Note that multiplicity of
 
XMLJSONMessageMappingLoader.java - Used by the framework to autoload JSONMessagePartMapping for each of the message parts.
 
JSONMessagePartMapping - Each node in the above picture has a corresponding JSONMessagePartMapping.
Each node has its own mapping, with its own values initialized in XMLJSONMessageMappingLoader.
In order to get the mapping, first cast MessagePart to a concrete class such as CompositeMessagePartInstance or PrimitiveMessagePart, then use part.getMapping(). The purpose of the mapping is metadata for each node.
 
JSONMessageFormatter - Used to turn messages into JSON format.
 
JSONMessageParser - Used to turn JSON into a message.
== Resources ==
1
edit

Navigation menu