1
2
3
4
5
6
7
8
9
10 package it.imolinfo.jbi4corba.utils.plugin.wsdl;
11
12 import com.ibm.wsdl.util.xml.DOMUtils;
13 import java.io.PrintWriter;
14 import java.util.logging.Logger;
15 import javax.wsdl.Definition;
16 import javax.wsdl.WSDLException;
17 import javax.wsdl.extensions.ExtensibilityElement;
18 import javax.wsdl.extensions.ExtensionRegistry;
19 import javax.wsdl.extensions.ExtensionSerializer;
20 import javax.xml.namespace.QName;
21
22
23
24
25
26
27 public class Jbi4CorbaPartnerLinkSerializer implements ExtensionSerializer {
28
29 private Logger log = Logger.getLogger(this.getClass().getName());
30
31 public void marshall(
32 Class parentType,
33 QName elementType,
34 ExtensibilityElement extension,
35 PrintWriter pw,
36 Definition definition,
37 ExtensionRegistry registry)
38 throws WSDLException
39 {
40 String prefix = null;
41 Jbi4CorbaPartnerLink ptnlnk = null;
42
43
44 if (extension instanceof Jbi4CorbaPartnerLink) {
45 ptnlnk = (Jbi4CorbaPartnerLink)extension;
46 prefix = ptnlnk.getPrefix();
47
48 log.fine("Used prefix: "+prefix);
49
50
51 pw.print("<" + prefix +":"+ Jbi4CorbaPartnerLinkExtension.PRTLNK_ELEMENT);
52 DOMUtils.printAttribute(
53 Jbi4CorbaPartnerLinkExtension.PRTLNK_NAME_ATTRIBUTE,
54 ptnlnk.getName(),
55 pw);
56 pw.println(">");
57
58 Role role = null;
59 for (int i = 0; i < ptnlnk.getRolesNumber(); i++) {
60 role = ptnlnk.getRole(0);
61 printRoleElement(prefix, role, pw);
62 }
63
64 pw.println("</" + prefix +":"+ Jbi4CorbaPartnerLinkExtension.PRTLNK_ELEMENT+">");
65 }
66 }
67
68
69
70
71 private void printRoleElement(String prefix, Role role, PrintWriter pw)
72 {
73 pw.print("<"+prefix+":");
74 pw.print(Jbi4CorbaPartnerLinkExtension.ROLE_ELEMENT);
75 DOMUtils.printAttribute(
76 Jbi4CorbaPartnerLinkExtension.ROLE_ATTRIBUTE_NAME,
77 role.getName(),
78 pw);
79
80 DOMUtils.printAttribute(
81 Jbi4CorbaPartnerLinkExtension.ROLE_ATTRIBUTE_PORT,
82 role.getPortType(),
83 pw);
84
85 pw.println("/>");
86 }
87
88 }