Hi Luca, In the current CVS code for the 1.2.2 release I've added an ExtensionDecorator class which allows both setting the superclass and adding pre/post method calls to the binding definition. I don't remember if I had to fix anything in the 1.2.1 code to make this work properly, but I'm using the same approach of calling setSuperClassName() in the start() method. Can you build from the current CVS code and see if this works for you?
You can see the ExtensionDecorator source at http://jibx.cvs.sourceforge.net/viewvc/jibx/core/build/src/org/jibx/schema/codegen/extend/ExtensionDecorator.java?revision=1.1&view=markup - 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 Luca Buraggi wrote: > > Great suggestion ! Thank you Nigel, > Using the SerializableDecorator as a template I wrote this (really > trivial) code:|| > > --- > public class ClassExtensionDecorator implements ClassDecorator { > // injected by JIBX > private String m_parentClass; > > @Override > public void start(IClassHolder holder) { > if (getParentClass() != null) { > holder.addImport(getParentClass()); > holder.setSuperClassName(getParentClass()); > } > } > > ... omissis ... > > } > --- > > I tested it adding this statement to the CodeGen customization file: > > <class-decorator > class="it.mate.jibx.extension.ClassExtensionDecorator" > parent-class="it.mate.horus.model.BaseEntity"/> > > but the result is not as I expected: > - the "import it.mate.horus.model.BaseEntity;" line is added correctly > to the source but > - the "extends it.mate.horus.model.BaseEntity" is missing from the > class declaration statement > > it's evident that the method setSuperClassName(...) is not equivalent > to the addInterface(...) method, so I'm still wondering how to > continue ... > my next attempt will be probably to try using the setSuperClass(...) > method, but to use it I must have a ClassHolder object containing the > "it.mate.horus.model.BaseEntity" class ... I suppose ... I browsed the > source code but it looks not so sinple ... > What I really need it would be a better knowledge on the code > generation mechanism ... do you have any hint on wger to look for ? > > Thank you. > > > > Nigel Charman ha scritto: >> Hi Luca >> >> This can be acheived using class decorators >> (http://jibx.sourceforge.net/fromschema/codegen-customs.html#extend). >> >> |The org.jibx.schema.codegen.extend.SerializableDecorator class >> should give you a good starting point. >> >> regards >> nigel. >> | >> Luca Buraggi wrote: >>> Hi all, I am just a beginner with JIBX and I have a question: >>> >>> It is possible to customize the code generation of CodeGen to generate a >>> Java class, for a given XSD complex type, that extends a given super class ? >>> I have no control on the XSD schema, and I can't modify it. I would like >>> to generate a set of classes all sharing the same super class. >>> >>> Any help is appreciated. >>> >>> Regards >>> >>> >>> ------------------------------------------------------------------------------ >>> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your >>> production scanning environment may not be a perfect world - but thanks to >>> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK >>> i700 >>> Series Scanner you'll get full speed at 300 dpi even with all image >>> processing features enabled. http://p.sf.net/sfu/kodak-com >>> _______________________________________________ >>> jibx-users mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/jibx-users >>> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------------ >> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your >> production scanning environment may not be a perfect world - but thanks to >> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 >> Series Scanner you'll get full speed at 300 dpi even with all image >> processing features enabled. http://p.sf.net/sfu/kodak-com >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> jibx-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/jibx-users >> > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > ------------------------------------------------------------------------ > > _______________________________________________ > jibx-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
