1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.xml.internal.ws.util; |
26 package com.sun.xml.internal.ws.util; |
27 |
27 |
28 import com.sun.xml.internal.ws.api.WSBinding; |
28 import com.sun.xml.internal.ws.api.WSBinding; |
|
29 import com.sun.xml.internal.ws.api.databinding.MetadataReader; |
29 import com.sun.xml.internal.ws.api.server.AsyncProvider; |
30 import com.sun.xml.internal.ws.api.server.AsyncProvider; |
30 import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; |
31 import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; |
31 import com.sun.xml.internal.ws.handler.HandlerChainsModel; |
32 import com.sun.xml.internal.ws.handler.HandlerChainsModel; |
|
33 import com.sun.xml.internal.ws.model.ReflectAnnotationReader; |
32 import com.sun.xml.internal.ws.server.EndpointFactory; |
34 import com.sun.xml.internal.ws.server.EndpointFactory; |
33 import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil; |
35 import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil; |
34 import com.sun.istack.internal.NotNull; |
36 import com.sun.istack.internal.NotNull; |
35 |
37 |
36 import javax.jws.HandlerChain; |
38 import javax.jws.HandlerChain; |
87 * in has no handler chain annotation. |
89 * in has no handler chain annotation. |
88 */ |
90 */ |
89 public static HandlerAnnotationInfo buildHandlerInfo(@NotNull |
91 public static HandlerAnnotationInfo buildHandlerInfo(@NotNull |
90 Class<?> clazz, QName serviceName, QName portName, WSBinding binding) { |
92 Class<?> clazz, QName serviceName, QName portName, WSBinding binding) { |
91 |
93 |
|
94 MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(clazz, binding); |
|
95 if (metadataReader == null) { |
|
96 metadataReader = new ReflectAnnotationReader(); |
|
97 } |
|
98 |
92 // clazz = checkClass(clazz); |
99 // clazz = checkClass(clazz); |
93 HandlerChain handlerChain = |
100 HandlerChain handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz); |
94 clazz.getAnnotation(HandlerChain.class); |
|
95 if (handlerChain == null) { |
101 if (handlerChain == null) { |
96 clazz = getSEI(clazz); |
102 clazz = getSEI(clazz, metadataReader); |
97 if (clazz != null) |
103 if (clazz != null) |
98 handlerChain = |
104 handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz); |
99 clazz.getAnnotation(HandlerChain.class); |
|
100 if (handlerChain == null) |
105 if (handlerChain == null) |
101 return null; |
106 return null; |
102 } |
107 } |
103 |
108 |
104 if (clazz.getAnnotation(SOAPMessageHandlers.class) != null) { |
109 if (clazz.getAnnotation(SOAPMessageHandlers.class) != null) { |
158 throw new UtilException("util.handler.class.not.found", |
163 throw new UtilException("util.handler.class.not.found", |
159 className); |
164 className); |
160 } |
165 } |
161 } |
166 } |
162 |
167 |
163 static Class getSEI(Class<?> clazz) { |
168 static Class getSEI(Class<?> clazz, MetadataReader metadataReader) { |
|
169 if (metadataReader == null) { |
|
170 metadataReader = new ReflectAnnotationReader(); |
|
171 } |
|
172 |
164 if (Provider.class.isAssignableFrom(clazz) || AsyncProvider.class.isAssignableFrom(clazz)) { |
173 if (Provider.class.isAssignableFrom(clazz) || AsyncProvider.class.isAssignableFrom(clazz)) { |
165 //No SEI for Provider Implementation |
174 //No SEI for Provider Implementation |
166 return null; |
175 return null; |
167 } |
176 } |
168 if (Service.class.isAssignableFrom(clazz)) { |
177 if (Service.class.isAssignableFrom(clazz)) { |
169 //No SEI for Service class |
178 //No SEI for Service class |
170 return null; |
179 return null; |
171 } |
180 } |
172 if (!clazz.isAnnotationPresent(WebService.class)) { |
181 |
173 throw new UtilException("util.handler.no.webservice.annotation", |
182 WebService webService = metadataReader.getAnnotation(WebService.class, clazz); |
174 clazz.getCanonicalName()); |
183 if (webService == null) { |
175 } |
184 throw new UtilException("util.handler.no.webservice.annotation", clazz.getCanonicalName()); |
176 |
185 } |
177 WebService webService = clazz.getAnnotation(WebService.class); |
|
178 |
186 |
179 String ei = webService.endpointInterface(); |
187 String ei = webService.endpointInterface(); |
180 if (ei.length() > 0) { |
188 if (ei.length() > 0) { |
181 clazz = getClass(webService.endpointInterface()); |
189 clazz = getClass(webService.endpointInterface()); |
182 if (!clazz.isAnnotationPresent(WebService.class)) { |
190 WebService ws = metadataReader.getAnnotation(WebService.class, clazz); |
|
191 if (ws == null) { |
183 throw new UtilException("util.handler.endpoint.interface.no.webservice", |
192 throw new UtilException("util.handler.endpoint.interface.no.webservice", |
184 webService.endpointInterface()); |
193 webService.endpointInterface()); |
185 } |
194 } |
186 return clazz; |
195 return clazz; |
187 } |
196 } |