Sunday 5 April, 2009

DOZER Framework and JCAPS512

Given the multilayered nature of the applications following SOA architectural approach,it becomes imperative that the message model being used in one layer is not bleeded in to other layers so that the layers are loose coupled.If we want to acheive the reusability of the business logic effectively,let the mapping functionality between different message models be segregated from the business logic and be handled by a mapping framework.

Advantages of using a mapping framework

  • Helps in providing more emphasis on business logic rather than focussing on the mapping intricasies by bifurcating the mapping functionality from the business logic.
  • Ease to maintain.
  • Ease to map.
  • Mapping between various data structures,Deep mapping,Mapping based on the indexes.

Lets take an example to showcase the usage of the mapping framework in JCAPS512 environment

Objective:Service(implemented using a JCD) needs to invoke another service by passing an object(java object,lets call it as a target object).The target object needs to be populated with the values passed on from source system which is unmarshalled in to an OTD being used in the JCD metioned above.The response from the target service is mapped to an output OTD in the source service(JCD) and send to an appropriate destination.

This can be implemented in the following way

1)Populate the input OTD with the message from the source system.

2)Using DOZER framework map the fields from the input OTD to that of the target object expected by the target service.

3)Map the output from the target service to the output OTD using DOZER framework.

Make the following code singleton

MapperIF mapper = new DozerBeanMapper();

DestinationObject destObject = (DestinationObject)mapper.map(otdObject,DestinationObject.class);

//set or get the values using the destObject object

Sample mapping file for mapping between source and target fields

/package.sourceOTDClassName

package.DestinationClassName

SourceFieldName

DestinationFieldName

External Jars in JCAPS512 Environment

Loading external jars in to JCAPS512 environment can be done in couple of ways.
1)Import the jar directly in to the JCD(The jar should be imported in to the project where this JCD is used or have access).
2)Place the jars in JCAPS\eDesigner\usr\lib\ext folder(If jars are placed in the above mentioned folder,to get the JCD recognize the methods exposed by the jar we have to type the entire package strcuture for the first time).

For runtime configuration
If the jars are not included as part of JCD,then for runtime loading of external jars,they have to be placed in JCAPS\logicalhost\is\lib folder.