1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.jbi.wsdl;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12
13 import java.util.Enumeration;
14 import java.util.Properties;
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
32 public class Jbi4EjbTypesSerializer implements ExtensionSerializer {
33
34
35
36
37 private static final Logger LOG
38 = LoggerFactory.getLogger(Jbi4EjbTypesSerializer.class);
39
40
41
42
43 public Jbi4EjbTypesSerializer() {}
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 public void marshall(Class parentType, QName elementType,
66 ExtensibilityElement extension, java.io.PrintWriter pw, Definition def, ExtensionRegistry extReg)
67 throws WSDLException {
68
69
70 String prefix = DOMUtils.getPrefix(Jbi4EjbExtension.NS_URI_JBI4EJB, def);
71
72
73 if (prefix == null) {
74 prefix = Jbi4EjbExtension.DEFAULT_PREFIX;
75
76 def.addNamespace(Jbi4EjbExtension.DEFAULT_PREFIX, Jbi4EjbExtension.NS_URI_JBI4EJB);
77 }
78
79 prefix += ":";
80
81 LOG.debug("prefix found: " + prefix);
82
83 if (extension instanceof Jbi4EjbTypes) {
84 Jbi4EjbTypes jbi4EjbTypes = (Jbi4EjbTypes) extension;
85 pw.print("<" + prefix + Jbi4EjbExtension.TYPES_ELEMENT);
86 pw.print(">\n");
87
88
89 printTypesElement(jbi4EjbTypes, pw, prefix);
90
91 pw.print("</" + prefix + Jbi4EjbExtension.TYPES_ELEMENT+">\n");
92
93 } else {
94 LOG.warn("EJB000401_Error_in_extension_element", new Object[]{Jbi4EjbExtension.TYPES_ELEMENT});
95 }
96
97 }
98
99
100
101
102
103
104
105
106 private void printTypesElement(Jbi4EjbTypes jbi4EjbBiTypes, java.io.PrintWriter pw, String prefix) {
107 if ((jbi4EjbBiTypes.getTypesSerialVersionUIDs() != null) &&
108 (!jbi4EjbBiTypes.getTypesSerialVersionUIDs().isEmpty())) {
109 Properties typesProperties = jbi4EjbBiTypes.getTypesSerialVersionUIDs();
110 Enumeration enKeys = typesProperties.keys();
111 for (; enKeys.hasMoreElements() ;) {
112 String key = (String)enKeys.nextElement();
113 Object suid = typesProperties.get(key);
114 String prop = null;
115 if (suid instanceof Long) {
116 prop = ((Long)suid).toString();
117 } else {
118 prop = (String)suid;
119 }
120 pw.print("<" + prefix + Jbi4EjbExtension.SERIAL_VERSION_UID_ELEMENT);
121 DOMUtils.printAttribute(Jbi4EjbExtension.CLASSNAME_ATTRIBUTE, key, pw);
122 DOMUtils.printAttribute(Jbi4EjbExtension.UID_ATTRIBUTE, prop, pw);
123 pw.print("/>\n");
124 }
125 }
126 }
127 }