1
2
3
4
5
6
7
8
9 package it.imolinfo.jbi4corba.jbi.wsdl;
10
11 import it.imolinfo.jbi4corba.Logger;
12 import it.imolinfo.jbi4corba.LoggerFactory;
13
14 import javax.wsdl.Definition;
15 import javax.wsdl.WSDLException;
16 import javax.wsdl.extensions.ExtensibilityElement;
17 import javax.wsdl.extensions.ExtensionRegistry;
18 import javax.wsdl.extensions.ExtensionSerializer;
19 import javax.xml.namespace.QName;
20
21 import com.ibm.wsdl.util.xml.DOMUtils;
22
23
24
25
26
27
28
29 public class Jbi4CorbaBindingSerializer implements ExtensionSerializer {
30
31
32
33
34 private static final Logger LOG = LoggerFactory
35 .getLogger(Jbi4CorbaBindingSerializer.class);
36
37
38
39
40 public Jbi4CorbaBindingSerializer() {
41 }
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 @SuppressWarnings("unchecked")
69 public void marshall(Class parentType, QName elementType,
70 ExtensibilityElement extension, java.io.PrintWriter pw,
71 Definition def, ExtensionRegistry extReg) throws WSDLException {
72
73
74 String prefix = DOMUtils.getPrefix(Jbi4CorbaExtension.NS_URI_JBI4CORBA,
75 def);
76
77
78 if (prefix == null) {
79 prefix = Jbi4CorbaExtension.DEFAULT_PREFIX;
80
81 def.addNamespace(Jbi4CorbaExtension.DEFAULT_PREFIX,
82 Jbi4CorbaExtension.NS_URI_JBI4CORBA);
83 }
84
85 prefix += ":";
86
87 LOG.debug("prefix found: " + prefix);
88
89 if (extension instanceof Jbi4CorbaBinding) {
90 Jbi4CorbaBinding jbi4CorbaBinding = (Jbi4CorbaBinding) extension;
91 pw.print("<" + prefix + Jbi4CorbaExtension.BINDING_ELEMENT);
92 pw.print(">\n");
93
94
95 printIDLElement(jbi4CorbaBinding, pw, prefix);
96
97 pw
98 .print("</" + prefix + Jbi4CorbaExtension.BINDING_ELEMENT
99 + ">\n");
100
101 } else {
102 LOG.warn("CRB000300_The_extension_element_is_not_a",
103 Jbi4CorbaExtension.BINDING_ELEMENT);
104 }
105
106 }
107
108
109
110
111
112
113
114
115
116
117
118 private void printIDLElement(Jbi4CorbaBinding jbi4CorbaBinding,
119 java.io.PrintWriter pw, String prefix) {
120 for (Jbi4CorbaIDLEntry jbi4CorbaIDLEntry:jbi4CorbaBinding.getJbi4CorbaDLEntryList()) {
121 if (jbi4CorbaIDLEntry.isDefault()){
122 pw.print("<" + prefix + Jbi4CorbaExtension.IDL_ENTRY + ">");
123 } else {
124 pw.print("<" + prefix + Jbi4CorbaExtension.IDL_ENTRY + " "+Jbi4CorbaExtension.ROOT+"=\""+jbi4CorbaIDLEntry.isRoot()+"\" "+Jbi4CorbaExtension.FILENAME+"=\""+jbi4CorbaIDLEntry.getIdlFilename()+"\" "+Jbi4CorbaExtension.RELATIVE_PATH+"=\""+jbi4CorbaIDLEntry.getRelativePath()+"\">");
125 }
126 pw.print(DOMUtils.cleanString(jbi4CorbaIDLEntry.getIDL()));
127 pw.print("</" + prefix + Jbi4CorbaExtension.IDL_ENTRY + ">\n");
128 }
129 }
130
131 }