users@jaxb.java.net

Réf. : Re: Plugin problem

From: Patrick BRUNETON <patrick.bruneton_at_eads.com>
Date: Mon, 29 Aug 2005 18:28:20 +0200

I have been using JAXB 2 since two weeks. It works very fine ! I have
developped my own plugin that modifies the generated code. I faced some
problems during the development because I did not found enough API in the
codemodel package.

- My plugin has to modify the get/set methods generated by xjc. The
existing API allow to add statments at the end of body of method but I did
not find how to add statments at the begining. I need to transform the code

   getXXX()
   {
       return xxx;
   }

   into

   getXXX()
   {
       <my code>
       return xxx;
   }

   I managed to do it but I used reflection on the codemodel classes to
access private fields.

- In the same way, I have to change the type of a generated field. It seems
not possible with the current API. Again I used reflection to achieve my
goals. Also it is not possible to remove a field from a JDefinedClass.

Is it possible to add some methods in the codmodel to avoid these tricks ?

I had also another problem, but I don't expect a change for this because
it's probably quite unusual : I need to be able to unmarshall into an
existing object, rather than in a new object. I managed to do it but with a
(little but ugly) patch to the source code.

Regards
Patrick Bruneton.