axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r573047 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: core/controller/AxisInvocationController.java message/Protocol.java
Date Wed, 05 Sep 2007 20:22:01 GMT
Author: scheu
Date: Wed Sep  5 13:21:59 2007
New Revision: 573047

URL: http://svn.apache.org/viewvc?rev=573047&view=rev
Log:
AXIS2-3168
Contributor: Nick Gallardo
Performance fix plus some minor changes to AxisInvocationController.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?rev=573047&r1=573046&r2=573047&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
Wed Sep  5 13:21:59 2007
@@ -81,6 +81,14 @@
     * @see org.apache.axis2.jaxws.core.controller.InvocationController#invoke(org.apache.axis2.jaxws.core.InvocationContext)
     */
     public MessageContext doInvoke(MessageContext request) {
+        
+
+        //Make sure that a non-Async invocation does not have the ASYNC property setting
+        Boolean useAsyncMep = (Boolean) request.getProperties().get(Constants.USE_ASYNC_MEP);
+        if (useAsyncMep != null && useAsyncMep.booleanValue()){
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("invalidMEP"));
+        }
+        
         // We need the qname of the operation being invoked to know which 
         // AxisOperation the OperationClient should be based on.
         // Note that the OperationDesc is only set through use of the Proxy. Dispatch
@@ -109,6 +117,9 @@
         try {
             execute(opClient, true, axisRequestMsgCtx);
         } catch (AxisFault af) {
+            // If an AxisFault was thrown, we need to cleanup the original OperationContext.
+            // Failure to do so results in a memory leak.
+            opClient.getOperationContext().cleanup();
             // save the fault in case it didn't come from the endpoint, and thus
             // there would be no message on the MessageContext
             faultexception = af;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java?rev=573047&r1=573046&r2=573047&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
Wed Sep  5 13:21:59 2007
@@ -24,6 +24,10 @@
 import javax.xml.ws.http.HTTPBinding;
 import javax.xml.ws.soap.SOAPBinding;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  * Protocol Each message has a protocol (soap11, soap12, rest) This enum represents the protocol
  * within the Message sub-component
@@ -33,11 +37,39 @@
 
     private static final Log log = LogFactory.getLog(Protocol.class);
 
+    private static Map<String, Protocol> protocolMappings; 
+    
     // These namespaces are used in the WSDL document to indentify a 
     // SOAP 1.1 vs. a SOAP 1.2 binding
     private static final String SOAP11_WSDL_BINDING = "http://schemas.xmlsoap.org/wsdl/soap";
     private static final String SOAP12_WSDL_BINDING = "http://schemas.xmlsoap.org/wsdl/soap12";
 
+    static {
+        // Normally a static HashMap can cause concurrency issues.
+        // However, if the HashMap is only queried (never modified) then 
+        // access by multiple theads is safe.
+        protocolMappings = new HashMap<String, Protocol>();
+        
+        protocolMappings.put(Protocol.SOAP11_WSDL_BINDING, Protocol.soap11);
+        protocolMappings.put(SOAPBinding.SOAP11HTTP_BINDING, Protocol.soap11);
+        protocolMappings.put(SOAPBinding.SOAP11HTTP_MTOM_BINDING, Protocol.soap11);
+        protocolMappings.put(Protocol.SOAP12_WSDL_BINDING, Protocol.soap12);
+        protocolMappings.put(SOAPBinding.SOAP12HTTP_BINDING, Protocol.soap12);
+        protocolMappings.put(SOAPBinding.SOAP12HTTP_MTOM_BINDING, Protocol.soap12);
+        protocolMappings.put(HTTPBinding.HTTP_BINDING, Protocol.rest);
+        
+        // Add each of the URLs with a "/" at the end for flexibility
+        Map<String, Protocol> updates = new HashMap<String, Protocol>();
+        Iterator<String> keys = protocolMappings.keySet().iterator();
+        while (keys.hasNext()) {
+            String key = keys.next();
+            if (!key.endsWith("/")) {
+                updates.put(key + "/", protocolMappings.get(key));    
+            }
+        }
+        protocolMappings.putAll(updates);
+    }
+    
     /**
      * Return the right value for the Protocol based on the binding URL that was passed in.
      *
@@ -50,44 +82,17 @@
             log.debug("Configuring message protocol for binding [" + url + "]");
         }
 
-        if (namespaceEquals(Protocol.SOAP11_WSDL_BINDING, url) ||
-                namespaceEquals(SOAPBinding.SOAP11HTTP_BINDING, url) ||
-                namespaceEquals(SOAPBinding.SOAP11HTTP_MTOM_BINDING, url)) {
-            if (debug) {
-                log.debug("SOAP 1.1 protocol configured for message");
-            }
-            return Protocol.soap11;
-        } else if (namespaceEquals(Protocol.SOAP12_WSDL_BINDING, url) ||
-                namespaceEquals(SOAPBinding.SOAP12HTTP_BINDING, url) ||
-                namespaceEquals(SOAPBinding.SOAP12HTTP_MTOM_BINDING, url)) {
-            if (debug) {
-                log.debug("SOAP 1.2 protocol configured for message");
+        Protocol proto = protocolMappings.get(url);
+        if (proto != null) {
+            if (log.isDebugEnabled()) {
+                log.debug("Found protocol mapping: " + proto);
             }
-            return Protocol.soap12;
-        } else if (namespaceEquals(HTTPBinding.HTTP_BINDING, url)) {
-            if (debug) {
-                log.debug("XML/HTTP protocol configured for message");
-            }
-            return Protocol.rest;
+            return proto;
         } else {
             if (debug) {
                 log.debug("Protocol was not found for:" + url);
             }
             return null;
         }
-    }
-
-    /*
-    * Check to see if the two strings (namespaces) passed in are the same, but
-    * also accounts for any trailing "/" characters in the string.
-    */
-    private static boolean namespaceEquals(String target, String input) {
-        if (target.equals(input)) {
-            return true;
-        } else if ((target + "/").equals(input)) {
-            return true;
-        }
-
-        return false;
     }
 }



---------------------------------------------------------------------
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