Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 1787 invoked from network); 25 May 2007 17:58:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 May 2007 17:58:49 -0000 Received: (qmail 72231 invoked by uid 500); 25 May 2007 17:58:53 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 72105 invoked by uid 500); 25 May 2007 17:58:52 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 72092 invoked by uid 500); 25 May 2007 17:58:52 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 72089 invoked by uid 99); 25 May 2007 17:58:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 May 2007 10:58:52 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 May 2007 10:58:46 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D38351A981A; Fri, 25 May 2007 10:58:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r541739 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: dispatchers/ engine/ Date: Fri, 25 May 2007 17:58:26 -0000 To: axis2-cvs@ws.apache.org From: davidillsley@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070525175826.D38351A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davidillsley Date: Fri May 25 10:58:25 2007 New Revision: 541739 URL: http://svn.apache.org/viewvc?view=rev&rev=541739 Log: Refactor to contain the dispatch logic in fewer classes. More of this to come. Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/ActionBasedOperationDispatcher.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/ActionBasedOperationDispatcher.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/ActionBasedOperationDispatcher.java?view=diff&rev=541739&r1=541738&r2=541739 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/ActionBasedOperationDispatcher.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/ActionBasedOperationDispatcher.java Fri May 25 10:58:25 2007 @@ -14,6 +14,8 @@ package org.apache.axis2.dispatchers; +import javax.xml.namespace.QName; + import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.axis2.description.AxisOperation; @@ -41,6 +43,16 @@ if (op == null) { op = service.getOperationByAction(action); } + + /* + * HACK: Please remove this when we add support for custom action + * uri + */ + if ((op == null) && (action.lastIndexOf('/') != -1)) { + op = service.getOperation(new QName(action.substring(action.lastIndexOf('/'), + action.length()))); + } + return op; } Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java?view=diff&rev=541739&r1=541738&r2=541739 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java Fri May 25 10:58:25 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 @@ -18,8 +16,6 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.AddressingConstants; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.OperationContext; import org.apache.axis2.context.ServiceContext; @@ -27,15 +23,13 @@ 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.dispatchers.ActionBasedOperationDispatcher; +import org.apache.axis2.dispatchers.RequestURIBasedServiceDispatcher; import org.apache.axis2.i18n.Messages; 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; - /** * Dispatcher based on the WS-Addressing properties. */ @@ -46,77 +40,16 @@ */ public static final String NAME = "AddressingBasedDispatcher"; private static final Log log = LogFactory.getLog(AddressingBasedDispatcher.class); + private RequestURIBasedServiceDispatcher rubsd = new RequestURIBasedServiceDispatcher(); + private ActionBasedOperationDispatcher abod = new ActionBasedOperationDispatcher(); - // TODO this logic needed to be improved, as the Dispatching is almost guaranteed to fail public AxisOperation findOperation(AxisService service, MessageContext messageContext) throws AxisFault { - if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { - log.debug( - messageContext.getLogIDString() + " " + Messages.getMessage("checkingoperation", - messageContext.getWSAAction())); - } - String action = messageContext.getWSAAction(); - - if (action != null) { - return service.getOperationByAction(action); - } - - return null; + return abod.findOperation(service, messageContext); } public AxisService findService(MessageContext messageContext) throws AxisFault { - EndpointReference toEPR = messageContext.getTo(); - - if ((toEPR == null) || (toEPR.hasAnonymousAddress())) { - return null; - } - - AxisService service = null; - String address = toEPR.getAddress(); - if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { - log.debug(messageContext.getLogIDString() + " " + - Messages.getMessage("checkingserviceforepr", address)); - } - - ConfigurationContext configurationContext = messageContext.getConfigurationContext(); - String[] values = - Utils.parseRequestURLForServiceAndOperation(address, - configurationContext. - getServiceContextPath()); - if (values == null) { - return null; - } - - if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { - log.debug(messageContext.getLogIDString() + " " + - Messages.getMessage("checkingserviceforepr", values[0])); - } - - if (values[0] != null) { - AxisConfiguration registry = - configurationContext.getAxisConfiguration(); - - service = registry.getService(values[0]); - - // If the axisService is not null we get the binding that the request came to and - // add it as a property to the messageContext - if (service != null) { - Map endpoints = service.getEndpoints(); - if (endpoints != null) { - if (endpoints.size() == 1) { - messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME, - endpoints.get( - service.getEndpointName())); - } else { - String endpointName = values[0].substring(values[0].indexOf(".") + 1); - messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME, - endpoints.get(endpointName)); - } - } - } - } - - return service; + return rubsd.findService(messageContext); } public void initDispatcher() { Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java?view=diff&rev=541739&r1=541738&r2=541739 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java Fri May 25 10:58:25 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,21 +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.MessageContext; import org.apache.axis2.description.AxisOperation; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.HandlerDescription; -import org.apache.axis2.util.Utils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.namespace.QName; +import org.apache.axis2.dispatchers.RequestURIBasedOperationDispatcher; /** * Dispatches the operation based on the information from the target endpoint URL. @@ -35,7 +26,7 @@ public class RequestURIOperationDispatcher extends AbstractDispatcher { public static final String NAME = "RequestURIOperationDispatcher"; - private static final Log log = LogFactory.getLog(RequestURIOperationDispatcher.class); + private RequestURIBasedOperationDispatcher rubod = new RequestURIBasedOperationDispatcher(); /* * (non-Javadoc) @@ -43,31 +34,7 @@ */ public AxisOperation findOperation(AxisService service, MessageContext messageContext) throws AxisFault { - - EndpointReference toEPR = messageContext.getTo(); - if (toEPR != null) { - String filePart = toEPR.getAddress(); - String[] values = Utils.parseRequestURLForServiceAndOperation(filePart, - messageContext - .getConfigurationContext().getServiceContextPath()); - - if ((values.length >= 2) && (values[1] != null)) { - QName operationName = new QName(values[1]); - log.debug(messageContext.getLogIDString() + - " Checking for Operation using QName(target endpoint URI fragment) : " + - operationName); - AxisOperation axisOperation = service.getOperation(operationName); - return axisOperation; - } else { - log.debug(messageContext.getLogIDString() + - " Attempted to check for Operation using target endpoint URI, but the operation fragment was missing"); - return null; - } - } else { - log.debug(messageContext.getLogIDString() + - " Attempted to check for Operation using null target endpoint URI"); - return null; - } + return rubod.findOperation(service, messageContext); } /* Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java?view=diff&rev=541739&r1=541738&r2=541739 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java Fri May 25 10:58:25 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,8 +11,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.axis2.engine; import org.apache.axis2.AxisFault; @@ -22,12 +18,11 @@ import org.apache.axis2.description.AxisOperation; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.HandlerDescription; +import org.apache.axis2.dispatchers.ActionBasedOperationDispatcher; import org.apache.axis2.util.LoggingControl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.xml.namespace.QName; - /** * Dispatches based on the SOAPAction. */ @@ -38,35 +33,11 @@ */ public static final String NAME = "SOAPActionBasedDispatcher"; private static final Log log = LogFactory.getLog(SOAPActionBasedDispatcher.class); + private ActionBasedOperationDispatcher abod = new ActionBasedOperationDispatcher(); public AxisOperation findOperation(AxisService service, MessageContext messageContext) throws AxisFault { - String action = messageContext.getSoapAction(); - - if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { - log.debug(messageContext.getLogIDString() + - " Checking for Operation using SOAPAction : " + action); - } - if (action != null) { - AxisOperation op = service.getOperationBySOAPAction(action); - - if (op == null) { - op = service.getOperationByAction(action); - } - - /* - * HACK: Please remove this when we add support for custom action - * uri - */ - if ((op == null) && (action.lastIndexOf('/') != -1)) { - op = service.getOperation(new QName(action.substring(action.lastIndexOf('/'), - action.length()))); - } - - return op; - } - - return null; + return abod.findOperation(service, messageContext); } /* --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org