Spring and C24 iO - Part 1 C24 Spring Core
The XML/Java binding-transform is an interesting example, popular technologies for performing such actions are JAXB & Castor; amongst a large cast of others. However, the specific value that C24 iO adds in this regard is that it’s not tied to any specific input data type such as XML - in fact iO models are strictly decoupled from input and output data types in order that you can freely choose or interchange between them when appropriate.
C24 iO models represent business objects. As a developer you can choose a number of input data types to use to populate those objects with business data, CSV, XML, SWIFT, JSON, FpML, Columnar etc. The same is also true for output, you can choose a data format for those business objects when you’re ready to perform a reverse of the bind-transform should you need to dispatch data downstream in a specific format. The facility to do this binding-transform, and the reverse, is provided by C24 iO, out-of-the-box - no additional development is necessary.
In order to build a C24 iO model an understanding of your business object is necessary. The iO model can be built automatically from a sample message in many formats or from an external model such as an XSD. Alternatively, if you wish to maintain your business model using C24 iO, you can use iO Studio to build it from scratch. Model building terminology should seem familiar and intuitive, due mainly to the language that’s used for constituent parts, most people understand elements, attributes, simple and complex types or will quickly learn the difference when using this graphical tool.
The one remaining piece of the puzzle is the mechanism that allows these models to be used in application software at runtime. Once models have been created and tested in iO Studio, a triggering of code generation produces a Jar file that contains everything necessary to read data into the business model (from various source data types), interact with it through intuitively named methods and write it out again (into various target data formats).
Each business object generated from an iO model is automatically part of a type hierarchy known as a Complex Data Object (CDO). Any standard or custom model that you use or build within C24 iO Studio will generate code that will implement the CDO type.
The c24-spring-core namespace provides capability to use CDOs as Spring beans either within applications using the Spring framework or as Spring beans within applications using the Spring Integration framework.
The namespace is http://schema.c24.biz/spring-core, the XSD is located at http://schema.c24.biz/spring-core.xsd. Using the c24-spring-core namespace within your Spring application means defining an interest in that namespace and location using something like the following configuration:
xmlns:c24="http://schema.c24.biz/spring-core" xsi:schemaLocation="http://schema.c24.biz/spring-core http://schema.c24.biz/spring-core.xsd"
Once the namespace configurations have been completed, a namespace construct can be used to generate a C24 iO bean and use it within a Spring application. Those readers familiar with SWIFT FIN messages will recognise this example as a message model representing a securities trade message, an MT541.
<c24:model id="mt541Model" base-element="biz.c24.io.swift2011.MT541Element"/>
Once the Spring container is loaded with this bean, the developer is at liberty to interact with this business object in the same way that you would when using it outside of the Spring container. The benefit gained here is that it now has a lifecycle controlled by the Spring container and can be used by other beans within the same context, this will be explored further in the next part of the series.
The motivation for Part 1 of this series was an introduction to C24 iO, a brief explanation of some of it's basic capability and an introduction to iO models used as Spring beans.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)