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