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 da...@apache.org on 2007/05/25 19:48:54 UTC

svn commit: r541738 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: dispatchers/RequestURIBasedServiceDispatcher.java engine/RequestURIBasedDispatcher.java

Author: davidillsley
Date: Fri May 25 10:48:53 2007
New Revision: 541738

URL: http://svn.apache.org/viewvc?view=rev&rev=541738
Log:
Refactor to contain the dispatch logic in single class.
More of this to come.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/RequestURIBasedServiceDispatcher.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/RequestURIBasedServiceDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/RequestURIBasedServiceDispatcher.java?view=diff&rev=541738&r1=541737&r2=541738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/RequestURIBasedServiceDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/RequestURIBasedServiceDispatcher.java Fri May 25 10:48:53 2007
@@ -14,11 +14,15 @@
 
 package org.apache.axis2.dispatchers;
 
+import java.util.Map;
+
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.util.LoggingControl;
 import org.apache.axis2.util.Utils;
@@ -44,15 +48,36 @@
             }
             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
+            ConfigurationContext configurationContext = messageContext.getConfigurationContext();
             String[] values = Utils.parseRequestURLForServiceAndOperation(filePart,
                                                                           messageContext
                                                                                   .getConfigurationContext().getServiceContextPath());
 
             if ((values.length >= 1) && (values[0] != null)) {
-                AxisConfiguration registry =
-                        messageContext.getConfigurationContext().getAxisConfiguration();
+            	
+            	AxisConfiguration registry =
+            		configurationContext.getAxisConfiguration();
+
+            	AxisService axisService = registry.getService(values[0]);
+
+            	// If the axisService is not null we get the binding that the request came to add
+            	// add it as a property to the messageContext
+            	if (axisService != null) {
+            		Map endpoints = axisService.getEndpoints();
+            		if (endpoints != null) {
+            			if (endpoints.size() == 1) {
+            				messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+            						endpoints.get(
+            								axisService.getEndpointName()));
+            			} else {
+            				String endpointName = values[0].substring(values[0].indexOf(".") + 1);
+            				messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+            						endpoints.get(endpointName));
+            			}
+            		}
+            	}
 
-                return registry.getService(values[0]);
+            	return axisService;
             } else {
                 if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                     log.debug(messageContext.getLogIDString() +

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java?view=diff&rev=541738&r1=541737&r2=541738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java Fri May 25 10:48:53 2007
@@ -1,6 +1,4 @@
 /*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -13,24 +11,14 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-
-
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.util.LoggingControl;
-import org.apache.axis2.util.Utils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Map;
+import org.apache.axis2.dispatchers.RequestURIBasedServiceDispatcher;
 
 /**
  * Dispatches the service based on the information from the target endpoint URL.
@@ -38,8 +26,8 @@
 public class RequestURIBasedDispatcher extends AbstractDispatcher {
 
     public static final String NAME = "RequestURIBasedDispatcher";
-    private static final Log log = LogFactory.getLog(RequestURIBasedDispatcher.class);
-
+    private RequestURIBasedServiceDispatcher rubsd = new RequestURIBasedServiceDispatcher();
+    
     /*
      *  (non-Javadoc)
      * @see org.apache.axis2.engine.AbstractDispatcher#findOperation(org.apache.axis2.description.AxisService, org.apache.axis2.context.MessageContext)
@@ -56,58 +44,7 @@
      * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
      */
     public AxisService findService(MessageContext messageContext) throws AxisFault {
-        EndpointReference toEPR = messageContext.getTo();
-
-        if (toEPR != null) {
-            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
-                log.debug(messageContext.getLogIDString() +
-                        " Checking for Service using target endpoint address : " +
-                        toEPR.getAddress());
-            }
-            String filePart = toEPR.getAddress();
-            //REVIEW: 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
-            ConfigurationContext configurationContext = messageContext.getConfigurationContext();
-            String[] values = Utils.parseRequestURLForServiceAndOperation(filePart,
-                                                                          configurationContext.getServiceContextPath());
-
-            if ((values.length >= 1) && (values[0] != null)) {
-                AxisConfiguration registry =
-                        configurationContext.getAxisConfiguration();
-
-                AxisService axisService = registry.getService(values[0]);
-
-                // If the axisService is not null we get the binding that the request came to add
-                // add it as a property to the messageContext
-                if (axisService != null) {
-                    Map endpoints = axisService.getEndpoints();
-                    if (endpoints != null) {
-                        if (endpoints.size() == 1) {
-                            messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
-                                                       endpoints.get(
-                                                               axisService.getEndpointName()));
-                        } else {
-                            String endpointName = values[0].substring(values[0].indexOf(".") + 1);
-                            messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
-                                                       endpoints.get(endpointName));
-                        }
-                    }
-                }
-
-                return axisService;
-            } else {
-                if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
-                    log.debug(messageContext.getLogIDString() +
-                            " Attempted to check for Service using target endpoint URI, but the service fragment was missing");
-                }
-                return null;
-            }
-        } else {
-            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
-                log.debug(messageContext.getLogIDString() +
-                        " Attempted to check for Service using null target endpoint URI");
-            }
-            return null;
-        }
+    	return rubsd.findService(messageContext);
     }
 
     public void initDispatcher() {



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