|
1 /* |
|
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
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 |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.internal.ws.wsdl.parser; |
|
27 |
|
28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; |
|
29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; |
|
30 import com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext; |
|
31 import com.sun.tools.internal.ws.util.xml.XmlUtil; |
|
32 import com.sun.tools.internal.ws.wsdl.document.*; |
|
33 import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName; |
|
34 import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding; |
|
35 import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBindingsConstants; |
|
36 import com.sun.tools.internal.ws.wsdl.document.jaxws.Parameter; |
|
37 import org.w3c.dom.Element; |
|
38 import org.w3c.dom.Node; |
|
39 import org.w3c.dom.NodeList; |
|
40 |
|
41 import javax.xml.namespace.NamespaceContext; |
|
42 import javax.xml.namespace.QName; |
|
43 import javax.xml.xpath.*; |
|
44 import java.util.Iterator; |
|
45 import java.util.Map; |
|
46 |
|
47 |
|
48 /** |
|
49 * @author Vivek Pandey |
|
50 * |
|
51 * jaxws:bindings exension handler. |
|
52 * |
|
53 */ |
|
54 public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler { |
|
55 |
|
56 // xml security enabled always, xpath used for parsing "part" attribute |
|
57 private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() { |
|
58 @Override |
|
59 protected XPathFactory initialValue() throws Exception { |
|
60 return XPathFactory.newInstance(); |
|
61 } |
|
62 }; |
|
63 |
|
64 private final XPath xpath = xpf.get().newXPath(); |
|
65 |
|
66 public JAXWSBindingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap) { |
|
67 super(extensionHandlerMap); |
|
68 } |
|
69 |
|
70 /* (non-Javadoc) |
|
71 * @see AbstractExtensionHandler#getNamespaceURI() |
|
72 */ |
|
73 @Override |
|
74 public String getNamespaceURI() { |
|
75 return JAXWSBindingsConstants.NS_JAXWS_BINDINGS; |
|
76 } |
|
77 |
|
78 /** |
|
79 * @param context |
|
80 * @param parent |
|
81 * @param e |
|
82 */ |
|
83 private boolean parseGlobalJAXWSBindings(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
84 context.push(); |
|
85 context.registerNamespaces(e); |
|
86 |
|
87 JAXWSBinding jaxwsBinding = getJAXWSExtension(parent); |
|
88 if(jaxwsBinding == null) { |
|
89 jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
90 } |
|
91 String attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.WSDL_LOCATION_ATTR); |
|
92 if (attr != null) { |
|
93 jaxwsBinding.setWsdlLocation(attr); |
|
94 } |
|
95 |
|
96 attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NODE_ATTR); |
|
97 if (attr != null) { |
|
98 jaxwsBinding.setNode(attr); |
|
99 } |
|
100 |
|
101 attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.VERSION_ATTR); |
|
102 if (attr != null) { |
|
103 jaxwsBinding.setVersion(attr); |
|
104 } |
|
105 |
|
106 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
107 Element e2 = Util.nextElement(iter); |
|
108 if (e2 == null) { |
|
109 break; |
|
110 } |
|
111 |
|
112 if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) { |
|
113 parsePackage(context, jaxwsBinding, e2); |
|
114 if ((jaxwsBinding.getJaxwsPackage() != null) && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) { |
|
115 ((Definitions) parent).setDocumentation(new Documentation(jaxwsBinding.getJaxwsPackage().getJavaDoc())); |
|
116 } |
|
117 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) { |
|
118 parseWrapperStyle(context, jaxwsBinding, e2); |
|
119 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) { |
|
120 parseAsynMapping(context, jaxwsBinding, e2); |
|
121 } // else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){ |
|
122 // parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2); |
|
123 // } |
|
124 else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) { |
|
125 parseMimeContent(context, jaxwsBinding, e2); |
|
126 } else { |
|
127 Util.fail( |
|
128 "parsing.invalidExtensionElement", |
|
129 e2.getTagName(), |
|
130 e2.getNamespaceURI()); |
|
131 return false; |
|
132 } |
|
133 } |
|
134 parent.addExtension(jaxwsBinding); |
|
135 context.pop(); |
|
136 // context.fireDoneParsingEntity( |
|
137 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
138 // jaxwsBinding); |
|
139 return true; |
|
140 } |
|
141 |
|
142 private static JAXWSBinding getJAXWSExtension(TWSDLExtensible extensible) { |
|
143 for (TWSDLExtension extension:extensible.extensions()) { |
|
144 if (extension.getClass().equals(JAXWSBinding.class)) { |
|
145 return (JAXWSBinding)extension; |
|
146 } |
|
147 } |
|
148 |
|
149 return null; |
|
150 } |
|
151 |
|
152 /** |
|
153 * @param context |
|
154 * @param parent |
|
155 * @param e |
|
156 */ |
|
157 private void parseProvider(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) { |
|
158 String val = e.getTextContent(); |
|
159 if (val == null) { |
|
160 return; |
|
161 } |
|
162 if (val.equals("false") || val.equals("0")) { |
|
163 ((JAXWSBinding)parent).setProvider(Boolean.FALSE); |
|
164 } else if(val.equals("true") || val.equals("1")) { |
|
165 ((JAXWSBinding)parent).setProvider(Boolean.TRUE); |
|
166 } |
|
167 |
|
168 } |
|
169 |
|
170 /** |
|
171 * @param context |
|
172 * @param parent |
|
173 * @param e |
|
174 */ |
|
175 private void parsePackage(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) { |
|
176 //System.out.println("In handlePackageExtension: " + e.getNodeName()); |
|
177 String packageName = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR); |
|
178 JAXWSBinding binding = (JAXWSBinding)parent; |
|
179 binding.setJaxwsPackage(new CustomName(packageName, getJavaDoc(e))); |
|
180 } |
|
181 |
|
182 /** |
|
183 * @param context |
|
184 * @param parent |
|
185 * @param e |
|
186 */ |
|
187 private void parseWrapperStyle(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) { |
|
188 //System.out.println("In handleWrapperStyleExtension: " + e.getNodeName()); |
|
189 String val = e.getTextContent(); |
|
190 if (val == null) { |
|
191 return; |
|
192 } |
|
193 if (val.equals("false") || val.equals("0")) { |
|
194 ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.FALSE); |
|
195 } else if (val.equals("true") || val.equals("1")) { |
|
196 ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.TRUE); |
|
197 } |
|
198 } |
|
199 |
|
200 /** |
|
201 * @param context |
|
202 * @param parent |
|
203 * @param e |
|
204 */ |
|
205 // private void parseAdditionalSOAPHeaderMapping(TWSDLParserContextImpl context, TWSDLExtensible parent, Element e) { |
|
206 // //System.out.println("In handleAdditionalSOAPHeaderExtension: " + e.getNodeName()); |
|
207 // String val = e.getTextContent(); |
|
208 // if(val == null) |
|
209 // return; |
|
210 // if(val.equals("false") || val.equals("0")){ |
|
211 // ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.FALSE); |
|
212 // }else if(val.equals("true") || val.equals("1")){ |
|
213 // ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.TRUE); |
|
214 // } |
|
215 // } |
|
216 |
|
217 /** |
|
218 * @param context |
|
219 * @param parent |
|
220 * @param e |
|
221 */ |
|
222 private void parseAsynMapping(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) { |
|
223 //System.out.println("In handleAsynMappingExtension: " + e.getNodeName()); |
|
224 String val = e.getTextContent(); |
|
225 if (val == null) { |
|
226 return; |
|
227 } |
|
228 if (val.equals("false") || val.equals("0")) { |
|
229 ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.FALSE); |
|
230 } else if (val.equals("true") || val.equals("1")) { |
|
231 ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.TRUE); |
|
232 } |
|
233 } |
|
234 |
|
235 /** |
|
236 * @param context |
|
237 * @param parent |
|
238 * @param e |
|
239 */ |
|
240 private void parseMimeContent(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) { |
|
241 //System.out.println("In handleMimeContentExtension: " + e.getNodeName()); |
|
242 String val = e.getTextContent(); |
|
243 if (val == null) { |
|
244 return; |
|
245 } |
|
246 if (val.equals("false") || val.equals("0")) { |
|
247 ((JAXWSBinding) parent).setEnableMimeContentMapping(Boolean.FALSE); |
|
248 } else if (val.equals("true") || val.equals("1")) { |
|
249 ((JAXWSBinding) parent).setEnableMimeContentMapping(Boolean.TRUE); |
|
250 } |
|
251 } |
|
252 |
|
253 /** |
|
254 * @param context |
|
255 * @param jaxwsBinding |
|
256 * @param e |
|
257 */ |
|
258 private void parseMethod(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) { |
|
259 String methodName = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR); |
|
260 String javaDoc = getJavaDoc(e); |
|
261 CustomName name = new CustomName(methodName, javaDoc); |
|
262 jaxwsBinding.setMethodName(name); |
|
263 } |
|
264 |
|
265 /** |
|
266 * @param context |
|
267 * @param jaxwsBinding |
|
268 * @param e |
|
269 */ |
|
270 private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) { |
|
271 String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR); |
|
272 Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e)); |
|
273 Node msgElm = msgPartElm.getParentNode(); |
|
274 //MessagePart msgPart = new MessagePart(); |
|
275 |
|
276 String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name"); |
|
277 String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name"); |
|
278 if ((partName == null) || (msgName == null)) { |
|
279 return; |
|
280 } |
|
281 |
|
282 String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR); |
|
283 String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR); |
|
284 |
|
285 QName elementName = null; |
|
286 if(element != null){ |
|
287 String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element)); |
|
288 elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element)); |
|
289 } |
|
290 |
|
291 jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name)); |
|
292 } |
|
293 |
|
294 private Element evaluateXPathNode(Node target, String expression, NamespaceContext namespaceContext) { |
|
295 NodeList nlst; |
|
296 try { |
|
297 xpath.setNamespaceContext(namespaceContext); |
|
298 nlst = (NodeList)xpath.evaluate(expression, target, XPathConstants.NODESET); |
|
299 } catch (XPathExpressionException e) { |
|
300 Util.fail("internalizer.XPathEvaluationError", e.getMessage()); |
|
301 return null; // abort processing this <jaxb:bindings> |
|
302 } |
|
303 |
|
304 if( nlst.getLength()==0 ) { |
|
305 Util.fail("internalizer.XPathEvaluatesToNoTarget", new Object[]{expression}); |
|
306 return null; // abort |
|
307 } |
|
308 |
|
309 if( nlst.getLength()!=1 ) { |
|
310 Util.fail("internalizer.XPathEvaulatesToTooManyTargets", new Object[]{expression, nlst.getLength()}); |
|
311 return null; // abort |
|
312 } |
|
313 |
|
314 Node rnode = nlst.item(0); |
|
315 if(!(rnode instanceof Element )) { |
|
316 Util.fail("internalizer.XPathEvaluatesToNonElement", new Object[]{expression}); |
|
317 return null; // abort |
|
318 } |
|
319 return (Element)rnode; |
|
320 } |
|
321 |
|
322 /** |
|
323 * @param context |
|
324 * @param jaxwsBinding |
|
325 * @param e |
|
326 */ |
|
327 private void parseClass(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) { |
|
328 String className = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR); |
|
329 String javaDoc = getJavaDoc(e); |
|
330 jaxwsBinding.setClassName(new CustomName(className, javaDoc)); |
|
331 } |
|
332 |
|
333 |
|
334 @Override |
|
335 public boolean handleDefinitionsExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
336 return parseGlobalJAXWSBindings(context, parent, e); |
|
337 } |
|
338 |
|
339 @Override |
|
340 public boolean handlePortTypeExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
341 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
342 context.push(); |
|
343 context.registerNamespaces(e); |
|
344 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
345 |
|
346 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
347 Element e2 = Util.nextElement(iter); |
|
348 if (e2 == null) { |
|
349 break; |
|
350 } |
|
351 |
|
352 if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) { |
|
353 parseWrapperStyle(context, jaxwsBinding, e2); |
|
354 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) { |
|
355 parseAsynMapping(context, jaxwsBinding, e2); |
|
356 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)) { |
|
357 parseClass(context, jaxwsBinding, e2); |
|
358 if ((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null) && (parent instanceof PortType)) { |
|
359 ((PortType) parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc())); |
|
360 } |
|
361 } else { |
|
362 Util.fail( |
|
363 "parsing.invalidExtensionElement", |
|
364 e2.getTagName(), |
|
365 e2.getNamespaceURI()); |
|
366 return false; |
|
367 } |
|
368 } |
|
369 parent.addExtension(jaxwsBinding); |
|
370 context.pop(); |
|
371 // context.fireDoneParsingEntity( |
|
372 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
373 // jaxwsBinding); |
|
374 return true; |
|
375 }else { |
|
376 Util.fail( |
|
377 "parsing.invalidExtensionElement", |
|
378 e.getTagName(), |
|
379 e.getNamespaceURI()); |
|
380 return false; |
|
381 } |
|
382 } |
|
383 |
|
384 @Override |
|
385 public boolean handleOperationExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
386 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
387 if(parent instanceof Operation){ |
|
388 return handlePortTypeOperation(context, (Operation)parent, e); |
|
389 }else if(parent instanceof BindingOperation){ |
|
390 return handleBindingOperation(context, (BindingOperation)parent, e); |
|
391 } |
|
392 }else { |
|
393 Util.fail( |
|
394 "parsing.invalidExtensionElement", |
|
395 e.getTagName(), |
|
396 e.getNamespaceURI()); |
|
397 return false; |
|
398 } |
|
399 return false; |
|
400 } |
|
401 |
|
402 private boolean handleBindingOperation(TWSDLParserContext context, BindingOperation operation, Element e) { |
|
403 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
404 context.push(); |
|
405 context.registerNamespaces(e); |
|
406 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
407 |
|
408 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
409 Element e2 = Util.nextElement(iter); |
|
410 if (e2 == null) { |
|
411 break; |
|
412 } |
|
413 |
|
414 // if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){ |
|
415 // parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2); |
|
416 // }else |
|
417 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)){ |
|
418 parseMimeContent(context, jaxwsBinding, e2); |
|
419 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PARAMETER)){ |
|
420 parseParameter(context, jaxwsBinding, e2); |
|
421 }else{ |
|
422 Util.fail( |
|
423 "parsing.invalidExtensionElement", |
|
424 e2.getTagName(), |
|
425 e2.getNamespaceURI()); |
|
426 return false; |
|
427 } |
|
428 } |
|
429 operation.addExtension(jaxwsBinding); |
|
430 context.pop(); |
|
431 // context.fireDoneParsingEntity( |
|
432 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
433 // jaxwsBinding); |
|
434 return true; |
|
435 }else { |
|
436 Util.fail( |
|
437 "parsing.invalidExtensionElement", |
|
438 e.getTagName(), |
|
439 e.getNamespaceURI()); |
|
440 return false; |
|
441 } |
|
442 } |
|
443 |
|
444 private boolean handlePortTypeOperation(TWSDLParserContext context, Operation parent, Element e) { |
|
445 context.push(); |
|
446 context.registerNamespaces(e); |
|
447 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
448 |
|
449 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
450 Element e2 = Util.nextElement(iter); |
|
451 if (e2 == null) { |
|
452 break; |
|
453 } |
|
454 |
|
455 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)){ |
|
456 parseWrapperStyle(context, jaxwsBinding, e2); |
|
457 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)){ |
|
458 parseAsynMapping(context, jaxwsBinding, e2); |
|
459 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.METHOD)){ |
|
460 parseMethod(context, jaxwsBinding, e2); |
|
461 if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){ |
|
462 parent.setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc())); |
|
463 } |
|
464 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PARAMETER)){ |
|
465 parseParameter(context, jaxwsBinding, e2); |
|
466 }else{ |
|
467 Util.fail( |
|
468 "parsing.invalidExtensionElement", |
|
469 e2.getTagName(), |
|
470 e2.getNamespaceURI()); |
|
471 return false; |
|
472 } |
|
473 } |
|
474 parent.addExtension(jaxwsBinding); |
|
475 context.pop(); |
|
476 // context.fireDoneParsingEntity( |
|
477 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
478 // jaxwsBinding); |
|
479 return true; |
|
480 } |
|
481 |
|
482 @Override |
|
483 public boolean handleBindingExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
484 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
485 context.push(); |
|
486 context.registerNamespaces(e); |
|
487 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
488 |
|
489 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
490 Element e2 = Util.nextElement(iter); |
|
491 if (e2 == null) { |
|
492 break; |
|
493 } |
|
494 |
|
495 // if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){ |
|
496 // parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2); |
|
497 // }else |
|
498 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)){ |
|
499 parseMimeContent(context, jaxwsBinding, e2); |
|
500 }else{ |
|
501 Util.fail( |
|
502 "parsing.invalidExtensionElement", |
|
503 e2.getTagName(), |
|
504 e2.getNamespaceURI()); |
|
505 return false; |
|
506 } |
|
507 } |
|
508 parent.addExtension(jaxwsBinding); |
|
509 context.pop(); |
|
510 // context.fireDoneParsingEntity( |
|
511 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
512 // jaxwsBinding); |
|
513 return true; |
|
514 }else { |
|
515 Util.fail( |
|
516 "parsing.invalidExtensionElement", |
|
517 e.getTagName(), |
|
518 e.getNamespaceURI()); |
|
519 return false; |
|
520 } |
|
521 } |
|
522 |
|
523 /* (non-Javadoc) |
|
524 * @see ExtensionHandlerBase#handleFaultExtension(TWSDLParserContextImpl, TWSDLExtensible, org.w3c.dom.Element) |
|
525 */ |
|
526 @Override |
|
527 public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
528 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
529 context.push(); |
|
530 context.registerNamespaces(e); |
|
531 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
532 |
|
533 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
534 Element e2 = Util.nextElement(iter); |
|
535 if (e2 == null) { |
|
536 break; |
|
537 } |
|
538 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)){ |
|
539 parseClass(context, jaxwsBinding, e2); |
|
540 if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){ |
|
541 ((Fault)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc())); |
|
542 } |
|
543 }else{ |
|
544 Util.fail( |
|
545 "parsing.invalidExtensionElement", |
|
546 e2.getTagName(), |
|
547 e2.getNamespaceURI()); |
|
548 return false; |
|
549 } |
|
550 } |
|
551 parent.addExtension(jaxwsBinding); |
|
552 context.pop(); |
|
553 // context.fireDoneParsingEntity( |
|
554 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
555 // jaxwsBinding); |
|
556 return true; |
|
557 }else { |
|
558 Util.fail( |
|
559 "parsing.invalidExtensionElement", |
|
560 e.getTagName(), |
|
561 e.getNamespaceURI()); |
|
562 return false; |
|
563 } |
|
564 } |
|
565 |
|
566 @Override |
|
567 public boolean handleServiceExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
568 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
569 context.push(); |
|
570 context.registerNamespaces(e); |
|
571 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
572 |
|
573 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
574 Element e2 = Util.nextElement(iter); |
|
575 if (e2 == null) { |
|
576 break; |
|
577 } |
|
578 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)){ |
|
579 parseClass(context, jaxwsBinding, e2); |
|
580 if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){ |
|
581 ((Service)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc())); |
|
582 } |
|
583 }else{ |
|
584 Util.fail( |
|
585 "parsing.invalidExtensionElement", |
|
586 e2.getTagName(), |
|
587 e2.getNamespaceURI()); |
|
588 return false; |
|
589 } |
|
590 } |
|
591 parent.addExtension(jaxwsBinding); |
|
592 context.pop(); |
|
593 // context.fireDoneParsingEntity( |
|
594 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
595 // jaxwsBinding); |
|
596 return true; |
|
597 }else { |
|
598 Util.fail( |
|
599 "parsing.invalidExtensionElement", |
|
600 e.getTagName(), |
|
601 e.getNamespaceURI()); |
|
602 return false; |
|
603 } |
|
604 } |
|
605 |
|
606 @Override |
|
607 public boolean handlePortExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) { |
|
608 if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){ |
|
609 context.push(); |
|
610 context.registerNamespaces(e); |
|
611 JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); |
|
612 |
|
613 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
614 Element e2 = Util.nextElement(iter); |
|
615 if (e2 == null) { |
|
616 break; |
|
617 } |
|
618 |
|
619 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PROVIDER)){ |
|
620 parseProvider(context, jaxwsBinding, e2); |
|
621 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.METHOD)){ |
|
622 parseMethod(context, jaxwsBinding, e2); |
|
623 if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){ |
|
624 ((Port)parent).setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc())); |
|
625 } |
|
626 }else{ |
|
627 Util.fail( |
|
628 "parsing.invalidExtensionElement", |
|
629 e2.getTagName(), |
|
630 e2.getNamespaceURI()); |
|
631 return false; |
|
632 } |
|
633 } |
|
634 parent.addExtension(jaxwsBinding); |
|
635 context.pop(); |
|
636 // context.fireDoneParsingEntity( |
|
637 // JAXWSBindingsConstants.JAXWS_BINDINGS, |
|
638 // jaxwsBinding); |
|
639 return true; |
|
640 }else { |
|
641 Util.fail( |
|
642 "parsing.invalidExtensionElement", |
|
643 e.getTagName(), |
|
644 e.getNamespaceURI()); |
|
645 return false; |
|
646 } |
|
647 } |
|
648 |
|
649 private String getJavaDoc(Element e){ |
|
650 for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){ |
|
651 Element e2 = Util.nextElement(iter); |
|
652 if (e2 == null) { |
|
653 break; |
|
654 } |
|
655 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.JAVADOC)){ |
|
656 return XmlUtil.getTextForNode(e2); |
|
657 } |
|
658 } |
|
659 return null; |
|
660 } |
|
661 } |