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

查看:28
本文介绍了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?

提前致谢,罗伊

推荐答案

对于 JAXB RI,已经处理了带有剧集"文件(这些实际上只是自定义文件).首先处理核心架构,确保让 xjc 使用-episode 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天全站免登陆