Author: veithen
Date: Thu Jan 21 07:46:08 2016
New Revision: 1725879
URL: http://svn.apache.org/viewvc?rev=1725879&view=rev
Log:
Move some methods with dubious code from BuilderUtil and
MessageProcessorSelector into the class that is the only consumer of those
methods (i.e. MessageExternalizeUtils).
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?rev=1725879&r1=1725878&r2=1725879&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
(original)
+++
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
Thu Jan 21 07:46:08 2016
@@ -53,7 +53,6 @@ import org.apache.axis2.engine.AxisConfi
import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.util.JavaUtils;
-import org.apache.axis2.util.MessageProcessorSelector;
import org.apache.axis2.util.MultipleEntryHashMap;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.io.IOUtils;
@@ -63,7 +62,6 @@ import org.apache.ws.commons.schema.*;
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
-import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.BufferedReader;
@@ -458,35 +456,7 @@ public class BuilderUtil {
return value;
}
- public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
- InputStream inStream,
String contentTypeString,
- boolean isSOAP)
- throws OMException, XMLStreamException, FactoryConfigurationError {
- StAXBuilder builder = null;
- XMLStreamReader streamReader;
-
- Attachments attachments = createAttachmentsMap(msgContext, inStream,
contentTypeString);
- String charSetEncoding =
getCharSetEncoding(attachments.getRootPartContentType());
-
- if ((charSetEncoding == null)
- || "null".equalsIgnoreCase(charSetEncoding)) {
- charSetEncoding = MessageContext.UTF_8;
- }
- msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
- charSetEncoding);
-
- streamReader =
StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream(),
charSetEncoding);
-
- // Setting the Attachments map to new SwA API
- msgContext.setAttachmentMap(attachments);
-
- String soapEnvelopeNamespaceURI =
getEnvelopeNamespace(contentTypeString);
-
- return MessageProcessorSelector.getAttachmentBuilder(msgContext,
attachments, streamReader, soapEnvelopeNamespaceURI, isSOAP);
-
- }
-
- protected static Attachments createAttachmentsMap(MessageContext
msgContext,
+ public static Attachments createAttachmentsMap(MessageContext msgContext,
InputStream inStream,
String
contentTypeString) {
boolean fileCacheForAttachments =
isAttachmentsCacheEnabled(msgContext);
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java?rev=1725879&r1=1725878&r2=1725879&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java
(original)
+++
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/externalize/MessageExternalizeUtils.java
Thu Jan 21 07:46:08 2016
@@ -19,11 +19,21 @@
package org.apache.axis2.context.externalize;
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.MTOMConstants;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.builder.BuilderUtil;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.MessageFormatter;
@@ -38,6 +48,10 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.OutputStream;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
/**
* Utility to read/write the Message of a MessageContext
* Message Object Format.
@@ -169,6 +183,73 @@ public class MessageExternalizeUtils im
}
}
+ private static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
+ InputStream inStream, String contentTypeString,
+ boolean isSOAP)
+ throws OMException, XMLStreamException, FactoryConfigurationError {
+ StAXBuilder builder = null;
+ XMLStreamReader streamReader;
+
+ Attachments attachments = BuilderUtil.createAttachmentsMap(msgContext,
inStream, contentTypeString);
+ String charSetEncoding =
BuilderUtil.getCharSetEncoding(attachments.getRootPartContentType());
+
+ if ((charSetEncoding == null)
+ || "null".equalsIgnoreCase(charSetEncoding)) {
+ charSetEncoding = MessageContext.UTF_8;
+ }
+ msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
+ charSetEncoding);
+
+ streamReader =
StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream(),
charSetEncoding);
+
+ // Setting the Attachments map to new SwA API
+ msgContext.setAttachmentMap(attachments);
+
+ String soapEnvelopeNamespaceURI =
BuilderUtil.getEnvelopeNamespace(contentTypeString);
+
+ return getAttachmentBuilder(msgContext, attachments, streamReader,
soapEnvelopeNamespaceURI, isSOAP);
+
+ }
+
+ private static StAXBuilder getAttachmentBuilder(MessageContext msgContext,
+ Attachments attachments, XMLStreamReader streamReader, String
soapEnvelopeNamespaceURI,
+ boolean isSOAP) throws OMException, XMLStreamException,
FactoryConfigurationError {
+
+ StAXBuilder builder = null;
+
+ if (isSOAP) {
+ if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.MTOM_TYPE)) {
+ //Creates the MTOM specific MTOMStAXSOAPModelBuilder
+ builder = new MTOMStAXSOAPModelBuilder(streamReader,
+ attachments, soapEnvelopeNamespaceURI);
+ msgContext.setDoingMTOM(true);
+ } else if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.SWA_TYPE)) {
+ builder = new StAXSOAPModelBuilder(streamReader,
+ soapEnvelopeNamespaceURI);
+ } else if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.SWA_TYPE_12)) {
+ builder = new StAXSOAPModelBuilder(streamReader,
+ soapEnvelopeNamespaceURI);
+ }
+
+ }
+ // To handle REST XOP case
+ else {
+ if
(attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
+ builder = new XOPAwareStAXOMBuilder(streamReader, attachments);
+
+ } else if
(attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
+ builder = new StAXOMBuilder(streamReader);
+ } else if
(attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE_12)) {
+ builder = new StAXOMBuilder(streamReader);
+ }
+ }
+
+ return builder;
+ }
+
/**
* Read the Message
* @param in
@@ -231,11 +312,7 @@ public class MessageExternalizeUtils im
try {
if (optimized) {
boolean isSOAP = true;
- builder =
- BuilderUtil.getAttachmentsBuilder(mc,
- mis,
- optimizedContentType,
- isSOAP);
+ builder = getAttachmentsBuilder(mc, mis, optimizedContentType,
isSOAP);
envelope = (SOAPEnvelope) builder.getDocumentElement();
envelope.buildWithAttachments();
} else {
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java?rev=1725879&r1=1725878&r2=1725879&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
(original)
+++
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
Thu Jan 21 07:46:08 2016
@@ -19,14 +19,6 @@
package org.apache.axis2.util;
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.impl.MTOMConstants;
-import org.apache.axiom.om.impl.builder.StAXBuilder;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
-import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.builder.Builder;
@@ -41,9 +33,6 @@ import org.apache.axis2.transport.http.X
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import java.util.Map;
/**
@@ -163,47 +152,6 @@ public class MessageProcessorSelector {
return messageFormatter;
}
- public static StAXBuilder getAttachmentBuilder(MessageContext msgContext,
- Attachments attachments,
XMLStreamReader streamReader,
- String
soapEnvelopeNamespaceURI,
- boolean isSOAP)
- throws OMException, XMLStreamException, FactoryConfigurationError {
-
- StAXBuilder builder = null;
-
- if (isSOAP) {
- if (attachments.getAttachmentSpecType().equals(
- MTOMConstants.MTOM_TYPE)) {
- //Creates the MTOM specific MTOMStAXSOAPModelBuilder
- builder = new MTOMStAXSOAPModelBuilder(streamReader,
- attachments, soapEnvelopeNamespaceURI);
- msgContext.setDoingMTOM(true);
- } else if (attachments.getAttachmentSpecType().equals(
- MTOMConstants.SWA_TYPE)) {
- builder = new StAXSOAPModelBuilder(streamReader,
- soapEnvelopeNamespaceURI);
- } else if (attachments.getAttachmentSpecType().equals(
- MTOMConstants.SWA_TYPE_12)) {
- builder = new StAXSOAPModelBuilder(streamReader,
- soapEnvelopeNamespaceURI);
- }
-
- }
- // To handle REST XOP case
- else {
- if
(attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
- builder = new XOPAwareStAXOMBuilder(streamReader, attachments);
-
- } else if
(attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
- builder = new StAXOMBuilder(streamReader);
- } else if
(attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE_12)) {
- builder = new StAXOMBuilder(streamReader);
- }
- }
-
- return builder;
- }
-
private static String getMessageFormatterProperty(MessageContext
msgContext) {
String messageFormatterProperty = null;
Object property = msgContext