You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/11/25 23:37:52 UTC

svn commit: r349031 - in /webservices/axis2/trunk/java/modules: addressing/test/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/ core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/util/

Author: dims
Date: Fri Nov 25 14:37:44 2005
New Revision: 349031

URL: http://svn.apache.org/viewcvs?rev=349031&view=rev
Log:
Baby Step #1 for cleaning up Stub/Call

- Get rid of the MIH inside MEPClient, this was overriding for example the setWSAAction set in the messagecontext (inside the stub)
- Keep the properties in a HashMap and copy them into MessageContext as soon as it is created.


Modified:
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Call.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOnlyMEPClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MessageSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java Fri Nov 25 14:37:44 2005
@@ -91,7 +91,7 @@
     }
 
     public void testHeaderCreationFromMsgCtxtInformation() throws Exception {
-        MessageInformationHeaders mIHeaders = new MessageInformationHeaders();
+        msgCtxt = new MessageContext(null);
 
         AnyContentType referenceValues = new AnyContentType();
 
@@ -99,7 +99,7 @@
         referenceValues.addReferenceValue(new QName("Reference2"),
                 "Value 200");
         epr.setReferenceParameters(referenceValues);
-        mIHeaders.setFrom(epr);
+        msgCtxt.setFrom(epr);
 
         epr = new EndpointReference("http://www.to.org/service/");
         referenceValues = new AnyContentType();
@@ -122,21 +122,19 @@
                 new QName("http://www.from.org/service/port/",
                         "Port",
                         "portNS"));
-        mIHeaders.setTo(epr);
+        msgCtxt.setTo(epr);
 
         epr =
                 new EndpointReference("http://www.replyTo.org/service/");
-        mIHeaders.setReplyTo(epr);
+        msgCtxt.setReplyTo(epr);
 
-        mIHeaders.setMessageId("123456-7890");
-        mIHeaders.setAction("http://www.actions.org/action");
+        msgCtxt.setMessageID("123456-7890");
+        msgCtxt.setWSAAction("http://www.actions.org/action");
 
         org.apache.axis2.addressing.RelatesTo relatesTo = new org.apache.axis2.addressing.RelatesTo(
                 "http://www.relatesTo.org/service/", "TestRelation");
-        mIHeaders.setRelatesTo(relatesTo);
+        msgCtxt.setRelatesTo(relatesTo);
 
