You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/12/03 01:06:51 UTC

svn commit: r351855 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl core/src/org/apache/axis2/client/MEPClient.java core/src/org/apache/axis2/client/Options.java

Author: dims
Date: Fri Dec  2 16:06:46 2005
New Revision: 351855

URL: http://svn.apache.org/viewcvs?rev=351855&view=rev
Log:
- Fixes 2 problems reported here:
  http://marc.theaimsgroup.com/?l=axis-dev&m=113352222715714&w=2
  http://marc.theaimsgroup.com/?l=axis-dev&m=113353014009451&w=2
- Added a delegation mechanism for Options to make sure user set properties are honored correctly
- Do not make copies of properties unless absolutely needed 
- Default behavior desired by Eran (http://marc.theaimsgroup.com/?l=axis-dev&m=113352364913770&w=2) remains the same (and there is no copying at all)


Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=351855&r1=351854&r2=351855&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Fri Dec  2 16:06:46 2005
@@ -112,16 +112,14 @@
          </xsl:for-each>) throws java.rmi.RemoteException{
 
 		     org.apache.axis2.client.Call _call = new org.apache.axis2.client.Call(_serviceContext);
-             _call.setClientOptions(_clientOptions);
+             org.apache.axis2.client.Options _options = new org.apache.axis2.client.Options(_clientOptions);
+             _call.setClientOptions(_options);
 
  		     org.apache.axis2.context.MessageContext _messageContext = getMessageContext();
-             if(_clientOptions.getSoapAction() == null) {
-               <xsl:for-each select="input/param[@Action!='']">_clientOptions.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
-			 }
-
-             if(_clientOptions.getAction() == null) {
-               <xsl:for-each select="input/param[@Action!='']">_clientOptions.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
-			 }
+             <xsl:for-each select="input/param[@Action!='']">_options.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
+
+             <xsl:for-each select="input/param[@Action!='']">_options.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
+
              //set the properties
             populateModules(_call);
 
@@ -135,7 +133,7 @@
                   <xsl:choose>
                       <xsl:when test="$style='rpc'">
                // Style is RPC
-              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI(), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
+              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI(), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
               new String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
               new Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
                       </xsl:when>
@@ -160,7 +158,7 @@
                    <xsl:choose>
                    <xsl:when test="$style='rpc'">
                //Style is RPC. No input parameters
-               org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
+               org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
                       </xsl:when>
                      <xsl:when test="$style='doc'">
                //Style is Doc. No input parameters
@@ -208,15 +206,13 @@
             <xsl:if test="$paramCount>0">,</xsl:if>final <xsl:value-of select="$package"/>.<xsl:value-of select="$callbackname"/> callback) throws java.rmi.RemoteException{
 
              org.apache.axis2.client.Call _call = new org.apache.axis2.client.Call(_serviceContext);
-             _call.setClientOptions(_clientOptions);
+            org.apache.axis2.client.Options _options = new org.apache.axis2.client.Options(_clientOptions);
+             _call.setClientOptions(_options);
  		     org.apache.axis2.context.MessageContext _messageContext = getMessageContext();
-            if(_clientOptions.getSoapAction() == null) {
-             _clientOptions.setSoapAction("<xsl:value-of select="$soapAction"/>");
-            }
+             _options.setSoapAction("<xsl:value-of select="$soapAction"/>");
             
-           if(_clientOptions.getAction() == null) {
-            <xsl:for-each select="input/param[@Action!='']">_lientOptions.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
-			}
+            <xsl:for-each select="input/param[@Action!='']">_options.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
+
              org.apache.axis2.soap.SOAPEnvelope env = createEnvelope();
              <xsl:choose>
              <!-- There are more than 1 parameter in the input-->
@@ -224,7 +220,7 @@
               <xsl:choose>
                <xsl:when test="$style='rpc'">
            // Style is RPC
-           org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI()), env,
+           org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI()), env,
             "<xsl:value-of select="@namespace"/>",
             "<xsl:value-of select="@name"/>",
              new String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
@@ -245,7 +241,7 @@
                    <xsl:choose>
                    <xsl:when test="$style='rpc'">
            //Style is RPC. No input parameters
