KickJava   Java API By Example, From Geeks To Geeks.

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


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.context.ConfigurationContext;
19 import org.apache.axis2.context.MessageContext;
20 import org.apache.axis2.context.OperationContext;
21 import org.apache.axis2.description.HandlerDescription;
22 import org.apache.axis2.description.OperationDescription;
23 import org.apache.axis2.description.ServiceDescription;
24 import org.apache.axis2.handlers.AbstractHandler;
25
26 import javax.xml.namespace.QName JavaDoc;
27
28 /**
29  * Class Dispatcher
30  */

31 public abstract class AbstractDispatcher extends AbstractHandler implements Handler {
32     /**
33      * Field NAME
34      */

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

41     private ConfigurationContext engineContext;
42     
43     public AbstractDispatcher() {
44         init(new HandlerDescription(NAME));
45     }
46
47     /**
48      * Method invoke
49      *
50      * @param msgctx
51      * @throws AxisFault
52      */

53     public final void invoke(MessageContext msgctx) throws AxisFault {
54   
55         if(msgctx.getServiceContext() == null){
56             ServiceDescription axisService = findService(msgctx);
57             if(axisService != null){
58                 msgctx.setServiceContext(axisService.findServiceContext(msgctx));
59             }
60         }
61
62         if (msgctx.getServiceContext() != null && msgctx.getOperationContext() == null) {
63             OperationDescription axisOperation = findOperation(msgctx.getServiceContext().getServiceConfig(),msgctx);
64             if(axisOperation != null){
65                 OperationContext operationContext = axisOperation.findOperationContext(msgctx,msgctx.getServiceContext());
66                 msgctx.setOperationContext(operationContext);
67             }
68         }
69
70     }
71     
72     public abstract ServiceDescription findService(MessageContext messageContext)throws AxisFault;
73     public abstract OperationDescription findOperation(ServiceDescription service,MessageContext messageContext)throws AxisFault;
74     
75 }
76
Popular Tags