KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.apache.axis2.util.Utils;
24
25 import javax.xml.namespace.QName JavaDoc;
26
27 /**
28  * Class Dispatcher
29  */

30 public class RequestURIBasedDispatcher extends AbstractDispatcher {
31     /**
32      * Field NAME
33      */

34     public static final QName JavaDoc NAME =
35         new QName JavaDoc("http://axis.ws.apache.org", "RequestURIBasedDispatcher");
36     QName JavaDoc serviceName = null;
37     QName JavaDoc operatoinName = null;
38
39     /**
40      * Constructor Dispatcher
41      */

42     public RequestURIBasedDispatcher() {
43         init(new HandlerDescription(NAME));
44     }
45
46     public OperationDescription findOperation(
47         ServiceDescription service,
48         MessageContext messageContext)
49         throws AxisFault {
50         if (operatoinName != null) {
51             OperationDescription axisOp = service.getOperation(operatoinName);
52             return axisOp;
53         }
54         return null;
55
56     }
57
58     /* (non-Javadoc)
59      * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
60      */

61     public ServiceDescription findService(MessageContext messageContext) throws AxisFault {
62         EndpointReference toEPR = messageContext.getTo();
63         if (toEPR != null) {
64             String JavaDoc filePart = toEPR.getAddress();
65             String JavaDoc[] values = Utils.parseRequestURLForServiceAndOperation(filePart);
66             if (values[1] != null) {
67                 operatoinName = new QName JavaDoc(values[1]);
68             }
69             if (values[0] != null) {
70                 serviceName = new QName JavaDoc(values[0]);
71                 AxisConfiguration registry =
72                     messageContext.getSystemContext().getAxisConfiguration();
73                 return registry.getService(serviceName);
74             }
75         }
76         return null;
77     }
78 }
79
Popular Tags