如何从JAXB生成JMX MXBean兼容的java类模型?

发布于 2024-09-05 01:45:17 字数 235 浏览 2 评论 0原文

从JMX MXBean规范来看,一个java类类型J必须满足

Either 如果 J 至少有一个带 ConstructorProperties 注释的公共构造函数, 或者 如果 J 有一个公共的无参数构造函数,并且对于 J 中类型 T 和名称 N 的每个 getter 都有一个具有相同名称和类型的对应 setter

那么我如何使用 JAXB 生成满足 MXBean 约束的 JAVA 类模型?

谢谢 于

From the JMX MXBean specification, a java class type J must satisfy

Either
if J has at least one public constructor with a ConstructorProperties annotation,
Or
if J has a public no-arg constructor, and for every getter in J with type T and name N there is a corresponding setter with the same name and type

So how can I use JAXB to generate JAVA class model which satisfy the MXBean constrain?

Thanks
YU

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘和柠 2024-09-12 01:45:17

JAXB 满足 getter/setter 约束,不是吗?或者,xjc 满足它。 JAXB本身只是一个框架。 xjc 用于从 XML 模式定义文件生成 Java 代码。

至于注释:这个好像没有必要。 JAXB 始终需要一个无参数构造函数来进行解组。

如果这听起来不适合您,也许您可​​以澄清您的问题(如果合适,可以用一个小例子)。

JAXB satisfies the getter/setter constraint, doesn't it? Or, rather xjc satisfies it. JAXB itself is just the framework. xjc is used to generate Java code from an XML schema definition file.

As for the annotation: This doesn't seem to be necessary. JAXB always needs a no-arg constructor for unmarshalling.

If this doesn't sound right to you, maybe you could clarify your question (with a small example if appropriate).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文