You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/12/03 19:17:54 UTC
svn commit: r1209962 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments:
MIMEMessage.java PartContent.java PartContentFactory.java
PartDataHandler.java PartDataSource.java PartImpl.java
Author: veithen
Date: Sat Dec 3 18:17:53 2011
New Revision: 1209962
URL: http://svn.apache.org/viewvc?rev=1209962&view=rev
Log:
AXIOM-377: More cleanup.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContent.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContentFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataSource.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartImpl.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java Sat Dec 3 18:17:53 2011
@@ -136,10 +136,10 @@ class MIMEMessage extends AttachmentsImp
}
}
- // Read the SOAP part and cache it
+ // Read the root part and cache it
getDataHandler(getRootPartContentID());
- // Now reset partsRequested. SOAP part is a special case which is always
+ // Now reset partsRequested. The root part is a special case which is always
// read beforehand, regardless of request.
partsRequested = false;
}
@@ -187,7 +187,7 @@ class MIMEMessage extends AttachmentsImp
dh = getDataHandler(getRootPartContentID());
if (dh == null) {
throw new OMException(
- "Mandatory Root MIME part containing the SOAP Envelope is missing");
+ "Mandatory root MIME part is missing");
}
return dh.getInputStream();
} catch (IOException e) {
@@ -199,7 +199,7 @@ class MIMEMessage extends AttachmentsImp
String getRootPartContentID() {
String rootContentID = contentType.getParameter("start");
if (log.isDebugEnabled()) {
- log.debug("getSOAPPartContentID rootContentID=" + rootContentID);
+ log.debug("getRootPartContentID rootContentID=" + rootContentID);
}
// to handle the Start parameter not mentioned situation
@@ -226,15 +226,15 @@ class MIMEMessage extends AttachmentsImp
}
String getRootPartContentType() {
- String soapPartContentID = getRootPartContentID();
- if (soapPartContentID == null) {
- throw new OMException("Unable to determine the content ID of the SOAP part");
- }
- DataHandler soapPart = getDataHandler(soapPartContentID);
- if (soapPart == null) {
- throw new OMException("Unable to locate the SOAP part; content ID was " + soapPartContentID);
+ String rootPartContentID = getRootPartContentID();
+ if (rootPartContentID == null) {
+ throw new OMException("Unable to determine the content ID of the root part");
+ }
+ DataHandler rootPart = getDataHandler(rootPartContentID);
+ if (rootPart == null) {
+ throw new OMException("Unable to locate the root part; content ID was " + rootPartContentID);
}
- return soapPart.getContentType();
+ return rootPart.getContentType();
}
IncomingAttachmentStreams getIncomingAttachmentStreams() {
@@ -342,13 +342,13 @@ class MIMEMessage extends AttachmentsImp
partsRequested = true;
- boolean isSOAPPart = (partIndex == 0);
+ boolean isRootPart = (partIndex == 0);
try {
List headers = readHeaders();
partIndex++;
- currentPart = new PartImpl(this, isSOAPPart, headers, parser);
+ currentPart = new PartImpl(this, isRootPart, headers, parser);
return currentPart;
} catch (IOException ex) {
throw new OMException(ex);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContent.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContent.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContent.java Sat Dec 3 18:17:53 2011
@@ -67,7 +67,20 @@ abstract class PartContent {
*/
abstract void writeTo(OutputStream out) throws IOException;
+ /**
+ * Get the size of the MIME part, more precisely the number of bytes in the decoded content of
+ * the MIME part.
+ *
+ * @return the size of the MIME part
+ */
abstract long getSize();
+ /**
+ * Release all resources used to store the content of the MIME part. The content will no longer
+ * be accessible after this method is called.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
abstract void destroy() throws IOException;
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContentFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContentFactory.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContentFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartContentFactory.java Sat Dec 3 18:17:53 2011
@@ -55,7 +55,7 @@ class PartContentFactory {
*
* @param manager
* @param in
- * @param isSOAPPart
+ * @param isRootPart
* @param thresholdSize
* @param attachmentDir
* @param messageContentLength
@@ -64,14 +64,14 @@ class PartContentFactory {
* if any exception is encountered while processing.
*/
static PartContent createPartContent(LifecycleManager manager, InputStream in,
- boolean isSOAPPart,
+ boolean isRootPart,
int thresholdSize,
String attachmentDir,
int messageContentLength
) throws OMException {
if(log.isDebugEnabled()){
log.debug("Start createPart()");
- log.debug(" isSOAPPart=" + isSOAPPart);
+ log.debug(" isRootPart=" + isRootPart);
log.debug(" thresholdSize= " + thresholdSize);
log.debug(" attachmentDir=" + attachmentDir);
log.debug(" messageContentLength " + messageContentLength);
@@ -87,9 +87,9 @@ class PartContentFactory {
// Allowing fewer threads reduces the thrashing. And when the remaining threads
// are notified their input (chunked) data is available.
//
- // Note: SOAPParts are at the beginning of the message and much smaller than attachments,
- // so don't wait on soap parts.
- if (!isSOAPPart) {
+ // Note: the root part is at the beginning of the message and much smaller than attachments,
+ // so don't wait on root parts.
+ if (!isRootPart) {
synchronized(semaphore) {
if (inflight >= INFLIGHT_MAX) {
semaphore.wait();
@@ -98,19 +98,19 @@ class PartContentFactory {
}
}
// Get new threshold based on the current available memory in the runtime.
- // We only use the thresholds for non-soap parts.
- if (!isSOAPPart && thresholdSize > 0) {
+ // We only use the thresholds for non-root parts.
+ if (!isRootPart && thresholdSize > 0) {
thresholdSize = getRuntimeThreshold(thresholdSize, inflight);
}
- if (isSOAPPart ||
+ if (isRootPart ||
thresholdSize <= 0 ||
(messageContentLength > 0 &&
messageContentLength < thresholdSize)) {
// If the entire message is less than the threshold size,
// keep it in memory.
- // If this is a SOAPPart, keep it in memory.
+ // If this is the root part, keep it in memory.
// Get the bytes of the data without a lot
// of resizing and GC. The BAAOutputStream
@@ -139,7 +139,7 @@ class PartContentFactory {
}
} finally {
- if (!isSOAPPart) {
+ if (!isRootPart) {
synchronized(semaphore) {
semaphore.notify();
inflight--;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java Sat Dec 3 18:17:53 2011
@@ -27,6 +27,9 @@ import javax.activation.DataSource;
import org.apache.axiom.attachments.lifecycle.DataHandlerExt;
+/**
+ * {@link DataHandler} implementation for MIME parts read from a stream.
+ */
class PartDataHandler extends DataHandler implements DataHandlerExt {
private final PartImpl part;
private DataSource dataSource;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataSource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataSource.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataSource.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataSource.java Sat Dec 3 18:17:53 2011
@@ -24,6 +24,11 @@ import java.io.OutputStream;
import org.apache.axiom.ext.activation.SizeAwareDataSource;
+/**
+ * Default {@link DataSource} implementation for MIME parts. This implementation will be used if
+ * there is no {@link DataSource} implementation specific to the buffering strategy being used, i.e.
+ * if {@link PartContent#getDataSource(String)} returns <code>null</code>.
+ */
class PartDataSource implements SizeAwareDataSource {
private final PartImpl part;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartImpl.java?rev=1209962&r1=1209961&r2=1209962&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartImpl.java Sat Dec 3 18:17:53 2011
@@ -66,7 +66,7 @@ final class PartImpl implements Part {
private static Log log = LogFactory.getLog(PartImpl.class);
private final MIMEMessage message;
- private final boolean isSOAPPart;
+ private final boolean isRootPart;
private List/*<Header>*/ headers;
@@ -90,9 +90,9 @@ final class PartImpl implements Part {
* @see org.apache.axiom.attachments.PartContentFactory
* @param headers
*/
- PartImpl(MIMEMessage message, boolean isSOAPPart, List headers, MimeTokenStream parser) {
+ PartImpl(MIMEMessage message, boolean isRootPart, List headers, MimeTokenStream parser) {
this.message = message;
- this.isSOAPPart = isSOAPPart;
+ this.isRootPart = isRootPart;
this.headers = headers;
this.parser = parser;
this.dataHandler = new PartDataHandler(this);
@@ -172,7 +172,7 @@ final class PartImpl implements Part {
// The PartFactory will determine which Part implementation is most appropriate.
content = PartContentFactory.createPartContent(message.getLifecycleManager(),
parser.getDecodedInputStream(),
- isSOAPPart,
+ isRootPart,
message.getThreshold(),
message.getAttachmentRepoDir(),
message.getContentLengthIfKnown()); // content-length for the whole message