1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.axis.message.addressing.tools.wsdl;
17
18 import java.io.IOException;
19 import java.io.PrintWriter;
20 import java.util.Map;
21
22 import javax.wsdl.Binding;
23 import javax.wsdl.Port;
24 import javax.wsdl.Service;
25
26 import org.apache.axis.utils.JavaUtils;
27 import org.apache.axis.utils.Messages;
28 import org.apache.axis.wsdl.symbolTable.BindingEntry;
29 import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
30 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
31 import org.apache.axis.wsdl.symbolTable.SymbolTable;
32 import org.apache.axis.wsdl.toJava.Emitter;
33 import org.apache.axis.wsdl.toJava.JavaBindingWriter;
34 import org.apache.axis.wsdl.toJava.Utils;
35
36
37
38
39
40
41
42 public class JavaAddressingServiceIfaceImplWriter extends JavaClassWithImportsWriter {
43
44
45
46
47
48
49
50
51 protected JavaAddressingServiceIfaceImplWriter(Emitter emitter, ServiceEntry sEntry,
52 SymbolTable symbolTable) {
53 super(emitter, sEntry, symbolTable, sEntry.getName() + "Addressing", "service");
54 }
55
56
57
58
59 protected String getExtendsText() {
60 return "extends " + resolve(this.sEntry.getName());
61 }
62
63
64
65
66 protected String getClassText() {
67 return "interface ";
68 }
69
70
71
72
73 protected String getImplementsText() {
74 return null;
75 }
76
77
78
79
80
81
82
83 protected void writeFileBody(PrintWriter pw) throws IOException {
84 Service service = sEntry.getService();
85
86
87 Map<?, ?> portMap = service.getPorts();
88
89
90 for (Object item : portMap.values()) {
91 Port p = (Port)item;
92 Binding binding = p.getBinding();
93
94 if (binding == null) {
95 throw new IOException(Messages.getMessage("emitFailNoBinding01", new String[] { p
96 .getName() }));
97 }
98
99 BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
100
101 if (bEntry == null) {
102 throw new IOException(Messages.getMessage("emitFailNoBindingEntry01",
103 new String[] { binding.getQName().toString() }));
104 }
105
106 PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(binding.getPortType()
107 .getQName());
108
109 if (ptEntry == null) {
110 throw new IOException(Messages.getMessage("emitFailNoPortType01",
111 new String[] { binding.getPortType().getQName().toString() }));
112 }
113
114
115 if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
116 continue;
117 }
118
119 String portName = p.getName();
120
121 if (!JavaUtils.isJavaId(portName)) {
122 portName = Utils.xmlNameToJavaClass(portName);
123 }
124
125 String bindingType = (String) bEntry
126 .getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
127
128 pw.println(" /**");
129 pw.println(" * Gets a Port instance from an end-point reference.");
130 pw.println(" *");
131 pw.println(" * @param reference EPR instance");
132 pw.println(" * @return Port instance");
133 pw.println(" * @throws ServiceException If an error occurs");
134 pw.println(" */");
135 pw.println(" " + resolve(bindingType) + " get" + portName
136 + "(EndpointReferenceType reference)");
137 pw.println(" throws ServiceException;");
138 pw.println();
139 }
140
141 pw.println();
142 }
143
144
145
146
147 @Override
148 protected void writeClassComment(PrintWriter pw) throws IOException {
149 pw.println("/**");
150 pw.println(" * Service interface with addressing support.");
151 pw.println(" */");
152 }
153
154 }