You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2007/07/12 14:33:56 UTC
svn commit: r555611 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
Author: scheu
Date: Thu Jul 12 05:33:56 2007
New Revision: 555611
URL: http://svn.apache.org/viewvc?view=rev&rev=555611
Log:
JIRA AXIS2-2943
Contributor: Rich Scheuerle
Changes to BuilderUtil to pass the CONTENT-LENGTH value to the Axiom Attachments constructor.
The Axiom Attachments constructor uses the CONTENT-LENGTH to determine if the attachments should
be represented as a PartOnFile or PartOnMemory. This new heuristic avoids excessive byte buffering
and will reduce memory footprint and improve performance.
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?view=diff&rev=555611&r1=555610&r2=555611
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Thu Jul 12 05:33:56 2007
@@ -69,6 +69,7 @@
import java.io.PushbackInputStream;
import java.io.Reader;
import java.util.Iterator;
+import java.util.Map;
public class BuilderUtil {
private static final Log log = LogFactory.getLog(BuilderUtil.class);
@@ -451,9 +452,45 @@
}
}
- Attachments attachments = new Attachments(inStream, contentTypeString,
- fileCacheForAttachments, attachmentRepoDir,
- attachmentSizeThreshold);
+ // Get the content-length if it is available
+ int contentLength = 0;
+ Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+ if (headers != null) {
+ String contentLengthValue = (String) headers.get(HTTPConstants.HEADER_CONTENT_LENGTH);
+ if (contentLengthValue != null) {
+ try {
+ contentLength = new Integer(contentLengthValue).intValue();
+ } catch (NumberFormatException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Content-Length is not a valid number. Will assume it is not set:" + e);
+ }
+ }
+ }
+ }
+ Attachments attachments = null;
+ if (contentLength > 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating an Attachments map. The content-length is" + contentLength);
+ }
+ attachments =
+ new Attachments(inStream,
+ contentTypeString,
+ fileCacheForAttachments,
+ attachmentRepoDir,
+ attachmentSizeThreshold,
+ contentLength);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating an Attachments map.");
+ }
+ attachments =
+ new Attachments(inStream,
+ contentTypeString,
+ fileCacheForAttachments,
+ attachmentRepoDir,
+ attachmentSizeThreshold);
+ }
+
return attachments;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org