首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将MimeUnmarshaller代码迁移到Spring5

将MimeUnmarshaller代码迁移到Spring5
EN

Stack Overflow用户
提问于 2020-01-30 01:48:44
回答 1查看 22关注 0票数 0

我有实现org.springframework.oxm.mimeMimeUnmarshaller的遗留代码

代码语言:javascript
复制
import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.transform.Source;
import org.springframework.oxm.UnmarshallingFailureException;
import org.springframework.oxm.XmlMappingException;
import org.springframework.oxm.mime.MimeContainer;
import org.springframework.oxm.mime.MimeUnmarshaller;
import org.springframework.xml.transform.StaxSource;

public class MISMarshaller implements MimeUnmarshaller {
    .
    .
    .
    public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException {
        AttachmentUnmarshaller au = null;
        if (this.mtomEnabled && mimeContainer != null) {
            au = new MISMarshaller.MISAttachmentUnmarshaller(mimeContainer);
        }

        if (source instanceof StaxSource && ((StaxSource)source).getXMLStreamReader() != null) {
            try {
                return this.context.unmarshal(au, ((StaxSource)source).getXMLStreamReader());
            } catch (Exception var5) {
                throw new UnmarshallingFailureException(var5.getMessage(), var5);
            }
        } else {
            throw new IllegalStateException(
                "Only StAX is supported for MIS marshaller.  Use AXIOM message factory.");
        }
    }
    .
    .
    .
}

我正在将这段代码升级到Spring5,而StaxSource类不在Spring5中,如何重写它才能在Spring5中工作呢?

EN

回答 1

Stack Overflow用户

发布于 2020-01-30 03:37:52

代码语言:javascript
复制
import org.springframework.util.xml.StaxUtils;
    .
    .
    .
            return this.context.unmarshal(au, StaxUtils.getXMLStreamReader(source));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59972849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档