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