01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.dispatchers;
21:
22: import org.apache.axis2.AxisFault;
23: import org.apache.axis2.addressing.EndpointReference;
24: import org.apache.axis2.context.MessageContext;
25: import org.apache.axis2.description.AxisOperation;
26: import org.apache.axis2.description.AxisService;
27: import org.apache.axis2.description.HandlerDescription;
28: import org.apache.axis2.util.Utils;
29: import org.apache.commons.logging.Log;
30: import org.apache.commons.logging.LogFactory;
31:
32: import javax.xml.namespace.QName;
33:
34: /**
35: * Dispatches the operation based on the information from the target endpoint URL.
36: */
37: public class RequestURIBasedOperationDispatcher extends
38: AbstractOperationDispatcher {
39:
40: public static final String NAME = "RequestURIBasedOperationDispatcher";
41: private static final Log log = LogFactory
42: .getLog(RequestURIBasedOperationDispatcher.class);
43:
44: /*
45: * (non-Javadoc)
46: * @see org.apache.axis2.engine.AbstractDispatcher#findOperation(org.apache.axis2.description.AxisService, org.apache.axis2.context.MessageContext)
47: */
48: public AxisOperation findOperation(AxisService service,
49: MessageContext messageContext) throws AxisFault {
50:
51: EndpointReference toEPR = messageContext.getTo();
52: if (toEPR != null) {
53: String filePart = toEPR.getAddress();
54: String[] values = Utils
55: .parseRequestURLForServiceAndOperation(filePart,
56: messageContext.getConfigurationContext()
57: .getServiceContextPath());
58:
59: if ((values.length >= 2) && (values[1] != null)) {
60: QName operationName = new QName(values[1]);
61: log
62: .debug(messageContext.getLogIDString()
63: + " Checking for Operation using QName(target endpoint URI fragment) : "
64: + operationName);
65: return service.getOperation(operationName);
66: } else {
67: log
68: .debug(messageContext.getLogIDString()
69: + " Attempted to check for Operation using target endpoint URI, but the operation fragment was missing");
70: return null;
71: }
72: } else {
73: log
74: .debug(messageContext.getLogIDString()
75: + " Attempted to check for Operation using null target endpoint URI");
76: return null;
77: }
78: }
79:
80: public void initDispatcher() {
81: init(new HandlerDescription(NAME));
82: }
83: }
|