Author: nagy
Date: Tue Jul 11 11:02:49 2006
New Revision: 420940

URL: http://svn.apache.org/viewvc?rev=420940&view=rev
Log:
Fixed a problem with the RequestURIBasedDispatcher not being thread safe, as it 
relied upon non-synchronized instance variables even though the object is a 
singleton within the scope of an AxisConfiguration.  Since multiple threads may 
access the object at the same time, there was the potential for a message to be 
dispatched to the wrong service/operation.

Modified:
    
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java

Modified: 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java?rev=420940&r1=420939&r2=420940&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java
 Tue Jul 11 11:02:49 2006
@@ -36,36 +36,39 @@
 
        private static final long serialVersionUID = 6212111158265910316L;
        
-       /**
-     * Field NAME
-     */
     public static final QName NAME = new QName("http://ws.apache.org/axis2/";,
             "RequestURIBasedDispatcher");
        private static final Log log = 
LogFactory.getLog(RequestURIBasedDispatcher.class);
-    String serviceName = null;
-    QName operationName = null;
 
+    /*
+     *  (non-Javadoc)
+     * @see 
org.apache.axis2.engine.AbstractDispatcher#findOperation(org.apache.axis2.description.AxisService,
 org.apache.axis2.context.MessageContext)
+     */
     public AxisOperation findOperation(AxisService service, MessageContext 
messageContext)
             throws AxisFault {
-        log.debug("Checking for Operation using target endpoint uri fragment : 
" + operationName);
+
         EndpointReference toEPR = messageContext.getTo();
-        if ((toEPR != null) && (operationName == null)) {
+        if (toEPR != null) {
             String filePart = toEPR.getAddress();
             String[] values = 
Utils.parseRequestURLForServiceAndOperation(filePart ,
                     messageContext.getConfigurationContext().getServicePath());
 
             if ((values.length >= 2) && (values[1] != null)) {
-                operationName = new QName(values[1]);
+                QName operationName = new QName(values[1]);
+                log.debug("Checking for Operation using QName(target endpoint 
URI fragment) : " + operationName);
+                return service.getOperation(operationName);
+            }
+            else
+            {
+              log.debug("Attempted to check for Operation using target 
endpoint URI, but the operation fragment was missing");
+              return null;
             }
         }
-
-        if (operationName != null) {
-            AxisOperation axisOperation = service.getOperation(operationName);
-            operationName = null;
-            return axisOperation;
+        else
+        {
+          log.debug("Attempted to check for Operation using null target 
endpoint URI");
+          return null;
         }
-
-        return null;
     }
 
     /*
@@ -79,24 +82,27 @@
             log.debug("Checking for Service using target endpoint address : " 
+ toEPR.getAddress());
 
             String filePart = toEPR.getAddress();
+            //REVIEW: (nagy) Parsing the RequestURI will also give us the 
operationName if present, so we could conceivably store it in the 
MessageContext, but doing so and retrieving it is probably no faster than 
simply reparsing the URI
             String[] values = 
Utils.parseRequestURLForServiceAndOperation(filePart ,
                     messageContext.getConfigurationContext().getServicePath());
 
-            if (values[1] != null) {
-                operationName = new QName(values[1]);
-            }
-
-            if (values[0] != null) {
-                serviceName = values[0];
-
+            if ((values.length >= 1) && (values[0] != null)) {
                 AxisConfiguration registry =
                         
messageContext.getConfigurationContext().getAxisConfiguration();
 
-                return registry.getService(serviceName);
+                return registry.getService(values[0]);
+            }
+            else
+            {
+              log.debug("Attempted to check for Service using target endpoint 
URI, but the service fragment was missing");
+              return null;
             }
         }
-
-        return null;
+        else
+        {
+          log.debug("Attempted to check for Service using null target endpoint 
URI");
+          return null;
+        }
     }
 
     public void initDispatcher() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to