Author: sagara
Date: Wed Sep 19 11:00:38 2012
New Revision: 1387522

URL: http://svn.apache.org/viewvc?rev=1387522&view=rev
Log:
AXIS2-5374 fixed .

* Introduced a new class called MessageProcessorSelector which encapsulate 
logics and algorithms when selecting MessageBuilders, AttachmentsBuilders and  
MessageFormatters, eventually related logics scattered in various places need 
to be moved to here.  

* REST support is now only depends on disableREST parameter. 

Added:
    
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
   (with props)
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/builder/MIMEBuilder.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/transport/TransportUtils.java
    
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
    
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
    
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
    
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.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=1387522&r1=1387521&r2=1387522&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
 Wed Sep 19 11:00:38 2012
@@ -57,6 +57,7 @@ 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.logging.Log;
@@ -454,37 +455,8 @@ public class BuilderUtil {
 
         String soapEnvelopeNamespaceURI = 
getEnvelopeNamespace(contentTypeString);
 
-        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 MessageProcessorSelector.getAttachmentBuilder(msgContext, 
attachments, streamReader, soapEnvelopeNamespaceURI, isSOAP);
 
-        return builder;
     }
 
     protected static Attachments createAttachmentsMap(MessageContext 
msgContext,

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java
 Wed Sep 19 11:00:38 2012
@@ -25,6 +25,7 @@ import org.apache.axiom.om.OMException;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.util.MessageProcessorSelector;
 
 import javax.mail.internet.ContentType;
 import javax.mail.internet.ParseException;
@@ -48,7 +49,7 @@ public class MIMEBuilder implements Buil
         
         String type = ct.getParameter("type");
         Builder builder =
-                BuilderUtil.getBuilderFromSelector(type, msgContext);
+                MessageProcessorSelector.getMessageBuilder(type, msgContext);
         
         if (builder instanceof MIMEAwareBuilder) {
             return ((MIMEAwareBuilder)builder).processMIMEMessage(attachments, 
type, 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=1387522&r1=1387521&r2=1387522&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
 Wed Sep 19 11:00:38 2012
@@ -27,7 +27,7 @@ import org.apache.axis2.AxisFault;
 import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -145,7 +145,7 @@ public class MessageExternalizeUtils  im
         try { 
             // Write out the message using the same logic as the 
             // transport layer.
-            MessageFormatter msgFormatter = 
TransportUtils.getMessageFormatter(mc);
+            MessageFormatter msgFormatter = 
MessageProcessorSelector.getMessageFormatter(mc);
             msgFormatter.writeTo(mc, outputFormat, bos, 
                                  true); // Preserve the original message
             

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
 Wed Sep 19 11:00:38 2012
@@ -43,11 +43,9 @@ import org.apache.axis2.context.Operatio
 import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.transport.http.ApplicationXMLFormatter;
 import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.transport.http.SOAPMessageFormatter;
-import org.apache.axis2.transport.http.XFormURLEncodedFormatter;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -196,7 +194,7 @@ public class TransportUtils {
         String type = null;
         if (contentType != null) {
             type = getContentType(contentType, msgContext);
-            Builder builder = BuilderUtil.getBuilderFromSelector(type, 
msgContext);
+            Builder builder = MessageProcessorSelector.getMessageBuilder(type, 
msgContext);
             if (builder != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("createSOAPEnvelope using Builder (" +
@@ -271,7 +269,8 @@ public class TransportUtils {
         if (msgContext.isDoingREST() && 
HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) {
             if (msgContext.isServerSide()) {
                 if (msgContext.getSoapAction() == null) {
-                    type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+                    // TODO - remove this logic. 
+                    //type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
                 }
             } else if 
(!msgContext.isPropertyTrue(Constants.Configuration.SOAP_RESPONSE_MEP)) {
                 type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
@@ -356,50 +355,7 @@ public class TransportUtils {
         }
     }
 
-    /**
-     * Initial work for a builder selector which selects the builder for a 
given message format based on the the content type of the recieved message.
-     * content-type to builder mapping can be specified through the Axis2.xml.
-     *
-     * @param msgContext
-     * @return the builder registered against the given content-type
-     * @throws AxisFault
-     */
-    public static MessageFormatter getMessageFormatter(MessageContext 
msgContext)
-            throws AxisFault {
-        MessageFormatter messageFormatter = null;
-        String messageFormatString = getMessageFormatterProperty(msgContext);
-        if (messageFormatString != null) {
-            messageFormatter = msgContext.getConfigurationContext()
-                    
.getAxisConfiguration().getMessageFormatter(messageFormatString);
-            if (log.isDebugEnabled()) {
-                log.debug("Message format is: " + messageFormatString
-                        + "; message formatter returned by AxisConfiguration: 
" + messageFormatter);
-            }
-        }
-        if (messageFormatter == null) {
-            messageFormatter = (MessageFormatter) 
msgContext.getProperty(Constants.Configuration.MESSAGE_FORMATTER);
-            if(messageFormatter != null) {
-                return messageFormatter;
-            }
-        }
-        if (messageFormatter == null) {
 
-            // If we are doing rest better default to Application/xml formatter
-            if (msgContext.isDoingREST()) {
-                String httpMethod = (String) 
msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
-                if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) 
||
-                        
Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) {
-                    return new XFormURLEncodedFormatter();
-                }
-                return new ApplicationXMLFormatter();
-            } else {
-                // Lets default to SOAP formatter
-                //TODO need to improve this to use the stateless nature
-                messageFormatter = new SOAPMessageFormatter();
-            }
-        }
-        return messageFormatter;
-    }
 
 
     /**
@@ -483,22 +439,7 @@ public class TransportUtils {
     }
 
 
-    private static String getMessageFormatterProperty(MessageContext 
msgContext) {
-        String messageFormatterProperty = null;
-        Object property = msgContext
-                .getProperty(Constants.Configuration.MESSAGE_TYPE);
-        if (property != null) {
-            messageFormatterProperty = (String) property;
-        }
-        if (messageFormatterProperty == null) {
-            Parameter parameter = msgContext
-                    .getParameter(Constants.Configuration.MESSAGE_TYPE);
-            if (parameter != null) {
-                messageFormatterProperty = (String) parameter.getValue();
-            }
-        }
-        return messageFormatterProperty;
-    }
+
 
 
         /**

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
 Wed Sep 19 11:00:38 2012
@@ -21,7 +21,6 @@ package org.apache.axis2.transport.http;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFault;
 import org.apache.axiom.soap.SOAPFaultDetail;
@@ -211,11 +210,13 @@ public class ApplicationXMLFormatter imp
         if (JavaUtils.indexOfIgnoreCase(contentType, 
SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
             return true;
         }
+        // 'text/xml' can be a POX (REST) content type too
+        // TODO - Remove 
         // search for "type=text/xml"
-        else if (JavaUtils.indexOfIgnoreCase(contentType, 
+        /*else if (JavaUtils.indexOfIgnoreCase(contentType,
                                              
SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
             return true;
-        }
+        }  */
         return false;
     }
 }

Added: 
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=1387522&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
 Wed Sep 19 11:00:38 2012
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.transport.MessageFormatter;
+import org.apache.axis2.transport.http.ApplicationXMLFormatter;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.SOAPMessageFormatter;
+import org.apache.axis2.transport.http.XFormURLEncodedFormatter;
+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;
+
+/**
+ * MessageProcessorSelector is utility class which encapsulate MessageBuilder 
and
+ * MessageFormatter selection logic.
+ *
+ * @since 1.7.0
+ */
+public class MessageProcessorSelector {
+
+    private static final Log log = 
LogFactory.getLog(MessageProcessorSelector.class);
+
+    /**
+     * Initial work for a builder selector which selects the builder for a 
given message format
+     * based on the the content type of the recieved message. content-type to 
builder mapping can be
+     * specified through the Axis2.xml.
+     *
+     * @param type       content-type
+     * @param msgContext the active MessageContext
+     * @return the builder registered against the given content-type
+     * @throws org.apache.axis2.AxisFault
+     */
+    public static Builder getMessageBuilder(String type, MessageContext 
msgContext)
+            throws AxisFault {
+        boolean useFallbackBuilder = false;
+        AxisConfiguration configuration =
+                msgContext.getConfigurationContext().getAxisConfiguration();
+        Parameter useFallbackParameter = 
configuration.getParameter(Constants.Configuration.USE_DEFAULT_FALLBACK_BUILDER);
+        if (useFallbackParameter != null) {
+            useFallbackBuilder = 
JavaUtils.isTrueExplicitly(useFallbackParameter.getValue(), useFallbackBuilder);
+        }
+
+        String cType = getContentTypeForBuilderSelection(type, msgContext);
+        Builder builder = configuration.getMessageBuilder(cType, 
useFallbackBuilder);
+        if (builder != null) {
+            // Check whether the request has a Accept header if so use that as 
the response
+            // message type.
+            // If thats not present,
+            // Setting the received content-type as the messageType to make
+            // sure that we respond using the received message serialization 
format.
+
+            Object contentNegotiation = configuration
+                    
.getParameterValue(Constants.Configuration.ENABLE_HTTP_CONTENT_NEGOTIATION);
+            if (JavaUtils.isTrueExplicitly(contentNegotiation)) {
+                Map transportHeaders =
+                        (Map) 
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+                if (transportHeaders != null) {
+                    String acceptHeader = (String) 
transportHeaders.get(HTTPConstants.HEADER_ACCEPT);
+                    if (acceptHeader != null) {
+                        int index = acceptHeader.indexOf(";");
+                        if (index > 0) {
+                            acceptHeader = acceptHeader.substring(0, index);
+                        }
+                        String[] strings = acceptHeader.split(",");
+                        for (String string : strings) {
+                            String accept = string.trim();
+                            // We dont want dynamic content negotoatin to work 
on text.xml as its
+                            // ambiguos as to whether the user requests SOAP 
1.1 or POX response
+                            if 
(!HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(accept) &&
+                                    configuration.getMessageFormatter(accept) 
!= null) {
+                                type = string;
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+
+            msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type);
+        }
+        return builder;
+    }
+
+    /**
+     * Initial work for a builder selector which selects the builder for a 
given message format based on the the content type of the recieved message.
+     * content-type to builder mapping can be specified through the Axis2.xml.
+     *
+     * @param msgContext
+     * @return the builder registered against the given content-type
+     * @throws AxisFault
+     */
+    public static MessageFormatter getMessageFormatter(MessageContext 
msgContext)
+            throws AxisFault {
+        MessageFormatter messageFormatter = null;
+        String messageFormatString = getMessageFormatterProperty(msgContext);
+        messageFormatString = 
getContentTypeForFormatterSelection(messageFormatString, msgContext);
+        if (messageFormatString != null) {
+            messageFormatter = msgContext.getConfigurationContext()
+                    
.getAxisConfiguration().getMessageFormatter(messageFormatString);
+            if (log.isDebugEnabled()) {
+                log.debug("Message format is: " + messageFormatString
+                        + "; message formatter returned by AxisConfiguration: 
" + messageFormatter);
+            }
+        }
+        if (messageFormatter == null) {
+            messageFormatter = (MessageFormatter) 
msgContext.getProperty(Constants.Configuration.MESSAGE_FORMATTER);
+            if (messageFormatter != null) {
+                return messageFormatter;
+            }
+        }
+        if (messageFormatter == null) {
+
+            // If we are doing rest better default to Application/xml formatter
+            if (msgContext.isDoingREST()) {
+                String httpMethod = (String) 
msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
+                if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) 
||
+                        
Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) {
+                    return new XFormURLEncodedFormatter();
+                }
+                return new ApplicationXMLFormatter();
+            } else {
+                // Lets default to SOAP formatter
+                //TODO need to improve this to use the stateless nature
+                messageFormatter = new SOAPMessageFormatter();
+            }
+        }
+        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
+                .getProperty(Constants.Configuration.MESSAGE_TYPE);
+        if (property != null) {
+            messageFormatterProperty = (String) property;
+        }
+        if (messageFormatterProperty == null) {
+            Parameter parameter = msgContext
+                    .getParameter(Constants.Configuration.MESSAGE_TYPE);
+            if (parameter != null) {
+                messageFormatterProperty = (String) parameter.getValue();
+            }
+        }
+        return messageFormatterProperty;
+    }
+
+    private static String getContentTypeForBuilderSelection(String type, 
MessageContext msgContext) {
+        /**
+         * Handle special case where content-type : text/xml and SOAPAction = 
null consider as
+         * POX (REST) message not SOAP 1.1.
+         *
+         * it's required use the Builder associate with "application/xml" here 
but should not
+         * change content type of current message.
+         *
+         */
+        String cType = type;
+        if (msgContext.getSoapAction() == null && 
HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type) && msgContext.isDoingREST()) {
+            cType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+        }
+        return cType;
+    }
+
+    private static String getContentTypeForFormatterSelection(String type, 
MessageContext msgContext) {
+        /**
+         * Handle special case where content-type : text/xml and SOAPAction = 
null consider as
+         * POX (REST) message not SOAP 1.1.
+         *
+         * 1.) it's required use the Builder associate with "application/xml" 
here but should not
+         * change content type of current message.
+         */
+        String cType = type;
+        if (msgContext.isDoingREST() && 
HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) {
+            cType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, 
HTTPConstants.MEDIA_TYPE_TEXT_XML);
+        }
+        return cType;
+    }
+
+}
\ No newline at end of file

Propchange: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/MessageProcessorSelector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
 Wed Sep 19 11:00:38 2012
@@ -35,6 +35,7 @@ import org.apache.axis2.transport.Transp
 import org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl;
 import org.apache.axis2.transport.http.server.AxisHttpResponse;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -336,7 +337,7 @@ public class CommonsHTTPTransportSender 
             }
         }
 
-        MessageFormatter messageFormatter = 
TransportUtils.getMessageFormatter(msgContext);
+        MessageFormatter messageFormatter = 
MessageProcessorSelector.getMessageFormatter(msgContext);
         if (messageFormatter == null) throw new AxisFault("No MessageFormatter 
in MessageContext");
 
         // Once we get to this point, exceptions should NOT be turned into 
faults and sent,

Modified: 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
 Wed Sep 19 11:00:38 2012
@@ -273,10 +273,10 @@ public class HTTPTransportUtils {
             if (soapVersion == VERSION_SOAP11) {
                 // TODO Keith : Do we need this anymore
                 // Deployment configuration parameter
-                Parameter enableREST = msgContext
-                        .getParameter(Constants.Configuration.ENABLE_REST);
-                if ((soapActionHeader == null) && (enableREST != null)) {
-                    if (Constants.VALUE_TRUE.equals(enableREST.getValue())) {
+                Parameter disableREST = msgContext
+                        .getParameter(Constants.Configuration.DISABLE_REST);
+                if (soapActionHeader == null && disableREST != null) {
+                    if (Constants.VALUE_FALSE.equals(disableREST.getValue())) {
                         // If the content Type is text/xml (BTW which is the
                         // SOAP 1.1 Content type ) and the SOAP Action is
                         // absent it is rest !!

Modified: 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
 Wed Sep 19 11:00:38 2012
@@ -42,11 +42,11 @@ import org.apache.axis2.context.NamedVal
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.TransportUtils;
 import org.apache.axis2.transport.http.HTTPAuthenticator;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
 import org.apache.axis2.transport.http.HTTPTransportConstants;
+import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
@@ -666,7 +666,8 @@ public class HTTPSenderImpl extends HTTP
             httpMethod.setDoAuthentication(true);
         }
 
-        MessageFormatter messageFormatter = 
TransportUtils.getMessageFormatter(msgContext);
+        MessageFormatter messageFormatter = MessageProcessorSelector
+                .getMessageFormatter(msgContext);
 
         url = messageFormatter.getTargetAddress(msgContext, format, url);
 

Modified: 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java?rev=1387522&r1=1387521&r2=1387522&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
 Wed Sep 19 11:00:38 2012
@@ -30,11 +30,11 @@ import org.apache.axis2.context.NamedVal
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.TransportUtils;
 import org.apache.axis2.transport.http.HTTPAuthenticator;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
 import org.apache.axis2.transport.http.HTTPTransportConstants;
+import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -656,7 +656,7 @@ public class HTTPSenderImpl extends HTTP
             
httpMethod.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, 
true);
         }
 
-        MessageFormatter messageFormatter = 
TransportUtils.getMessageFormatter(msgContext);
+        MessageFormatter messageFormatter = 
MessageProcessorSelector.getMessageFormatter(msgContext);
 
         url = messageFormatter.getTargetAddress(msgContext, format, url);
 


Reply via email to