-        msgCtxt = new MessageContext(null);
-        msgCtxt.setMessageInformationHeaders(mIHeaders);
         msgCtxt.setEnvelope(
                 OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
         outHandler.invoke(msgCtxt);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java Fri Nov 25 14:37:44 2005
@@ -181,7 +181,15 @@
 
 
     public static final char SERVICE_NAME_SPLIT_CHAR =':';
-
+    
+    /** Addressing Constants */
+    public static final String ADDRESSING_ACTION = "WS-Addressing:Action";
+    public static final String ADDRESSING_FAULT_TO = "WS-Addressing:FaultTo" ;
+    public static final String ADDRESSING_FROM = "WS-Addressing:From" ;
+    public static final String ADDRESSING_MESSAGE_ID = "WS-Addressing:MessageId";
+    public static final String ADDRESSING_RELATES_TO = "WS-Addressing:RelatesTo" ;
+    public static final String ADDRESSING_REPLY_TO = "WS-Addressing:ReplyTo" ;
+    public static final String ADDRESSING_TO = "WS-Addressing:To" ;
 
     public static interface Configuration {
         public static final String ENABLE_REST = "enableREST";

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Call.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Call.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Call.java Fri Nov 25 14:37:44 2005
@@ -108,7 +108,7 @@
                 serviceContext.getAxisService().getOperation(new QName(axisop));
         opDesc = createOpDescAndFillInFlowInformation(opDesc, axisop, WSDLConstants.MEP_CONSTANT_OUT_IN);
 
-        MessageContext msgctx = new MessageContext(serviceContext.getConfigurationContext());
+        MessageContext msgctx = createMessageContext();
         if (envelope == null || envelope.getBody() == null) {
             throw new AxisFault("SOAP envelope or SOAP Body can not be null");
         }
@@ -158,7 +158,7 @@
                 serviceContext.getAxisService().getOperation(new QName(axisop));
         opDesc = createOpDescAndFillInFlowInformation(opDesc, axisop, WSDLConstants.MEP_CONSTANT_OUT_IN);
 
-        MessageContext msgctx = new MessageContext(serviceContext.getConfigurationContext());
+        MessageContext msgctx = createMessageContext();
         if (envelope == null || envelope.getBody() == null) {
             throw new AxisFault("SOAP envelope or SOAP Body can not be null");
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOnlyMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOnlyMEPClient.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOnlyMEPClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOnlyMEPClient.java Fri Nov 25 14:37:44 2005
@@ -40,7 +40,6 @@
 
     public InOnlyMEPClient(ServiceContext service) {
         super(service, WSDLConstants.MEP_URI_IN_ONLY);
-        messageInformationHeaders = new MessageInformationHeaders();
     }
 
     /**
@@ -59,7 +58,7 @@
         //if the transport to use for sending is not specified, try to find it from the URL
         if (senderTransport == null) {
             senderTransport =
-                    inferTransport(messageInformationHeaders.getTo());
+                    inferTransport(msgctx.getTo());
         }
         msgctx.setTransportOut(senderTransport);
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java Fri Nov 25 14:37:44 2005
@@ -17,8 +17,8 @@
 package org.apache.axis2.client;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.MessageInformationHeaders;
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
@@ -40,6 +40,7 @@
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.HashMap;
 
 /**
  * This is the super class for all the MEPClients.
@@ -50,9 +51,8 @@
     protected String soapVersionURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
     protected String soapAction = "";
 
-    protected MessageInformationHeaders messageInformationHeaders = new MessageInformationHeaders();
-
     protected List soapHeaderList;
+    protected HashMap contextProperties = new HashMap();
 
     /*
       If there is a SOAP Fault in the body of the incoming SOAP Message, system can be configured to
@@ -88,13 +88,10 @@
         if (serviceContext.getAxisService().getOperation(axisop.getName()) == null) {
             serviceContext.getAxisService().addOperation(axisop);
         }
-        if (msgCtx.getMessageInformationHeaders() != null && msgCtx.getMessageInformationHeaders().getAction() != null) {
-            messageInformationHeaders.setAction(msgCtx.getMessageInformationHeaders().getAction());
-        }
-
-        msgCtx.setMessageInformationHeaders(cloneMIHeaders());
 
-        //msgCtx.setMessageInformationHeaders(messageInformationHeaders);
+        if(!contextProperties.isEmpty()) {
+            msgCtx.setContextProperties(contextProperties);
+        }
         msgCtx.setSoapAction(soapAction + "");
 
         // check user has put any SOAPHeader using the call MEPClient methods and add them, if any, to the
@@ -130,7 +127,7 @@
      * @throws AxisFault
      */
     protected MessageContext prepareTheSOAPEnvelope(OMElement toSend) throws AxisFault {
-        MessageContext msgctx = new MessageContext(serviceContext.getConfigurationContext());
+        MessageContext msgctx = createMessageContext();
 
         SOAPEnvelope envelope = createDefaultSOAPEnvelope();
         if (toSend != null) {
@@ -200,18 +197,6 @@
         }
     }
 
-    public MessageInformationHeaders cloneMIHeaders() {
-        MessageInformationHeaders messageInformationHeaders = new MessageInformationHeaders();
-        messageInformationHeaders.setAction(this.messageInformationHeaders.getAction());
-        messageInformationHeaders.setFaultTo(this.messageInformationHeaders.getFaultTo());
-        messageInformationHeaders.setFrom(this.messageInformationHeaders.getFrom());
-        messageInformationHeaders.setMessageId(this.messageInformationHeaders.getMessageId());
-        messageInformationHeaders.setRelatesTo(this.messageInformationHeaders.getRelatesTo());
-        messageInformationHeaders.setReplyTo(this.messageInformationHeaders.getReplyTo());
-        messageInformationHeaders.setTo(this.messageInformationHeaders.getTo());
-        return messageInformationHeaders;
-    }
-
     /**
      * @param string
      */
@@ -279,49 +264,49 @@
      * @param action
      */
     public void setWsaAction(String action) {
-        messageInformationHeaders.setAction(action);
+        contextProperties.put(Constants.ADDRESSING_ACTION, action);
     }
 
     /**
      * @param faultTo
      */
     public void setFaultTo(EndpointReference faultTo) {
-        messageInformationHeaders.setFaultTo(faultTo);
+        contextProperties.put(Constants.ADDRESSING_FAULT_TO, faultTo);
     }
 
     /**
      * @param from
      */
     public void setFrom(EndpointReference from) {
-        messageInformationHeaders.setFrom(from);
+        contextProperties.put(Constants.ADDRESSING_FROM, from);
     }
 
     /**
      * @param messageId
      */
     public void setMessageId(String messageId) {
-        messageInformationHeaders.setMessageId(messageId);
+        contextProperties.put(Constants.ADDRESSING_MESSAGE_ID, messageId);
     }
 
     /**
      * @param relatesTo
      */
     public void setRelatesTo(RelatesTo relatesTo) {
-        messageInformationHeaders.setRelatesTo(relatesTo);
+        contextProperties.put(Constants.ADDRESSING_RELATES_TO, relatesTo);
     }
 
     /**
      * @param replyTo
      */
     public void setReplyTo(EndpointReference replyTo) {
-        messageInformationHeaders.setReplyTo(replyTo);
+        contextProperties.put(Constants.ADDRESSING_REPLY_TO, replyTo);
     }
 
     /**
      * @param to
      */
     public void setTo(EndpointReference to) {
-        messageInformationHeaders.setTo(to);
+        contextProperties.put(Constants.ADDRESSING_TO, to);
     }
 
     // ==============================================================================
@@ -349,6 +334,20 @@
         return serviceContext;
     }
 
+    /**
+     * Creates a message context and sets the contextProperties
+     * 
+     * @return
+     * @throws AxisFault
+     */
+    protected MessageContext createMessageContext() throws AxisFault {
+        MessageContext newMsgCtx = new MessageContext(serviceContext.getConfigurationContext());
+        if(!contextProperties.isEmpty()) {
+            newMsgCtx.setContextProperties(contextProperties);
+        }
+        return newMsgCtx;
+    }
+    
     /**
      * Assumes the values for the ConfigurationContext and ServiceContext to make the NON WSDL cases simple.
      *

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MessageSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MessageSender.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MessageSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MessageSender.java Fri Nov 25 14:37:44 2005
@@ -104,7 +104,7 @@
             serviceContext.getAxisService().addOperation(axisOp);
         }
 
-        MessageContext msgctx = new MessageContext(serviceContext.getConfigurationContext());
+        MessageContext msgctx = createMessageContext();
 
         msgctx.setEnvelope(soapEnvelope);
         super.send(axisOp, msgctx);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java Fri Nov 25 14:37:44 2005
@@ -17,6 +17,7 @@
 package org.apache.axis2.context;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.MessageInformationHeaders;
 import org.apache.axis2.addressing.RelatesTo;
@@ -39,6 +40,9 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 /**
  * MessageContext holds service specific state information.
@@ -97,7 +101,7 @@
      * information is present in the SOAP header.
      */
 
-    private MessageInformationHeaders messageInformationHeaders;
+    private MessageInformationHeaders messageInformationHeaders = new MessageInformationHeaders();
 
     private OperationContext operationContext;
     private ServiceContext serviceContext;
@@ -247,7 +251,6 @@
         } else {
             this.sessionContext = sessionContext;
         }
-        messageInformationHeaders = new MessageInformationHeaders();
         this.transportIn = transportIn;
         this.transportOut = transportOut;
         this.configurationContext = engineContext;
@@ -598,12 +601,36 @@
     }
 
     /**
+     * Copy the values into the respective fields.
+     * 
      * @param collection
      */
