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.util.logging.Logger;
21:
22: import javax.jws.WebService;
23: import javax.xml.ws.Provider;
24: import javax.xml.ws.WebServiceProvider;
25:
26: import org.apache.cxf.common.logging.LogUtils;
27:
28: public final class EndpointUtils {
29:
30: private static final Logger LOG = LogUtils
31: .getL7dLogger(EndpointUtils.class);
32:
33: private EndpointUtils() {
34: // Utility class - never constructed
35: }
36:
37: private static boolean hasWebServiceAnnotation(Class<?> cls) {
38: if (cls == null) {
39: return false;
40: }
41: if (null != cls.getAnnotation(WebService.class)) {
42: return true;
43: }
44: for (Class<?> inf : cls.getInterfaces()) {
45: if (null != inf.getAnnotation(WebService.class)) {
46: return true;
47: }
48: }
49:
50: return hasWebServiceAnnotation(cls.getSuperclass());
51: }
52:
53: private static boolean hasWebServiceProviderAnnotation(Class<?> cls) {
54: if (cls != null) {
55: return cls.isAnnotationPresent(WebServiceProvider.class);
56: }
57:
58: return false;
59: }
60:
61: public static boolean isValidImplementor(Object implementor) {
62: if (Provider.class.isAssignableFrom(implementor.getClass())
63: && hasWebServiceProviderAnnotation(implementor
64: .getClass())) {
65: return true;
66: }
67:
68: // implementor MUST be an instance of a class with a WebService
69: // annotation
70: // (that implements an SEI) OR a Provider
71:
72: if (hasWebServiceAnnotation(implementor.getClass())) {
73: return true;
74: }
75:
76: LOG
77: .info("Implementor is not annotated with WebService annotation.");
78: return false;
79: }
80: }
|