jaxb - JXB How to use different strategies of code generation -
usually, jaxb used generate code xsd, generates java classes xsd complextype
annotations convert xml , vice-versa.
i trying achieve different. want, generate data mapper class each such xsd element. mapper map each field of generated class values datatype (say database, or other stream)
so need to: every user-defined datatype in xsd, add method in datamapper
class map-<xsd-complexdatatype-class>()
, generate method body.
to achieve this, think not possible generate class in plugin extending com.sun.tools.internal.xjc.plugin
in run
method, wont able create new jdefinedclass
is there way add hook method before model
invokes plugins
?
thanks,
there few things can do. in my other answer specificaly meant these:
- in plugin can write , set own
com.sun.tools.xjc.generator.bean.field.fieldrendererfactory
. field renderers generatefieldoutline
scpropertyinfo
s. step between model , outline. if want different code generated out of model, consider implementing ownfieldrendererfactory
. can registerfieldrendererfactory
via xjc plugin (seeoptions.setfieldrendererfactory(...)
). - on class level, can write own
com.sun.tools.xjc.generator.bean.beangenerator
, use code generation. - you can use
model
, generate code on own. in jsonix when produce javascript mappings xml<->json.
as specific task, postprocess code model in run
method of plugin. have there - model
, outline
, code model (see outline.getcodemodel()
). , can create jdefinedclass
es there, code model exists already.
Comments
Post a Comment