JAXB - 创建模块以供重用 [英] JAXB - Creating modules for reuse

查看:127
本文介绍了JAXB - 创建模块以供重用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JAXB是否支持模块化代码生成?

Does JAXB support modular code generation?

我的大多数背景都是使用JibX进行XML编组,但由于遗留原因,我们公司正在使用JAXB。

Most of my background is with JibX for XML marshalling, but for legacy reasons our firm is using JAXB.

JIBX可用的一项功能是模块化代码代。假设我有一个主模式但我有几个不同的信封用于该模式。使用JibX,我可以用JibX的核心模式创建一个jar文件,然后在单独的项目中,我可以JibX我的信封模式,只需指向共享jar,而不必复制每个信封的核心模式的代码生成。

One feature that was available for JIBX was modular code generation. Say I have a main schema but I have several different envelopes for that schema. With JibX I could create a jar file out of the JibX'ed core schema, and then in separate projects I could JibX my envelope schemas and simply point to the shared jar instead of having to duplicate the code generation of the core schemas for each envelope.

我还没有看到JAXB处理这个问题的方法 - 有没有人成功做过这样的事情?

I don't yet see a way for JAXB to handle this - has anyone been successful doing something like this?

提前致谢,
Roy

Thanks in advance, Roy

推荐答案

对于 JAXB RI ,用episode文件处理(这些只是自定义文件)。首先处理核心模式,确保 xjc 使用 -episode< file> arg。使用 META-INF / sun-jaxb.episode 中的剧集文件将该处理的结果打包到JAR文件中。然后,在处理其他模式时,将该JAR文件作为arg传递给xjc。

For the JAXB RI, that's handled with "episode" files (these are really just customization files). Process the core schema first, making sure to have xjc use the -episode <file> arg. Package the results of that processing into a JAR file with the episode file in META-INF/sun-jaxb.episode. Then, pass that JAR file as an arg to xjc when processing the other schemas.

这篇关于JAXB - 创建模块以供重用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