01: package org.objectweb.celtix.tools.extensions.jaxws;
02:
03: import javax.wsdl.Definition;
04: import javax.wsdl.WSDLException;
05: import javax.wsdl.extensions.ExtensionRegistry;
06: import org.w3c.dom.Element;
07: import org.w3c.dom.Node;
08: import org.w3c.dom.NodeList;
09:
10: import org.objectweb.celtix.tools.common.ToolConstants;
11:
12: public class JAXWSBindingParser {
13:
14: public JAXWSBinding parse(BindingsNode bindingsNode, Definition def)
15: throws WSDLException {
16: return parse(bindingsNode.getParentType(), bindingsNode
17: .getElement(), def);
18: }
19:
20: public JAXWSBinding parse(Class parentType, Element element,
21: Definition def) throws WSDLException {
22: ExtensionRegistry extReg = def.getExtensionRegistry();
23: JAXWSBinding jaxwsBinding = (JAXWSBinding) extReg
24: .createExtension(parentType,
25: ToolConstants.JAXWS_BINDINGS);
26:
27: jaxwsBinding.setElementType(ToolConstants.JAXWS_BINDINGS);
28: jaxwsBinding.setElement(element);
29: jaxwsBinding.setDocumentBaseURI(def.getDocumentBaseURI());
30:
31: parseElement(jaxwsBinding, element);
32: return jaxwsBinding;
33: }
34:
35: public void parseElement(JAXWSBinding jaxwsBinding, Element element) {
36: NodeList children = element.getChildNodes();
37: if (children != null) {
38: for (int i = 0; i < children.getLength(); i++) {
39: Node child = children.item(i);
40: if (isAsyncElement(child)) {
41: jaxwsBinding.setAsyncMapping(true);
42: jaxwsBinding.setEnableAsyncMapping(isAsync(child));
43: }
44: if (isMIMEElement(child)) {
45: jaxwsBinding.setSetMimeEnable(true);
46: jaxwsBinding.setEnableMime(isMIMEEnabled(child));
47: }
48: }
49: }
50: }
51:
52: private Boolean isAsyncElement(Node node) {
53: return "enableAsyncMapping".equals(node.getNodeName());
54: }
55:
56: private Boolean isAsync(Node node) {
57: return Boolean.valueOf(node.getTextContent());
58: }
59:
60: private Boolean isMIMEElement(Node node) {
61: return "enableMIMEContent".equals(node.getNodeName());
62: }
63:
64: private Boolean isMIMEEnabled(Node node) {
65: return Boolean.valueOf(node.getTextContent());
66: }
67: }
|