Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Patterns : Java class conversion from axis objects

Tags:

java

axis

I use a axis to auto-generate webservice artifacts which I then convert into objects used within our application. Is there a sensible pattern for doing this ? We have written transform methods to output our objects from the axis created objects, at other times we have written an intermediate set of transformer classes that transform the axis objects to our application objects? Is there a common way of approaching this?

like image 774
Davocs Avatar asked Oct 27 '08 16:10

Davocs


3 Answers

If I understand correctly, you want to use Axis WSDL2Java feature to generate code from a WSDL and then map that to your existing application object model. In that case, you might want to consider to use Axis with JiBX binding.

like image 179
Buu Nguyen Avatar answered Nov 14 '22 02:11

Buu Nguyen


If the goal is to translate the "axis generated" to your business objects you can try a tool like dozer (http://dozer.sourceforge.net/) that is a "mapper" to copy from an object implementation to another implementation. It don't know how to use it (I think you have to explain the translation in xml files) and then it should work (I didn't used myself but some colleagues used it for a similar purpose and it seemed to work)

like image 41
Vinze Avatar answered Nov 14 '22 01:11

Vinze


I guess there is a common sense way of doing that. Abstract a bit your mind and imagine layers.

  1. You get a library with the basic IO and perhaps basic session functionality and/or credentials.
  2. Create a convert layer. Here you will place all the code needed to build your application dependent objects. Finish this layer with a nice interface for your application.

The convertion layer can be done in multiple ways.

  • If the conversion is simple, you can merge the first and second layer almost in one. Extend the POJOS to provide transformation functionality. This will give you, at least two pieces of code, the automatically generated and the extensions + functionality

  • If we're talking about huge XMLs that need to be converted to multiple small application objects. Ok, leave the first layer as it is and in the second use:

    • Command pattern: to encapsulate the transformations.
    • If the transformation also gets messy: Chain of responsibility will help you to generate a tree of transformations.

I hope this helps

like image 1
graffic Avatar answered Nov 14 '22 03:11

graffic