Spring MVC 3.0:避免显式 JAXBElement<>方法 arg 中的包装器

发布于 2024-08-29 21:08:27 字数 528 浏览 1 评论 0 原文

我有以下方法,并且希望避免必须显式显示 JAXBElement<>句法。是否有某种注释允许该方法看起来接受原始 MessageResponse 对象,但实际上工作原理与如下所示相同?我不确定这有多清楚,所以我会这样说:我正在寻找一些语法糖:)

    @ServiceActivator
public void handleMessageResponse(JAXBElement<MessageResponse> jaxbResponse) {
    MessageResponse response = jaxbResponse.getValue();
    MessageStatus status = messageStatusDao.getByStoreIdAndMessageId(response.getStoreId(), response.getMessageId());
    status.setStatusTimestamp(response.getDate());
    status.setStatus("Complete");
}

I have the following method and want to avoid having to explicitly show the JAXBElement<> syntax. Is there some sort of annotation that would allow the method to appear to accept raw MessageResponse objects but in actuality work the same as shown below? I'm not sure how clear that was so I'll say this: I'm looking for some syntactic sugar :)

    @ServiceActivator
public void handleMessageResponse(JAXBElement<MessageResponse> jaxbResponse) {
    MessageResponse response = jaxbResponse.getValue();
    MessageStatus status = messageStatusDao.getByStoreIdAndMessageId(response.getStoreId(), response.getMessageId());
    status.setStatusTimestamp(response.getDate());
    status.setStatus("Complete");
}

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

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

发布评论

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

评论(1

灼痛 2024-09-05 21:08:27

您可以使用参考指南中描述的解组转换器 此处

改编自文档(可在链中使用):

<si-xml:unmarshalling-transformer unmarshaller="unmarshaller" />

这应该为您提供一个域对象作为消息负载。

You can use the unmarshalling transformer described in the reference guide here.

Adapted from the documentation (usable in a chain):

<si-xml:unmarshalling-transformer unmarshaller="unmarshaller" />

This should give you a domain object as the message payload.

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