From 5ab5d742aabe5961ead7e1e039d3bfdbe98cbf3b Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 13 Jun 2007 22:51:53 +0000 Subject: [PATCH] Added mtomEnabled property. --- .../springframework/oxm/jaxb/Jaxb2Marshaller.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index b802bbd4..219248b2 100644 --- a/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -93,6 +93,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller implements MimeMarsh private Map jaxbContextProperties; + private boolean mtomEnabled = true; + /** * Sets the XmlAdapters to be registered with the JAXB Marshaller and * Unmarshaller @@ -124,6 +126,14 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller implements MimeMarsh this.marshallerListener = marshallerListener; } + /** + * Indicates whether MTOM support should be enabled or not. Default is true, marshalling using XOP/MTOM + * is enabled. + */ + public void setMtomEnabled(boolean mtomEnabled) { + this.mtomEnabled = mtomEnabled; + } + /** * Sets the schema language. Default is the W3C XML Schema: http://www.w3.org/2001/XMLSchema". * @@ -252,7 +262,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller implements MimeMarsh public void marshal(Object graph, Result result, MimeContainer mimeContainer) throws XmlMappingException { try { Marshaller marshaller = createMarshaller(); - if (mimeContainer != null) { + if (mtomEnabled && mimeContainer != null) { marshaller.setAttachmentMarshaller(new Jaxb2AttachmentMarshaller(mimeContainer)); } if (result instanceof StaxResult) { @@ -291,7 +301,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller implements MimeMarsh public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException { try { Unmarshaller unmarshaller = createUnmarshaller(); - if (mimeContainer != null) { + if (mtomEnabled && mimeContainer != null) { unmarshaller.setAttachmentUnmarshaller(new Jaxb2AttachmentUnmarshaller(mimeContainer)); } if (source instanceof StaxSource) {