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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]