1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 package org.apache.geronimo.ews.ws4j2ee.context.wsdl.impl;
57
58 import org.apache.axis.wsdl.symbolTable.BindingEntry;
59 import org.apache.axis.wsdl.symbolTable.Element;
60 import org.apache.axis.wsdl.symbolTable.PortEntry;
61 import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
62 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
63 import org.apache.axis.wsdl.symbolTable.SymTabEntry;
64 import org.apache.axis.wsdl.symbolTable.SymbolTable;
65 import org.apache.axis.wsdl.symbolTable.TypeEntry;
66 import org.apache.commons.logging.Log;
67 import org.apache.commons.logging.LogFactory;
68 import org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext;
69 import org.apache.geronimo.ews.ws4j2ee.context.wsdl.type.SchemaType;
70
71 import javax.wsdl.Binding;
72 import javax.wsdl.PortType;
73 import javax.wsdl.Service;
74 import javax.xml.namespace.QName;
75 import java.util.Collection;
76 import java.util.HashMap;
77 import java.util.Iterator;
78 import java.util.Map;
79 import java.util.Vector;
80
81 /***
82 * <p>This Class is a wrapper fo the Axis SymbolTable. Since SymbolTable is parsed
83 * completly it is not editable so the methods will throw the
84 * UnsupportedOperationException.</p>
85 *
86 * @author Srinath Perera(hemapani@opensource.lk)
87 * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext
88 */
89 public class AxisWSDLContext extends AbstractWSDLContext implements WSDLContext {
90 protected static Log log =
91 LogFactory.getLog(AxisWSDLContext.class.getName());
92 private SymbolTable symbolTable;
93 private HashMap services;
94 private HashMap bindings;
95 private HashMap portetypes;
96 private HashMap ports;
97
98 private boolean verbose = false;
99
100 public AxisWSDLContext(SymbolTable axisSymbltable) {
101 this.symbolTable = axisSymbltable;
102 this.services = new HashMap();
103 this.bindings = new HashMap();
104 this.portetypes = new HashMap();
105 this.ports = new HashMap();
106 Iterator it = symbolTable.getHashMap().values().iterator();
107 while (it.hasNext()) {
108 Vector v = (Vector) it.next();
109 for (int i = 0; i < v.size(); ++i) {
110 SymTabEntry entry = (SymTabEntry) v.elementAt(i);
111 if (entry instanceof ServiceEntry) {
112 Service service = ((ServiceEntry) entry).getService();
113 this.services.put(service.getQName(), entry);
114 } else if (entry instanceof BindingEntry) {
115 Binding binding = ((BindingEntry) entry).getBinding();
116 this.bindings.put(binding.getQName(), entry);
117 } else if (entry instanceof PortTypeEntry) {
118 PortType portType = ((PortTypeEntry) entry).getPortType();
119 this.portetypes.put(portType.getQName(), entry);
120 } else if (entry instanceof PortEntry) {
121 PortEntry port = ((PortEntry) entry);
122 this.ports.put(port.getQName().getLocalPart(), entry);
123 }
124 }
125 }
126 }
127
128 /***
129 * Symbol table can't be edited
130 */
131 public void addService(Service service) {
132 throw new UnsupportedOperationException("Symboltable can't be edited");
133 }
134
135 /***
136 * Symbol table can't be edited
137 */
138 public void addType(SchemaType type) {
139 throw new UnsupportedOperationException("Symboltable can't be edited");
140 }
141
142 /***
143 *
144 */
145 public BindingEntry getBinding(QName bindingname) {
146 if (bindingname == null) {
147
148 Iterator values = this.bindings.values().iterator();
149 if (values.hasNext())
150 return (BindingEntry) values.next();
151 }
152 return (BindingEntry) this.bindings.get(bindingname);
153 }
154
155
156
157
158 public Collection getBindings() {
159 return this.bindings.values();
160 }
161
162
163
164
165 public PortTypeEntry getPortType(QName portname) {
166 return (PortTypeEntry) this.portetypes.get(portname);
167 }
168
169
170
171
172 public Collection getPortTypes() {
173 return this.portetypes.values();
174 }
175
176
177
178
179 public ServiceEntry getService(QName servicename) {
180 return (ServiceEntry) this.services.get(servicename);
181 }
182
183
184
185
186 public Collection getServices() {
187 return this.services.values();
188 }
189
190
191
192
193 public TypeEntry getType(QName typename) {
194
195 return symbolTable.getType(typename);
196 }
197
198
199
200
201 public Map getTypes() {
202 return symbolTable.getTypeIndex();
203 }
204
205
206
207
208 public Element getElement(QName name) {
209 return this.symbolTable.getElement(name);
210 }
211
212
213
214
215 public PortEntry getPort(QName name) {
216 if (verbose)
217 log.info("getting port type " + name);
218 Object obj = this.ports.get(name);
219
220
221 if (obj == null) {
222 obj = this.ports.get(name.getLocalPart());
223 }
224 return (PortEntry) obj;
225 }
226
227 public String getTargetNSURI() {
228 return symbolTable.getDefinition().getTargetNamespace();
229 }
230 }