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: */package org.apache.cxf.jaxws;
19:
20: import java.lang.reflect.Method;
21: import java.util.logging.Logger;
22:
23: import org.apache.cxf.common.i18n.Message;
24: import org.apache.cxf.common.logging.LogUtils;
25: import org.apache.cxf.endpoint.Endpoint;
26: import org.apache.cxf.frontend.SimpleMethodDispatcher;
27: import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
28: import org.apache.cxf.service.factory.ServiceConstructionException;
29: import org.apache.cxf.service.model.BindingOperationInfo;
30: import org.apache.cxf.service.model.OperationInfo;
31:
32: public class JAXWSMethodDispatcher extends SimpleMethodDispatcher {
33:
34: private static final Logger LOG = LogUtils
35: .getL7dLogger(JAXWSMethodDispatcher.class);
36:
37: private JaxWsImplementorInfo implInfo;
38:
39: public JAXWSMethodDispatcher(JaxWsImplementorInfo implInfo) {
40: this .implInfo = implInfo;
41: }
42:
43: public void bind(OperationInfo o, Method... methods) {
44: Method[] newMethods = new Method[methods.length];
45: int i = 0;
46: for (Method m : methods) {
47: try {
48: newMethods[i++] = getImplementationMethod(m);
49: } catch (NoSuchMethodException e) {
50: Class endpointClass = implInfo.getImplementorClass();
51: Message msg = new Message("SEI_METHOD_NOT_FOUND", LOG,
52: m.getName(), endpointClass.getName());
53: throw new ServiceConstructionException(msg, e);
54: }
55: }
56: super .bind(o, newMethods);
57: }
58:
59: public BindingOperationInfo getBindingOperation(Method method,
60: Endpoint endpoint) {
61: try {
62: method = getImplementationMethod(method);
63: } catch (NoSuchMethodException e) {
64: // ignore
65: }
66: return super .getBindingOperation(method, endpoint);
67: }
68:
69: public Method getImplementationMethod(Method method)
70: throws NoSuchMethodException {
71: Class<?> endpointClass = implInfo.getImplementorClass();
72:
73: if (!endpointClass.isAssignableFrom(method.getDeclaringClass())) {
74: try {
75: method = endpointClass.getMethod(method.getName(),
76: (Class[]) method.getParameterTypes());
77: } catch (SecurityException e) {
78: throw new ServiceConstructionException(e);
79: }
80: }
81: return method;
82: }
83:
84: }
|