Hi Luca
You have written the code exactly as I would have, given my limited
knowledge. One thing I noticed is that you have the parent class
injected by JiBX. Are you sure this injection has been performed at the
time your decorator is invoked? You could try hardcoding the parent
class to see if that bit works.
cheers
Nigel
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
jibx-users@lists.sourceforge.net
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
jibx-users@lists.sourceforge.net
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
jibx-users@lists.sourceforge.net
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
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users