-              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI()), env,
+              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI()), env,
                 "<xsl:value-of select="@namespace"/>",
                 "<xsl:value-of select="@name"/>",
                 null,
@@ -297,15 +293,12 @@
          org.apache.axis2.client.MessageSender _msgSender = new org.apache.axis2.client.MessageSender(_serviceContext);
             
  		    org.apache.axis2.context.MessageContext _messageContext = getMessageContext();
-          _msgSender.setClientOptions(_clientOptions);
+          org.apache.axis2.client.Options _options = new org.apache.axis2.client.Options(_clientOptions);
+          _msgSender.setClientOptions(_options);
+
+          _options.setSoapAction("<xsl:value-of select="$soapAction"/>");
 
-          if(_clientOptions.getSoapAction() == null) {
-            _clientOptions.setSoapAction("<xsl:value-of select="$soapAction"/>");
-          }
-
-            if(_clientOptions.getAction() == null) {
-            <xsl:for-each select="input/param[@Action!='']">_clientOptions.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
-			}
+          <xsl:for-each select="input/param[@Action!='']">_options.setAction("<xsl:value-of select="@Action"/>");</xsl:for-each>
           org.apache.axis2.soap.SOAPEnvelope env = null;
             env = createEnvelope();
             <xsl:choose>
@@ -315,7 +308,7 @@
                   <xsl:choose>
                       <xsl:when test="$style='rpc'">
                // Style is RPC
-              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
+              org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
               new String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
               new Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
                       </xsl:when>
@@ -335,7 +328,7 @@
                    <xsl:choose>
                    <xsl:when test="$style='rpc'">
                //Style is RPC. No input parameters
-               org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_clientOptions.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
+               org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_options.getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
                       </xsl:when>
                      <xsl:when test="$style='doc'">
                //Style is Doc. No input parameters

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=351855&r1=351854&r2=351855&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 Dec  2 16:06:46 2005
@@ -336,7 +336,7 @@
             AxisConfiguration axisConfig = this.serviceContext.getConfigurationContext().getAxisConfiguration();
 
             // we have a deprecated method for user to set the transport protocol directly. Lets support that also
