1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.geronimo.ews.ws4j2ee.context.impl;
18
19 import org.apache.axis.wsdl.symbolTable.BindingEntry;
20 import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
21 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
22 import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
23 import org.apache.geronimo.ews.jaxrpcmapping.JaxRpcMapper;
24 import org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext;
25 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
26 import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
27 import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
28
29 import javax.wsdl.Operation;
30 import javax.wsdl.Part;
31 import javax.wsdl.Port;
32 import javax.xml.namespace.QName;
33 import java.io.InputStream;
34 import java.io.Writer;
35 import java.util.Iterator;
36 import java.util.Map;
37
38 /***
39 * This class wrap the JAXRPCMapper and only expose a interface to
40 * the rest of the WS4j2ee.
41 *
42 * @author Srinath Perera(hemapani@opensource.lk)
43 * @see org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext
44 */
45 public class JaxRpcMapperImpl implements JaxRpcMapperContext {
46 private JaxRpcMapper jaxrpcmapper;
47 private J2eeEmitter j2ee;
48
49 public JaxRpcMapperImpl(JaxRpcMapper jaxrpcmapper, J2eeEmitter j2ee) {
50 this.jaxrpcmapper = jaxrpcmapper;
51 this.j2ee = j2ee;
52 }
53
54 /***
55 * @param messageQName
56 * @return
57 */
58 public String getExceptionType(QName messageQName) {
59 String exceptionName = jaxrpcmapper.getExceptionType(messageQName);
60 if (exceptionName == null) {
61 exceptionName = j2ee.getJavaName(messageQName);
62 if (exceptionName == null)
63 throw new UnrecoverableGenerationFault("the exception name in a SEI OP can not be null" +
64 "possibly be a bug check the WSDL2Java data extraction");
65 }
66 return exceptionName;
67 }
68
69 /***
70 * @param bEntry
71 * @param operation
72 * @return
73 */
74 public String getJavaMethodName(BindingEntry bEntry, Operation operation) {
75 String opName = jaxrpcmapper.getJavaMethodName(bEntry, operation);
76 if (opName == null)
77 opName = operation.getName();
78 if (opName == null)
79 throw new UnrecoverableGenerationFault("the method name in a SEI OP can not be null" +
80 "possibly be a bug check the WSDL2Java data extraction");
81 return Utils.firstCharacterToLowerCase(opName);
82 }
83
84 /***
85 * @param bEntry
86 * @param operation
87 * @param position
88 * @return
89 */
90 public String getJavaMethodParamType(BindingEntry bEntry,
91 Operation operation,
92 int position, QName parmType) {
93 String type = jaxrpcmapper.getJavaMethodParamType(bEntry, operation, position);
94 if (type == null) {
95 type = j2ee.getJavaName(parmType);
96 if (type == null)
97 throw new UnrecoverableGenerationFault("the parm type name in a SEI OP can not be null" +
98 "possibly be a bug check the WSDL2Java data extraction");
99 }
100 return type;
101 }
102
103 /***
104 * @param bEntry
105 * @param operation
106 * @return
107 */
108 public String getJavaMethodReturnType(BindingEntry bEntry,
109 Operation operation) {
110 String returnType = jaxrpcmapper.getJavaMethodReturnType(bEntry, operation);
111 if (returnType == null) {
112 Map parts = operation.getOutput().getMessage().getParts();
113 if (parts != null) {
114 Iterator returnlist = parts.values().iterator();
115 if (returnlist.hasNext()) {
116 Part part = (Part) returnlist.next();
117 returnType = jaxrpcmapper.getJavaType(part.getTypeName());
118 if (returnType == null)
119 returnType = j2ee.getJavaName(part.getTypeName());
120 }
121 }
122 }
123 return returnType;
124
125
126 }
127
128 /***
129 * @param typeQName
130 * @return
131 */
132 public String getJavaType(QName typeQName) {
133 String type = jaxrpcmapper.getJavaType(typeQName);
134 if (type == null)
135 type = j2ee.getJavaName(typeQName);
136 if (type == null)
137 throw new UnrecoverableGenerationFault("the type name can" +
138 " not be null possibly be a bug check the WSDL2Java data extraction");
139 return type;
140 }
141
142 /***
143 * @param port
144 * @return
145 */
146 public String getPortName(Port port) {
147 String portName = jaxrpcmapper.getPortName(port);
148 if (portName == null) {
149 portName = port.getName();
150 if (portName == null)
151 throw new UnrecoverableGenerationFault("the portName can" +
152 " not be null, possibly be a bug check the WSDL2Java data extraction");
153 }
154 return portName;
155 }
156
157 /***
158 * @param ptEntry
159 * @param bEntry
160 * @return
161 */
162 public String getServiceEndpointInterfaceName(PortTypeEntry ptEntry,
163 BindingEntry bEntry) {
164 String seiName = jaxrpcmapper.getServiceEndpointInterfaceName(ptEntry, bEntry);
165 if (seiName == null) {
166 seiName = ptEntry.getName();
167 if (seiName == null)
168 throw new UnrecoverableGenerationFault("the seiName can" +
169 " not be null, possibly be a bug check the WSDL2Java data extraction");
170 }
171 return seiName;
172 }
173
174 /***
175 * @param entry
176 * @return
177 */
178 public String getServiceInterfaceName(ServiceEntry entry) {
179 String serviceInterface = jaxrpcmapper.getServiceInterfaceName(entry);
180 if (serviceInterface == null) {
181 serviceInterface = entry.getName();
182 if (serviceInterface == null)
183 throw new UnrecoverableGenerationFault("the serviceInterface can" +
184 " not be null, possibly be a bug check the WSDL2Java data extraction");
185 }
186 return serviceInterface;
187 }
188
189 /***
190 * @param path
191 */
192 public void loadMappingFromDir(String path) throws GenerationFault {
193 jaxrpcmapper.loadMappingFromDir(path);
194 }
195
196 /***
197 * @param is
198 */
199 public void loadMappingFromInputStream(InputStream is) throws GenerationFault {
200 jaxrpcmapper.loadMappingFromInputStream(is);
201 }
202
203
204
205
206 public void serialize(Writer out) {
207 throw new UnsupportedOperationException("when the wsdl is avalibe serialization not reqired");
208 }
209
210
211
212
213 public String getPackageMappingClassName(int index) {
214 return jaxrpcmapper.getPackageMappingClassName(index);
215 }
216
217 public int getPackageMappingCount() {
218 return jaxrpcmapper.getPackageMappingCount();
219 }
220
221 public String getPackageMappingURI(int index) {
222 return jaxrpcmapper.getPackageMappingURI(index);
223 }
224
225 }