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.context.MessageContext;
24: import org.apache.axis2.description.AxisOperation;
25: import org.apache.axis2.description.AxisService;
26: import org.apache.axis2.description.HandlerDescription;
27: import org.apache.axis2.handlers.AbstractHandler;
28: import org.apache.axis2.i18n.Messages;
29: import org.apache.axis2.util.LoggingControl;
30: import org.apache.axis2.wsdl.WSDLConstants;
31: import org.apache.commons.logging.Log;
32: import org.apache.commons.logging.LogFactory;
33:
34: public abstract class AbstractOperationDispatcher extends
35: AbstractHandler {
36:
37: public static final String NAME = "AbstractOperationDispatcher";
38: private static final Log log = LogFactory
39: .getLog(AbstractOperationDispatcher.class);
40:
41: public AbstractOperationDispatcher() {
42: init(new HandlerDescription(NAME));
43: }
44:
45: /**
46: * Called by Axis Engine to find the operation.
47: *
48: * @param service
49: * @param messageContext
50: * @return Returns AxisOperation.
51: * @throws AxisFault
52: */
53: public abstract AxisOperation findOperation(AxisService service,
54: MessageContext messageContext) throws AxisFault;
55:
56: public abstract void initDispatcher();
57:
58: /**
59: * @param msgctx
60: * @throws org.apache.axis2.AxisFault
61: */
62: public InvocationResponse invoke(MessageContext msgctx)
63: throws AxisFault {
64: if ((msgctx.getAxisService() != null)
65: && (msgctx.getAxisOperation() == null)) {
66: AxisOperation axisOperation = findOperation(msgctx
67: .getAxisService(), msgctx);
68:
69: if (axisOperation != null) {
70: if (LoggingControl.debugLoggingAllowed
71: && log.isDebugEnabled()) {
72: log.debug(msgctx.getLogIDString()
73: + " "
74: + Messages.getMessage("operationfound",
75: axisOperation.getName()
76: .getLocalPart()));
77: }
78:
79: msgctx.setAxisOperation(axisOperation);
80: //setting axisMessage into messageContext
81: msgctx
82: .setAxisMessage(axisOperation
83: .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
84: }
85: }
86: return InvocationResponse.CONTINUE;
87: }
88: }
|