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 generate fieldoutlines cpropertyinfos. step between model , outline. if want different code generated out of model, consider implementing own fieldrendererfactory. can register fieldrendererfactory via xjc plugin (see options.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 jdefinedclasses there, code model exists already.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -