Author: barrettj
Date: Fri Apr 9 20:07:06 2010
New Revision: 932570
URL: http://svn.apache.org/viewvc?rev=932570&view=rev
Log:
Support for MTOM.threshold on the client set via a WebServiceFeature on the
factory APIs or via a sparse composite.
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentMarshaller.java
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentMarshaller.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentMarshaller.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentMarshaller.java?rev=932570&r1=932569&r2=932570&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentMarshaller.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentMarshaller.java
Fri Apr 9 20:07:06 2010
@@ -111,32 +111,35 @@ public class JAXBAttachmentMarshaller ex
String cid = null;
- try {
- // Create MIME Body Part
- InternetHeaders ih = new InternetHeaders();
- ih.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, mimeType);
- MimeBodyPart mbp = new MimeBodyPart(ih, data);
-
- //Create a data source for the MIME Body Part
- MimePartDataSource mpds = new MimePartDataSource(mbp);
- long dataLength =data.length;
- Integer value = null;
- if (msgContext != null) {
- value = (Integer)
msgContext.getProperty(Constants.Configuration.MTOM_THRESHOLD);
- }
- int optimizedThreshold = (value != null) ? value.intValue() :
0;
-
- if(optimizedThreshold==0 || dataLength > optimizedThreshold){
- DataHandler dataHandler = new DataHandler(mpds);
- cid = addDataHandler(dataHandler);
- }
-
- // Add the content id to the mime body part
- mbp.setHeader(HTTPConstants.HEADER_CONTENT_ID, cid);
- } catch (MessagingException e) {
- throw new OMException(e);
+ try {
+ // Create MIME Body Part
+ InternetHeaders ih = new InternetHeaders();
+ ih.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, mimeType);
+ MimeBodyPart mbp = new MimeBodyPart(ih, data);
+
+ //Create a data source for the MIME Body Part
+ MimePartDataSource mpds = new MimePartDataSource(mbp);
+ long dataLength =data.length;
+ Integer value = null;
+ if (msgContext != null) {
+ value = (Integer)
msgContext.getProperty(Constants.Configuration.MTOM_THRESHOLD);
+ } else if (log.isDebugEnabled()) {
+ log.debug("The msgContext is null so the MTOM threshold value
can not be determined; it will default to 0.");
}
-
+
+ int optimizedThreshold = (value != null) ? value.intValue() : 0;
+
+ if(optimizedThreshold==0 || dataLength > optimizedThreshold){
+ DataHandler dataHandler = new DataHandler(mpds);
+ cid = addDataHandler(dataHandler);
+ }
+
+ // Add the content id to the mime body part
+ mbp.setHeader(HTTPConstants.HEADER_CONTENT_ID, cid);
+ } catch (MessagingException e) {
+ throw new OMException(e);
+ }
+
return cid == null ? null : "cid:" + cid;
}
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentMarshaller.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentMarshaller.java?rev=932570&r1=932569&r2=932570&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentMarshaller.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentMarshaller.java
Fri Apr 9 20:07:06 2010
@@ -19,6 +19,7 @@
package org.apache.axis2.jaxws.message.attachments;
+import org.apache.axis2.context.MessageContext;
import org.apache.axis2.jaxws.message.Message;
import javax.activation.DataHandler;
@@ -32,9 +33,24 @@ public class JAXBAttachmentMarshaller ex
private Message message;
public JAXBAttachmentMarshaller(Message message, XMLStreamWriter writer) {
- super(null, writer);
+ super(getAxis2MessageContext(message), writer);
this.message = message;
}
+
+ /**
+ * Get the Axis2 Message Context out of the Message by going through the
JAXWS Message Context.
+ * @param message The Message from which to get the Axis Message Context
+ * @return the Axis Message context or null if one is not found.
+ */
+ private static MessageContext getAxis2MessageContext(Message message) {
+ MessageContext axisMessageContext = null;
+ if (message != null) {
+ if (message.getMessageContext() != null) {
+ axisMessageContext =
message.getMessageContext().getAxisMessageContext();
+ }
+ }
+ return axisMessageContext;
+ }
/**
* @return if MTOM enabled calculated from the context information
*/