FormatConversionBean – One Bean to rule them all!
Update 9 Sep 2018: FormatConversionBean now available in CPI as well
Update 19 May 2015: Added new converter Base64EncodeConverter
Update 30 Apr 2015: Added new converter Base64DecodeConverter
Over the past months, I have introduced various custom adapter modules that are configurable and reusable; aiming to handle various format conversions to/from XML that are not available in standard adapter modules.
I have recently refactored the different modules and consolidated them into a single module, FormatConversionBean. The benefits of this refactoring are:-
- Single point of entry for the different types of conversion
- Refactoring of factory class utilizing ConverterFactory allows dynamic instantiation of converters
- Easily extensible to new converter formats by extending class AbstractModuleConverter
- Conforms to the Open Close Principle whereby new converters can be added without modification to existing code
Converter Class List
Below is the comprehensive list of the converter classes that are part of FormatConversionBean now. This list will be updated as and when new converter classes are introduced in the future.
|Converter Class||Source Format||Target Format||Reference|
|Excel2XMLTransformer||Excel||XML||ExcelTransformBean Part 1: Convert various Excel formats to simple XML easily|
|XML2ExcelTransformer||XML||Excel||ExcelTransformBean Part 2: Convert simple XML to various Excel formats easily|
|DeepPlain2XMLConverter||Deep Plain Text||XML||DeepFCCBean – The better FCC at meeting your deep (structure) needs! (Part 2 – Flat File to Deep XML)|
|XML2DeepPlainConverter||XML||Deep Plain Text||DeepFCCBean – The better FCC at meeting your deep (structure) needs! (Part 1 – Deep XML to Flat File)|
|JSON2XMLConverter||JSON||XML||JSONTransformBean Part 1: Converting JSON content to XML|
|XML2JSONConverter||XML||JSON||JSONTransformBean Part 2: Converting XML to JSON content|
|Base64DecodeConverter||Base64 (Plain/XML)||Binary||Base64DecodeConverter – Base64 decoding made easy!|
|Base64EncodeConverter||Binary||Base64 (Plain/XML)||Base64EncodeConverter – Base64 encoding made easy!|
Usage of Module in Communication Channel
Module Processing Sequence
|Number||Module Name||Type||Module Key|
<Depending on position of module in chain>
1) Asynchronous scenario,
Normally before the last module in channels
2) Synchronous scenario,
Before last module to convert request payload
After last module to convert response payload
|Custom_AF_Modules/FormatConversionBean||Local Enterprise Bean||<Any Arbitrary Value>|
For configuration of parameters, refer to parameter list of each converter.
Source Code and Deployment Archive
The Java source codes for the module are located in the following GitHub repositories.
The EAR file for deployment (compiled on NWDS 7.31 SP13 Patch 0) is also available from the latest repository release below. The EAR file can be deployed directly on PI/PO systems with versions that are same/higher than 7.31 SP13 or 7.4 SP8.
To set up the EJB/EAR projects on NWDS for further customization, refer to the following.
|7.3x or higher||Setup com.equalize.xpi.af.modules Adapter Module project in NWDS easily using EGit|
|7.1x||Recompile com.equalize.xpi.af.modules as EJB 2.1 modules in NWDS 7.1x|
If you plan to download the source codes into your own NWDS installation to make changes and/or develop new modules, the following blog would be useful for performing testing in NWDS prior to deployment into the PI system.
Guide on EAR deployment via NWDS