JAXB: How to generate serializable classes in runtime?
I use runtime generation of java code from xsd like this:
SchemaCompiler sc = XJC.createSchemaCompiler();
sc.forcePackageName(md5_dig);
sc.parseSchema(new InputSource(string_url));
S2JJAXBModel model = sc.bind();
JCodeModel jcmodel = model.generateCode(null,null);
try{
jcmodel.build(dir_src);
}catch (IOException ex){
log.severe(ex.toString());
}
How to generate serializable classes in this way?
[710 byte] By [
mbunnya] at [2007-11-27 0:14:15]

# 2
I can't. That schemas are used in another project where they are in one compilation into java classes, so I can't annotate global bindings in each schema.
Now I do the next workaround:
SchemaCompiler sc = XJC.createSchemaCompiler();
sc.forcePackageName(md5_dig);
sc.parseSchema(new InputSource("http://otherlocation/dummy.xsd"));
sc.parseSchema(new InputSource(string_url));
S2JJAXBModel model = sc.bind();
JCodeModel jcmodel = model.generateCode(null, null);
Global bindings are annotated in empty dummy.xsd in different location.
But I hope there is another way...