JSON Integration Adapter
Contents
- 1 Project Repository
- 2 Project Goal
- 3 Current Status
- 4 Project Phases
- 4.1 Phase I. Research (DONE)
- 4.2 Phase II. Planning and Approval (DONE)
- 4.3 Phase III. Message Formatter
- 4.4 Phase IV. Message Parser
- 4.5 Phase V. Integration and Stress Tests
- 4.6 Phase VI. Internal Code Review
- 4.7 Phase VII. Optimization
- 4.8 Phase VIII. First Code Review at NexJ
- 4.9 Phase IX. Code Rewrite
- 4.10 Phase X. Second Code Review at NexJ
- 4.11 Phase XI. Project Completion
- 5 Project Repository
- 6 Technical Notes
- 7 Resources
Project Repository
https://bitbucket.org/b_lim/nexj-express-json-integration-adapter/overview
Project Goal
To create an adapter for the NexJ Core similar in methodology and design of existing message adapters (XML, Fixed, CSV etc.) but using the JSON format
Contributors
Current Status
Currently at Phase II and beginning Phase III.
Project Phases
JSON Integration Adapter Phases
Phase I. Research (DONE)
- Complete Fundamentals of NexJ Studio tutorial
- Complete NexJ Integration tutorial
- Install NexJ Studio Express from source
Phase II. Planning and Approval (DONE)
- Receive general approval for project
- Receive approval for JSON encoding options
- Receive approval for JSON formatting options
Phase III. Message Formatter
- Add JSON to .XSD base types
- Create sample JSON .message
- Parse sample JSON .message with JUnit Test
- Create first set of unit tests for Message Formatter
- Code Message Formatter first draft
- Resolve issues with first set of unit tests
- Create second set of unit tests
- Resolve issues with second set of unit tests
- Refactor and code message formatter
Phase IV. Message Parser
- Discover how to connect JSON RPC parser with Message Parser
- Create first set of trivial unit tests for Message Parser
- Code Message Parser skeleton
- Pass first set of trivial unit tests
- Create second set of unit tests (non-trivial) for Message Parser
- Code Message Formatter first draft
- Resolve issues with second set of unit tests
- Refactor
Phase V. Integration and Stress Tests
- Test Message Formatter and Message Parser with integration and stress tests
- Test through NexJ Studio Express GUI (manual testing)
Phase VI. Internal Code Review
- Internally review code at CDOT
Phase VII. Optimization
- Find more code optimizations relevant to Enterprise environments
Phase VIII. First Code Review at NexJ
- Date TBA
Phase IX. Code Rewrite
- Rewrite code to conform with NexJ suggestions and standards
Phase X. Second Code Review at NexJ
- Date TBA
Phase XI. Project Completion
Project Repository
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.
Internally, messages are Transfer Objects. To determine if a node is a message, use instanceof on CompositeMessagePartInstance after retrieving the MessagePart. For example,
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 } ... } ...
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
JSON RFC : http://www.ietf.org/rfc/rfc4627.txt
Introduction to NexJ Studio Express : https://www.projects.openhealthtools.org/sf/go/doc1771?nav=1
NexJ Developer's Guide
NexJ Integration Fundamentals
Open Health Tools Integration Platform https://www.projects.openhealthtools.org/sf/projects/oht_aip/