KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > engine > AddressingBasedDispatcher


1 /*
2 * Copyright 2004,2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16 package org.apache.axis2.engine;
17
18 import org.apache.axis2.addressing.EndpointReference;
19 import org.apache.axis2.context.MessageContext;
20 import org.apache.axis2.description.HandlerDescription;
21 import org.apache.axis2.description.OperationDescription;
22 import org.apache.axis2.description.ServiceDescription;
23
24 import javax.xml.namespace.QName JavaDoc;
25
26 /**
27  * Class Dispatcher
28  */

29 public class AddressingBasedDispatcher extends AbstractDispatcher {
30     /**
31      * Field NAME
32      */

33     public static final QName JavaDoc NAME =
34         new QName JavaDoc("http://axis.ws.apache.org", "AddressingBasedDispatcher");
35
36     public AddressingBasedDispatcher() {
37         init(new HandlerDescription(NAME));
38     }
39
40     public OperationDescription findOperation(
41         ServiceDescription service,
42         MessageContext messageContext)
43         throws AxisFault {
44
45         String JavaDoc action = (String JavaDoc) messageContext.getWSAAction();
46         if (action != null) {
47             QName JavaDoc operationName = new QName JavaDoc(action);
48             OperationDescription op = service.getOperation(operationName);
49
50             return op;
51         }
52         return null;
53     }
54
55     /* (non-Javadoc)
56      * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
57      */

58     public ServiceDescription findService(MessageContext messageContext) throws AxisFault {
59         EndpointReference toEPR = messageContext.getTo();
60         ServiceDescription service = null;
61         if (toEPR != null) {
62             QName JavaDoc serviceName = new QName JavaDoc(toEPR.getAddress());
63             service =
64                 messageContext.getSystemContext().getAxisConfiguration().getService(serviceName);
65         }
66         return service;
67     }
68
69 }
70
Popular Tags