0

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

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.");
        }
    }
    .
    .
    .
}

我正在将此代码升级到 Spring 5 并且该类StaxSource不在 Spring 5 中。如何重写以适用于 Spring 5?

4

1 回答 1

0
import org.springframework.util.xml.StaxUtils;
    .
    .
    .
            return this.context.unmarshal(au, StaxUtils.getXMLStreamReader(source));
于 2020-01-29T19:37:52.300 回答