axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r475437 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: engine/ receivers/ transport/http/ transport/http/server/ transport/mail/ transport/mail/server/ transport/tcp/ util/
Date Wed, 15 Nov 2006 21:32:53 GMT
Author: davidillsley
Date: Wed Nov 15 13:32:52 2006
New Revision: 475437

URL: http://svn.apache.org/viewvc?view=rev&rev=475437
Log:
Merge and redo refactor of response MessageContext creation to take account of lots of common
code.
All roads now lead to the MessageContextBuilder

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/server/DefaultHttpServiceProcessor.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailWorker.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
Wed Nov 15 13:32:52 2006
@@ -17,38 +17,27 @@
 
 package org.apache.axis2.engine;
 
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPConstants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AddressingConstants.Final;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.util.JavaUtils;
-import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.xml.namespace.QName;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-
 /**
  * There is one engine for the Server and the Client. the send() and receive()
  * Methods are the basic operations the Sync, Async messageing are build on top.
@@ -129,336 +118,12 @@
      * This method is called to handle any error that occurs at inflow or outflow. But if
the
      * method is called twice, it implies that sending the error handling has failed, in
which case
      * the method logs the error and exists.
-     *
-     * @param processingContext
-     * @param e
-     * @throws AxisFault
+     * @deprecated (post 1.1 branch)
+     * @see org.apache.axis2.util.MessageContextBuilder.createFaultMessageContext()
      */
     public MessageContext createFaultMessageContext(MessageContext processingContext, Throwable
e)
             throws AxisFault {
-        if (processingContext.isProcessingFault()) {
-
-            // We get the error file processing the fault. nothing we can do
-            throw new AxisFault(Messages.getMessage("errorwhileProcessingFault"));
-        }
-
-        MessageContext faultContext = new MessageContext();
-        faultContext.setConfigurationContext(engineContext);
-        faultContext.setSessionContext(processingContext.getSessionContext());
-        faultContext.setTransportIn(processingContext.getTransportIn());
-        faultContext.setTransportOut(processingContext.getTransportOut());
-
-        faultContext.setMessageID(UUIDGenerator.getUUID());
-        faultContext.addRelatesTo(new RelatesTo(processingContext.getOptions().getMessageId()));
-        faultContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
-                processingContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
-        faultContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
-                processingContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION));
-        faultContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
-                processingContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
-
-        // register the fault message context
-        if (processingContext.getAxisOperation() != null && processingContext.getOperationContext()
!= null) {
-            processingContext.getAxisOperation().addFaultMessageContext(faultContext, processingContext.getOperationContext());
-        }
-
-        ServiceContext serviceContext = processingContext.getServiceContext();
-        if (serviceContext != null) {
-            faultContext.setServiceContext(serviceContext);
-        }
-
-        faultContext.setOperationContext(processingContext.getOperationContext());
-        faultContext.setProcessingFault(true);
-        faultContext.setServerSide(true);
-        faultContext.setDoingREST(processingContext.isDoingREST());
-
-        faultContext.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI));
-
-        // Add correct Action
-        AxisOperation op = processingContext.getAxisOperation();
-        if (op != null && op.getFaultAction() != null) {
-            faultContext.setWSAAction(processingContext.getAxisOperation().getFaultAction());
-        } else { //If, for some reason there is no value set, should use a sensible action.
-            faultContext.setWSAAction(Final.WSA_SOAP_FAULT_ACTION);
-        }
-
-        // there are some information  that the fault thrower wants to pass to the fault
path.
-        // Means that the fault is a ws-addressing one hence use the ws-addressing fault
action.
-        Object faultInfoForHeaders = processingContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
-        if (faultInfoForHeaders != null) {
-            faultContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInfoForHeaders);
-            faultContext.setWSAAction(Final.WSA_FAULT_ACTION);
-        }
-
-        // if the exception is due to a problem in the faultTo header itself, we can not
use those
-        // fault informatio to send the error. Try to send using replyTo, leave it to transport
-        boolean doNotSendFaultUsingFaultTo = false;
-        if (faultInfoForHeaders != null) {
-            String problemHeaderName = (String) ((Map) faultInfoForHeaders).get(AddressingConstants.Final.FAULT_HEADER_PROB_HEADER_QNAME);
-            doNotSendFaultUsingFaultTo = (problemHeaderName != null && (AddressingConstants.WSA_DEFAULT_PREFIX
+ ":" + AddressingConstants.WSA_FAULT_TO).equals(problemHeaderName));
-        }
-
-        EndpointReference faultTo = processingContext.getFaultTo();
-        if (faultTo != null && !doNotSendFaultUsingFaultTo) {
-            faultContext.setTo(faultTo);
-        } else {
-            faultContext.setTo(processingContext.getReplyTo());
-        }
-
-        // do Target Resolution
-        faultContext.getConfigurationContext().getAxisConfiguration().getTargetResolverChain().resolveTarget(faultContext);
-
-        //Determine that we have the correct transport available.
-        TransportOutDescription transportOut = faultContext.getTransportOut();
-
-        try {
-            EndpointReference responseEPR = faultContext.getTo();
-            if (faultContext.isServerSide() && responseEPR != null) {
-                if (!responseEPR.hasAnonymousAddress() && !responseEPR.hasNoneAddress())
{
-                    URI uri = new URI(responseEPR.getAddress());
-                    String scheme = uri.getScheme();
-                    if (!transportOut.getName().getLocalPart().equals(scheme)) {
-                        ConfigurationContext configurationContext = faultContext.getConfigurationContext();
-                        transportOut = configurationContext.getAxisConfiguration()
-                                .getTransportOut(new QName(scheme));
-                        if (transportOut == null) {
-                            throw new AxisFault("Can not find the transport sender : " +
scheme);
-                        }
-                        faultContext.setTransportOut(transportOut);
-                    }
-                }
-            }
-        } catch (URISyntaxException urise) {
-            throw new AxisFault(urise);
-        }
-
-        SOAPEnvelope envelope;
-
-        if (processingContext.isSOAP11()) {
-            envelope = OMAbstractFactory.getSOAP11Factory().getDefaultFaultEnvelope();
-        } else {
-
-            // Following will make SOAP 1.2 as the default, too.
-            envelope = OMAbstractFactory.getSOAP12Factory().getDefaultFaultEnvelope();
-        }
-
-        extractFaultInformationFromMessageContext(processingContext, envelope.getBody().getFault(),
-                e);
-        faultContext.setEnvelope(envelope);
-        faultContext.setProperty(MessageContext.TRANSPORT_OUT,
-                processingContext.getProperty(MessageContext.TRANSPORT_OUT));
-        faultContext.setProperty(Constants.OUT_TRANSPORT_INFO,
-                processingContext.getProperty(Constants.OUT_TRANSPORT_INFO));
-
-        return faultContext;
-    }
-
-    /**
-     * Information to create the SOAPFault can be extracted from different places.
-     * 1. Those information may have been put in to the message context by some handler.
When someone
-     * is putting like that, he must make sure the SOAPElements he is putting must be from
the
-     * correct SOAP Version.
-     * 2. SOAPProcessingException is flexible enough to carry information about the fault.
For example
-     * it has an attribute to store the fault code. The fault reason can be extracted from
the
-     * message of the exception. I opted to put the stacktrace under the detail element.
-     * eg : <Detail>
-     * <Exception> stack trace goes here </Exception>
-     * <Detail>
-     * <p/>
-     * If those information can not be extracted from any of the above places, I default
the soap
-     * fault values to following.
-     * <Fault>
-     * <Code>
-     * <Value>env:Receiver</Value>
-     * </Code>
-     * <Reason>
-     * <Text>unknown</Text>
-     * </Reason>
-     * <Role/>
-     * <Node/>
-     * <Detail/>
-     * </Fault>
-     * <p/>
-     * -- EC
-     *
-     * @param context
-     * @param fault
-     * @param e
-     */
-    private void extractFaultInformationFromMessageContext(MessageContext context, SOAPFault
fault,
-                                                           Throwable e) {
-        SOAPProcessingException soapException = null;
-        AxisFault axisFault = null;
-
-        if (e != null) {
-            if (e instanceof AxisFault) {
-                axisFault = (AxisFault) e;
-            } else if (e.getCause() instanceof AxisFault) {
-                axisFault = (AxisFault) e.getCause();
-            }
-        }
-
-        if (e instanceof SOAPProcessingException) {
-            soapException = (SOAPProcessingException) e;
-        } else if (axisFault != null) {
-            if (axisFault.getCause() instanceof SOAPProcessingException) {
-                soapException = (SOAPProcessingException) axisFault.getCause();
-            }
-        } else {
-            // we have recd an instance of just the Exception class
-        }
-
-        // user can set the fault information to the message context or to the AxisFault
itself.
-        // whatever user sets to the message context, supercedes eerything.
-
-        Object faultCode = context.getProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
-        String soapFaultCode = "";
-
-
-        if (faultCode != null) {
-            fault.setCode((SOAPFaultCode) faultCode);
-        } else if (soapException != null) {
-            soapFaultCode = soapException.getFaultCode();
-        } else if (axisFault != null) {
-
-            Map faultElementsMap = axisFault.getFaultElements();
-            if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)
!= null) {
-                fault.setCode((SOAPFaultCode) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME));
-            } else {
-                QName faultCodeQName = axisFault.getFaultCode();
-                if (faultCodeQName != null) {
-                    if (faultCodeQName.getLocalPart().indexOf(":") == -1) {
-                        String prefix = faultCodeQName.getPrefix();
-                        String uri = faultCodeQName.getNamespaceURI();
-                        prefix = prefix == null || "".equals(prefix) ? Constants.AXIS2_NAMESPACE_PREFIX
: prefix;
-                        uri = uri == null || "".equals(uri) ? Constants.AXIS2_NAMESPACE_URI
: uri;
-                        soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
-                        fault.declareNamespace(uri, prefix);
-                    } else {
-                        soapFaultCode = faultCodeQName.getLocalPart();
-                    }
-                }
-            }
-        }
-
-        // defaulting to fault code Sender, if no message is available
-        if (faultCode == null && context.getEnvelope() != null) {
-            soapFaultCode = ("".equals(soapFaultCode) || (soapFaultCode == null))
-                    ? getSenderFaultCode(context.getEnvelope().getNamespace())
-                    : soapFaultCode;
-            fault.getCode().getValue().setText(soapFaultCode);
-        }
-
-        Object faultReason = context.getProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);
-        String message = "";
-
-        if (faultReason != null) {
-            fault.setReason((SOAPFaultReason) faultReason);
-            message = fault.getReason().getFirstSOAPText().getText();
-        } else if (soapException != null) {
-            message = soapException.getMessage();
-        } else if (axisFault != null) {
-            Map faultElementsMap = axisFault.getFaultElements();
-            if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)
!= null) {
-                fault.setReason((SOAPFaultReason) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME));
-            } else {
-                message = axisFault.getReason();
-                if (message == null || "".equals(message)) {
-                    message = getFaultReasonFromException(e, context);
-                }
-//                message = message != null && "".equals(message) ? message : e.getMessage();
-            }
-
-
-        }
-
-        // defaulting to reason, unknown, if no reason is available
-        if (faultReason == null) {
-            message = ("".equals(message) || (message == null))
-                    ? "unknown"
-                    : message;
-            fault.getReason().getFirstSOAPText().setLang("en-US");
-            fault.getReason().getFirstSOAPText().setText(message);
-        }
-
-
-        Object faultRole = context.getProperty(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME);
-        if (faultRole != null) {
-            fault.getRole().setText((String) faultRole);
-        } else if (axisFault != null) {
-            Map faultElementsMap = axisFault.getFaultElements();
-            if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME)
!= null) {
-                fault.setRole((SOAPFaultRole) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME));
-            }
-        }
-
-        Object faultNode = context.getProperty(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME);
-        if (faultNode != null) {
-            fault.getNode().setText((String) faultNode);
-        } else if (axisFault != null) {
-            Map faultElementsMap = axisFault.getFaultElements();
-            if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME)
!= null) {
-                fault.setNode((SOAPFaultNode) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME));
-            }
-        }
-
-        // Allow handlers to override the sendStacktraceDetailsWithFaults setting from the
Configuration to allow
-        // WS-* protocol faults to not include the exception.
-        boolean sendStacktraceDetailsWithFaults;
-        OperationContext oc = context.getOperationContext();
-        Object flagFromContext = null;
-        if (oc != null) {
-            flagFromContext = context.getOperationContext().getProperty(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS);
-        }
-        if (flagFromContext != null) {
-            sendStacktraceDetailsWithFaults = JavaUtils.isTrue(flagFromContext);
-        } else {
-            Parameter param = context.getParameter(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS);
-            sendStacktraceDetailsWithFaults = JavaUtils.isTrue(param.getValue());
-        }
-
-        Object faultDetail = context.getProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME);
-        if (faultDetail != null) {
-            fault.setDetail((SOAPFaultDetail) faultDetail);
-        } else if (axisFault != null) {
-            Map faultElementsMap = axisFault.getFaultElements();
-            if (faultElementsMap != null && faultElementsMap.get(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)
!= null) {
-                fault.setDetail((SOAPFaultDetail) faultElementsMap.get(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
-            } else {
-                OMElement detail = axisFault.getDetail();
-                if (detail != null) {
-                    fault.getDetail().addDetailEntry(detail);
-                } else if (sendStacktraceDetailsWithFaults) {
-                    fault.setException(axisFault);
-                }
-            }
-        } else if (fault.getException() == null && sendStacktraceDetailsWithFaults)
{
-            if (e instanceof Exception) {
-                fault.setException((Exception) e);
-            } else {
-                fault.setException(new Exception(e));
-            }
-        }
-
-
-    }
-
-    /**
-     * By the time the exception comes here it can be wrapped by so many levels. This will
crip down
-     * to the root cause and get the initial error depending on the property
-     *
-     * @param e
-     */
-    private String getFaultReasonFromException(Throwable e, MessageContext context) {
-        Throwable throwable = e;
-        Parameter param = context.getParameter(Constants.Configuration.DRILL_DOWN_TO_ROOT_CAUSE_FOR_FAULT_REASON);
-        boolean drillDownToRootCauseForFaultReason = param != null && ((String) param.getValue()).equalsIgnoreCase("true");
-        if (drillDownToRootCauseForFaultReason) {
-            while (throwable.getCause() != null) {
-                throwable = throwable.getCause();
-            }
-        }
-        return throwable.getMessage();
+        return MessageContextBuilder.createFaultMessageContext(processingContext, e);
     }
 
     /**
@@ -709,14 +374,6 @@
 
             sender.invoke(msgContext);
         }
-    }
-
-    private String getSenderFaultCode(OMNamespace soapNamespace) {
-        return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespace.getNamespaceURI())
-                ? SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":"
-                + SOAP12Constants.FAULT_CODE_SENDER
-                : SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":"
-                + SOAP11Constants.FAULT_CODE_SENDER;
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
Wed Nov 15 13:32:52 2006
@@ -20,6 +20,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,7 +47,7 @@
                 AxisEngine engine =
                         new AxisEngine(messageCtx.getOperationContext().getServiceContext()
                                 .getConfigurationContext());
-                MessageContext faultContext = engine.createFaultMessageContext(messageCtx,
fault);
+                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(messageCtx,
fault);
 
                 engine.sendFault(faultContext);
             }
@@ -54,7 +55,7 @@
         Runnable theadedTask = new Runnable() {
             public void run() {
                 try {
-                    MessageContext newmsgCtx = Utils.createOutMessageContext(messageCtx);
+                    MessageContext newmsgCtx = MessageContextBuilder.createOutMessageContext(messageCtx);
                     newmsgCtx.getOperationContext().addMessageContext(newmsgCtx);
                     ThreadContextDescriptor tc = setThreadContext(messageCtx);
                     try {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
Wed Nov 15 13:32:52 2006
@@ -20,7 +20,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.util.Utils;
+import org.apache.axis2.util.MessageContextBuilder;
 
 /**
  * This is the Absract IN-OUT MEP MessageReceiver. The
@@ -31,7 +31,7 @@
             throws AxisFault;
 
     public final void receive(MessageContext msgContext) throws AxisFault {
-        MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
+        MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(msgContext);
         outMsgContext.getOperationContext().addMessageContext(outMsgContext);
 
         ThreadContextDescriptor tc = setThreadContext(msgContext);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
Wed Nov 15 13:32:52 2006
@@ -36,6 +36,7 @@
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -300,7 +301,7 @@
         msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
 
         AxisEngine engine = new AxisEngine(configContext);
-        MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+        MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
 
         engine.sendFault(faultContext);
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/server/DefaultHttpServiceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/server/DefaultHttpServiceProcessor.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/server/DefaultHttpServiceProcessor.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/server/DefaultHttpServiceProcessor.java
Wed Nov 15 13:32:52 2006
@@ -44,6 +44,7 @@
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -191,7 +192,7 @@
                 msgContext.setProperty(MessageContext.TRANSPORT_OUT, outbuffer.getOutputStream());
                 msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outbuffer);
 
-                MessageContext faultContext = engine.createFaultMessageContext(msgContext,
e);
+                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
                 // If the fault is not going along the back channel we should be 202ing
                 if (AddressingHelper.isFaultRedirected(msgContext)) {
                     response.setStatusLine(new StatusLine(ver, 202, "Accepted"));

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailWorker.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailWorker.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailWorker.java
Wed Nov 15 13:32:52 2006
@@ -21,6 +21,7 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -59,7 +60,7 @@
                 try {
                     if (msgContext != null) {
                         MessageContext faultContext =
-                                engine.createFaultMessageContext(msgContext, e);
+                            MessageContextBuilder.createFaultMessageContext(msgContext, e);
                         engine.sendFault(faultContext);
                     }
                 } catch (Exception e1) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java
Wed Nov 15 13:32:52 2006
@@ -24,6 +24,7 @@
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.transport.mail.Constants;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
@@ -139,7 +140,7 @@
         } catch (Exception e) {
             try {
                 if (msgContext != null) {
-                    MessageContext faultContext = engine.createFaultMessageContext(msgContext,
e);
+                    MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
 
                     engine.sendFault(faultContext);
                 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java
Wed Nov 15 13:32:52 2006
@@ -30,6 +30,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -103,7 +104,7 @@
                 if (msgContext != null) {
                     msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());
 
-                    MessageContext faultContext = engine.createFaultMessageContext(msgContext,
e);
+                    MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext,
e);
 
                     engine.sendFault(faultContext);
                 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
Wed Nov 15 13:32:52 2006
@@ -232,6 +232,8 @@
                         }
                         context.setTransportOut(transportOut);
                     }
+                    context.getOperationContext().setProperty(
+                            Constants.DIFFERENT_EPR, Constants.VALUE_TRUE);
                 }
             }
         } catch (URISyntaxException urise) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java?view=diff&rev=475437&r1=475436&r2=475437
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java Wed Nov
15 13:32:52 2006
@@ -17,14 +17,29 @@
 
 package org.apache.axis2.util;
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.RelatesTo;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.*;
-import org.apache.axis2.description.*;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Flow;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.PhaseRule;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisError;
 import org.apache.axis2.engine.Handler;
@@ -33,13 +48,6 @@
 import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
 
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Iterator;
-
 public class Utils {
     public static void addHandler(Flow flow, Handler handler, String phaseName) {
         HandlerDescription handlerDesc = new HandlerDescription();
@@ -51,95 +59,12 @@
         flow.addHandler(handlerDesc);
     }
 
+    /**
+     * @deprecated (post 1.1 branch)
+     * @see org.apache.axis2.util.MessageContextBuilder.createOutMessageContext()
+     */
     public static MessageContext createOutMessageContext(MessageContext inMessageContext)
throws AxisFault {
-        MessageContext newmsgCtx = new MessageContext();
-
-        newmsgCtx.setConfigurationContext(inMessageContext.getConfigurationContext());
-        newmsgCtx.setSessionContext(inMessageContext.getSessionContext());
-        newmsgCtx.setTransportIn(inMessageContext.getTransportIn());
-        newmsgCtx.setTransportOut(inMessageContext.getTransportOut());
-
-        Options oldOptions =
-                inMessageContext.getOptions();
-
-        newmsgCtx.setMessageID(UUIDGenerator.getUUID());
-        newmsgCtx.setTo(oldOptions.getReplyTo());
-        newmsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
-                inMessageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION));
-        newmsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
-                inMessageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
-
-        // do Target Resolution
-        newmsgCtx.getConfigurationContext().getAxisConfiguration().getTargetResolverChain().resolveTarget(newmsgCtx);
-
-        newmsgCtx.addRelatesTo(new RelatesTo(oldOptions.getMessageId()));
-
-        AxisService axisService = inMessageContext.getAxisService();
-        if (axisService != null && Constants.SCOPE_SOAP_SESSION.equals(axisService.getScope()))
{
-            newmsgCtx.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
-            // add the service group id as a reference parameter
-            String serviceGroupContextId = inMessageContext.getServiceGroupContextId();
-            if (serviceGroupContextId != null && !"".equals(serviceGroupContextId))
{
-                EndpointReference replyToEPR = newmsgCtx.getReplyTo();
-                replyToEPR.addReferenceParameter(new QName(Constants.AXIS2_NAMESPACE_URI,
-                        Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX), serviceGroupContextId);
-            }
-        } else {
-            newmsgCtx.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI));
-        }
-
-        AxisOperation ao = inMessageContext.getAxisOperation();
-        if (ao.getOutputAction() != null) {
-            newmsgCtx.setWSAAction(ao.getOutputAction());
-        } else {
-            newmsgCtx.setWSAAction(oldOptions.getAction());
-        }
-
-        newmsgCtx.setAxisMessage(ao.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
-        newmsgCtx.setOperationContext(inMessageContext.getOperationContext());
-        newmsgCtx.setServiceContext(inMessageContext.getServiceContext());
-        newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,
-                inMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
-        newmsgCtx.setProperty(Constants.OUT_TRANSPORT_INFO,
-                inMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));
-
-        // Setting the charater set encoding
-        newmsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
-                inMessageContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
-        newmsgCtx.setDoingREST(inMessageContext.isDoingREST());
-        newmsgCtx.setDoingMTOM(inMessageContext.isDoingMTOM());
-        newmsgCtx.setServerSide(inMessageContext.isServerSide());
-        newmsgCtx.setServiceGroupContextId(inMessageContext.getServiceGroupContextId());
-
-        // write the Message to the Wire
-        TransportOutDescription transportOut = newmsgCtx.getTransportOut();
-
-        //there may be instance where you want to send the response to replyTo
-        //and this default behaviour should happen if somebody (e.g. a module) has not already
provided
-        //a Sender.
-        try {
-            EndpointReference responseEPR = newmsgCtx.getTo();
-            if (newmsgCtx.isServerSide() && responseEPR != null) {
-                if (!responseEPR.hasAnonymousAddress() && !responseEPR.hasNoneAddress())
{
-                    URI uri = new URI(responseEPR.getAddress());
-                    String scheme = uri.getScheme();
-                    if (!transportOut.getName().getLocalPart().equals(scheme)) {
-                        ConfigurationContext configurationContext = newmsgCtx.getConfigurationContext();
-                        transportOut = configurationContext.getAxisConfiguration()
-                                .getTransportOut(new QName(scheme));
-                        if (transportOut == null) {
-                            throw new AxisFault("Can not find the transport sender : " +
scheme);
-                        }
-                        newmsgCtx.setTransportOut(transportOut);
-                    }
-                    inMessageContext.getOperationContext().setProperty(
-                            Constants.DIFFERENT_EPR, Constants.VALUE_TRUE);
-                }
-            }
-        } catch (URISyntaxException e) {
-            throw new AxisFault(e);
-        }
-        return newmsgCtx;
+        return MessageContextBuilder.createOutMessageContext(inMessageContext);
     }
 
     public static AxisService createSimpleService(QName serviceName, String className, QName
opName)



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message