Hi Andrea,

Munging the generated code in the AST with a ClassDecorator valueAdded() 
or finish() method is the only way you can currently do this. You should 
only need to change the initializer for the field to make this work. 
Changing the initializer to your own custom List implementation will 
leave you with an unnecessary ArrayList import in the generated class, 
but that's harmless.

I've thought about adding a customization to handle this, but the number 
of supported customizations is already large and I'd prefer to avoid any 
more complexity. Once the current code has had some time to settle and 
the weaknesses become clear I'll see about making it more flexible for a 
2.0 release.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Andrea Cisternino wrote:
> Hi all,
>
> I've been using JiBX 1.2.1 + CodeGen on a few large and complex
> schemas used in inter-bank communication.
> So far JiBX proved to be fast, effective, and reliable. CodeGen is
> also a great improvement over what was available in 1.6.
> Great job Dennis!
>
> Given the structure and size (> 200MB) of the XML files that we expect
> to receive we cannot hold the collections of some objects in memory
> during both unmarshalling and marshalling. Currently this is the only
> option because the generated classes have their List implementation
> hardcoded to ArrayList.
>
> I have been playing with class decorators and I have been able to
> nicely alter the generated classes structure adding a few extra fields
> and methods needed by our infrastructure but now I need to change the
> implementation of List from ArrayList to our own derived class that
> overrides the add() and get() methods to perform our business logic.
>
> At the moment I'm thinking of using the ClassDecorator finish() method
> to scan the completed class structure and perform the changes. I also
> thought about using the valueAdded() method but it seems to be called
> _after_ the value is added to the class and so it seems to provide no
> real value over a final pass in the finish() method.
>
> An alternative approach could be using the binding file and customize
> the List type implementation using the factory attribute but this
> works for unmarshalling only.
>
> Has anyone tried this before and care to comment?
>
> In the meantime I will keep experimenting the CodeGen route and also
> digging into the CodeGen sources to understand what happens but this
> is a longer road :-)
>
> Thanks everybody.
>   

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to