-    public void setMessageInformationHeaders(MessageInformationHeaders collection) {
-        messageInformationHeaders = collection;
+    public void setContextProperties(HashMap collection) {
+        Iterator iterator = collection.entrySet().iterator();
+        while(iterator.hasNext()){
+            Map.Entry entry = (Map.Entry) iterator.next();
+            String key = (String)entry.getKey();
+            Object value = entry.getValue();
+            if(value!= null){
+                if(Constants.ADDRESSING_ACTION.equals(key)){
+                    messageInformationHeaders.setAction((String) value);                        
+                } else if (Constants.ADDRESSING_FAULT_TO.equals(key)){
+                    messageInformationHeaders.setFaultTo((EndpointReference) value);                        
+                } else if (Constants.ADDRESSING_FROM.equals(key)){
+                    messageInformationHeaders.setFrom((EndpointReference) value);                        
+                } else if (Constants.ADDRESSING_MESSAGE_ID.equals(key)){
+                    messageInformationHeaders.setMessageId((String) value);                        
+                } else if (Constants.ADDRESSING_RELATES_TO.equals(key)){
+                    messageInformationHeaders.setRelatesTo((RelatesTo) value);                        
+                } else if (Constants.ADDRESSING_REPLY_TO.equals(key)){
+                    messageInformationHeaders.setReplyTo((EndpointReference) value);                        
+                } else if (Constants.ADDRESSING_TO.equals(key)){
+                    System.out.println("TO" + value);
+                    messageInformationHeaders.setTo((EndpointReference) value);                        
+                }
+            }
+        }
     }
-
 
     /**
      * Retrieves configuration descriptor parameters at any level. The order of search is

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=349031&r1=349030&r2=349031&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Fri Nov 25 14:37:44 2005
@@ -68,18 +68,15 @@
                         inMessageContext.getTransportOut());
         MessageInformationHeaders oldMessageInfoHeaders =
                 inMessageContext.getMessageInformationHeaders();
-        MessageInformationHeaders messageInformationHeaders =
-                new MessageInformationHeaders();
-        messageInformationHeaders.setMessageId(UUIDGenerator.getUUID());
-        messageInformationHeaders.setTo(oldMessageInfoHeaders.getReplyTo());
-        messageInformationHeaders.setFaultTo(
+        newmsgCtx.setMessageID(UUIDGenerator.getUUID());
+        newmsgCtx.setTo(oldMessageInfoHeaders.getReplyTo());
+        newmsgCtx.setFaultTo(
                 oldMessageInfoHeaders.getFaultTo());
-        messageInformationHeaders.setFrom(oldMessageInfoHeaders.getTo());
-        messageInformationHeaders.setRelatesTo(
+        newmsgCtx.setFrom(oldMessageInfoHeaders.getTo());
+        newmsgCtx.setRelatesTo(
                 new org.apache.axis2.addressing.RelatesTo(oldMessageInfoHeaders.getMessageId(),
                         AddressingConstants.Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
-        messageInformationHeaders.setAction(oldMessageInfoHeaders.getAction());
-        newmsgCtx.setMessageInformationHeaders(messageInformationHeaders);
+        newmsgCtx.setWSAAction(oldMessageInfoHeaders.getAction());
         newmsgCtx.setOperationContext(inMessageContext.getOperationContext());
         newmsgCtx.setServiceContext(inMessageContext.getServiceContext());
         newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,



Re: svn commit: r349031 - in /webservices/axis2/trunk/java/modules: addressing/test/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/ core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/util/

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Fri, 2005-11-25 at 22:37 +0000, dims@apache.org wrote:
> Author: dims
> Date: Fri Nov 25 14:37:44 2005
> New Revision: 349031
> 
> URL: http://svn.apache.org/viewcvs?rev=349031&view=rev
> Log:
> Baby Step #1 for cleaning up Stub/Call
> 
> - Get rid of the MIH inside MEPClient, this was overriding for example the setWSAAction set in the messagecontext (inside the stub)
> - Keep the properties in a HashMap and copy them into MessageContext as soon as it is created.

FYI Eran and I are doing a careful review of the client side and expect
to propose a significant refactoring. We've found lots of places to
improve. It may take a couple of days (depending on how much we get done
over the weekend) but it'll be worth it. Along with refactoring
MEPClient downwards we also are looking at the Stub class.

>      /**
> +     * Copy the values into the respective fields.
> +     * 
>       * @param collection
>       */
> -    public void setMessageInformationHeaders(MessageInformationHeaders collection) {
> -        messageInformationHeaders = collection;
> +    public void setContextProperties(HashMap collection) {
> +        Iterator iterator = collection.entrySet().iterator();
> +        while(iterator.hasNext()){
> +            Map.Entry entry = (Map.Entry) iterator.next();
> +            String key = (String)entry.getKey();
> +            Object value = entry.getValue();
> +            if(value!= null){
> +                if(Constants.ADDRESSING_ACTION.equals(key)){
> +                    messageInformationHeaders.setAction((String) value);                        
> +                } else if (Constants.ADDRESSING_FAULT_TO.equals(key)){
> +                    messageInformationHeaders.setFaultTo((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_FROM.equals(key)){
> +                    messageInformationHeaders.setFrom((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_MESSAGE_ID.equals(key)){
> +                    messageInformationHeaders.setMessageId((String) value);                        
> +                } else if (Constants.ADDRESSING_RELATES_TO.equals(key)){
> +                    messageInformationHeaders.setRelatesTo((RelatesTo) value);                        
> +                } else if (Constants.ADDRESSING_REPLY_TO.equals(key)){
> +                    messageInformationHeaders.setReplyTo((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_TO.equals(key)){
> +                    System.out.println("TO" + value);
> +                    messageInformationHeaders.setTo((EndpointReference) value);                        
> +                }
> +            }
> +        }
>      }

I hate this kind of code - the addressing properties are fundamental
concepts of a message and hence they should be stored directly IMO. Also
this is relatively inefficient for something that happens thru every
call.invoke*.

The problem (that the MIH was replacing stuff) can be dealt with in
another way too. Anyway, need a bit more time to sort this through.

Sanjiva.


Re: svn commit: r349031 - in /webservices/axis2/trunk/java/modules: addressing/test/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/ core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/util/

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Fri, 2005-11-25 at 22:37 +0000, dims@apache.org wrote:
> Author: dims
> Date: Fri Nov 25 14:37:44 2005
> New Revision: 349031
> 
> URL: http://svn.apache.org/viewcvs?rev=349031&view=rev
> Log:
> Baby Step #1 for cleaning up Stub/Call
> 
> - Get rid of the MIH inside MEPClient, this was overriding for example the setWSAAction set in the messagecontext (inside the stub)
> - Keep the properties in a HashMap and copy them into MessageContext as soon as it is created.

FYI Eran and I are doing a careful review of the client side and expect
to propose a significant refactoring. We've found lots of places to
improve. It may take a couple of days (depending on how much we get done
over the weekend) but it'll be worth it. Along with refactoring
MEPClient downwards we also are looking at the Stub class.

>      /**
> +     * Copy the values into the respective fields.
> +     * 
>       * @param collection
>       */
> -    public void setMessageInformationHeaders(MessageInformationHeaders collection) {
> -        messageInformationHeaders = collection;
> +    public void setContextProperties(HashMap collection) {
> +        Iterator iterator = collection.entrySet().iterator();
> +        while(iterator.hasNext()){
> +            Map.Entry entry = (Map.Entry) iterator.next();
> +            String key = (String)entry.getKey();
> +            Object value = entry.getValue();
> +            if(value!= null){
> +                if(Constants.ADDRESSING_ACTION.equals(key)){
> +                    messageInformationHeaders.setAction((String) value);                        
> +                } else if (Constants.ADDRESSING_FAULT_TO.equals(key)){
> +                    messageInformationHeaders.setFaultTo((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_FROM.equals(key)){
> +                    messageInformationHeaders.setFrom((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_MESSAGE_ID.equals(key)){
> +                    messageInformationHeaders.setMessageId((String) value);                        
> +                } else if (Constants.ADDRESSING_RELATES_TO.equals(key)){
> +                    messageInformationHeaders.setRelatesTo((RelatesTo) value);                        
> +                } else if (Constants.ADDRESSING_REPLY_TO.equals(key)){
> +                    messageInformationHeaders.setReplyTo((EndpointReference) value);                        
> +                } else if (Constants.ADDRESSING_TO.equals(key)){
> +                    System.out.println("TO" + value);
> +                    messageInformationHeaders.setTo((EndpointReference) value);                        
> +                }
> +            }
> +        }
>      }

I hate this kind of code - the addressing properties are fundamental
concepts of a message and hence they should be stored directly IMO. Also
this is relatively inefficient for something that happens thru every
call.invoke*.

The problem (that the MIH was replacing stuff) can be dealt with in
another way too. Anyway, need a bit more time to sort this through.

Sanjiva.