-            String senderTrasportProtocol = clientOptions.getSenderTrasportProtocol();
+            String senderTrasportProtocol = clientOptions.getSenderTransportProtocol();
             if (axisConfig != null) {
                 if (senderTrasportProtocol == null || "".equals(senderTrasportProtocol)) {
                     // by this time we have passed all the information we collected via Options to the

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java?rev=351855&r1=351854&r2=351855&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java Fri Dec  2 16:06:46 2005
@@ -39,8 +39,9 @@
  * will be getting parameters using this.
  */
 public class Options {
-
-
+    
+    private Options delegate = null;
+    
     private Map properties = new HashMap();
 
     // ==========================================================================
@@ -61,7 +62,7 @@
     private TransportInDescription listenerTransport;
     private boolean useSeparateListener = false;
     private String listenerTransportProtocol;
-    private String senderTrasportProtocol;
+    private String senderTransportProtocol;
 
     // Addressing specific properties
     private String action;
@@ -83,6 +84,20 @@
     // ==========================================================================
 
     /**
+     * Default constructor
+     */
+    public Options() {
+    }
+
+    /**
+     * Any setting in the delegate always wins. 
+     * @param delegate
+     */
+    public Options(Options delegate) {
+        this.delegate = delegate;
+    }
+
+    /**
      * Properties you need to pass in to the message context must be set via this.
      * If there is a method to the set this property, within this class, its encouraged to use that method,
      * without duplicating stuff or making room for bugs.
@@ -99,10 +114,24 @@
      * @return the value realeted to this key. Null, if not found.
      */
     public Object getProperty(String key) {
+        if (delegate != null) {
+            Object ret = delegate.getProperty(key);
+            if (ret != null) {
+                return ret;
+            }
+        }
         return properties.get(key);
     }
 
     public Map getProperties() {
+        if (delegate != null) {
+            Map properties = delegate.getProperties();
+            if (properties.size() > 0) {
+                HashMap ret = new HashMap(properties);
+                ret.putAll(properties);
+                return ret;
+            }
+        }
         return properties;
     }
 
@@ -119,6 +148,12 @@
     }
 
     public String getSoapVersionURI() {
+        if (delegate != null) {
+            String ret = delegate.getSoapVersionURI();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return soapVersionURI;
     }
 
@@ -127,6 +162,12 @@
     }
 
     public String getSoapAction() {
+        if (delegate != null) {
+            String ret = delegate.getSoapAction();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return soapAction;
     }
 
@@ -141,6 +182,9 @@
      * be returned to the application, irrespective of whether it has a Fault or not.
      */
     public boolean isExceptionToBeThrownOnSOAPFault() {
+        if (delegate != null) {
+            return delegate.isExceptionToBeThrownOnSOAPFault();
+        }
         return isExceptionToBeThrownOnSOAPFault;
     }
 
@@ -164,6 +208,9 @@
      * @return timeOutInMilliSeconds
      */
     public long getTimeOutInMilliSeconds() {
+        if (delegate != null) {
+            return delegate.getTimeOutInMilliSeconds();
+        }
         return timeOutInMilliSeconds;
     }
 
@@ -178,6 +225,12 @@
     }
 
     public TransportListener getListener() {
+        if (delegate != null) {
+            TransportListener ret = delegate.getListener();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return listener;
     }
 
@@ -186,6 +239,12 @@
     }
 
     public TransportOutDescription getSenderTransport() {
+        if (delegate != null) {
+            TransportOutDescription ret = delegate.getSenderTransport();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return senderTransport;
     }
 
@@ -208,6 +267,12 @@
     }
 
     public TransportInDescription getListenerTransport() {
+        if (delegate != null) {
+            TransportInDescription ret = delegate.getListenerTransport();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return listenerTransport;
     }
 
@@ -216,6 +281,9 @@
     }
 
     public boolean isUseSeparateListener() {
+        if (delegate != null) {
+            return delegate.isUseSeparateListener();
+        }
         return useSeparateListener;
     }
 
@@ -232,6 +300,12 @@
     }
 
     public String getAction() {
+        if (delegate != null) {
+            String ret = delegate.getAction();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return action;
     }
 
@@ -240,6 +314,12 @@
     }
 
     public String getMessageId() {
+        if (delegate != null) {
+            String ret = delegate.getMessageId();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return messageId;
     }
 
@@ -248,6 +328,12 @@
     }
 
     public EndpointReference getTo() {
+        if (delegate != null) {
+            EndpointReference ret = delegate.getTo();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return to;
     }
 
@@ -256,6 +342,12 @@
     }
 
     public EndpointReference getFrom() {
+        if (delegate != null) {
+            EndpointReference ret = delegate.getFrom();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return from;
     }
 
@@ -264,6 +356,12 @@
     }
 
     public EndpointReference getReplyTo() {
+        if (delegate != null) {
+            EndpointReference ret = delegate.getReplyTo();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return replyTo;
     }
 
@@ -272,6 +370,12 @@
     }
 
     public EndpointReference getFaultTo() {
+        if (delegate != null) {
+            EndpointReference ret = delegate.getFaultTo();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return faultTo;
     }
 
@@ -280,6 +384,12 @@
     }
 
     public RelatesTo getRelatesTo() {
+        if (delegate != null) {
+            RelatesTo ret = delegate.getRelatesTo();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return relatesTo;
     }
 
@@ -288,6 +398,12 @@
     }
 
     public String getListenerTransportProtocol() {
+        if (delegate != null) {
+            String ret = delegate.getListenerTransportProtocol();
+            if (ret != null) {
+                return ret;
+            }
+        }
         return listenerTransportProtocol;
     }
 
@@ -295,8 +411,14 @@
         this.listenerTransportProtocol = listenerTransportProtocol;
     }
 
-    public String getSenderTrasportProtocol() {
-        return senderTrasportProtocol;
+    public String getSenderTransportProtocol() {
+        if (delegate != null) {
+            String ret = delegate.getSenderTransportProtocol();
+            if (ret != null) {
+                return ret;
+            }
+        }
+        return senderTransportProtocol;
     }
 
 
@@ -339,6 +461,6 @@
         }
 
         setListenerTransportProtocol(listenerTransport);
-        this.senderTrasportProtocol = senderTransport;
+        this.senderTransportProtocol = senderTransport;
     }
 }