0

I have legacy code that implements 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.");
        }
    }
    .
    .
    .
}

I am upgrading this code to Spring 5 and the class StaxSource is not in Spring 5. How can this be rewritten to work for Spring 5?

Paul Reiners
  • 8,576
  • 33
  • 117
  • 202

1 Answers1

0
import org.springframework.util.xml.StaxUtils;
    .
    .
    .
            return this.context.unmarshal(au, StaxUtils.getXMLStreamReader(source));
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202