KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > remote > soap > LZDefaultTypeMapping


1 /* *****************************************************************************
2  * LZDefaultTypeMapping.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 /*
11  * Copyright 2001-2004 The Apache Software Foundation.
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  */

25
26 package org.openlaszlo.remote.soap;
27
28 import org.apache.axis.Constants;
29 import org.apache.axis.attachments.OctetStream;
30 import org.apache.axis.encoding.TypeMapping;
31 import org.apache.axis.encoding.TypeMappingImpl;
32 import org.apache.axis.encoding.ser.ArraySerializerFactory;
33 import org.apache.axis.encoding.ser.Base64SerializerFactory;
34 import org.apache.axis.encoding.ser.BeanSerializerFactory;
35 import org.apache.axis.encoding.ser.DateSerializerFactory;
36 import org.apache.axis.encoding.ser.ElementSerializerFactory;
37 import org.apache.axis.encoding.ser.HexSerializerFactory;
38 import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
39 import org.apache.axis.encoding.ser.MapSerializerFactory;
40 import org.apache.axis.encoding.ser.QNameSerializerFactory;
41 import org.apache.axis.encoding.ser.SimpleSerializerFactory;
42 import org.apache.axis.encoding.ser.VectorSerializerFactory;
43 import org.apache.axis.encoding.ser.DocumentSerializerFactory;
44 import org.apache.axis.schema.SchemaVersion;
45 import org.apache.axis.types.HexBinary;
46 import org.apache.axis.utils.JavaUtils;
47 import org.apache.axis.utils.Messages;
48
49 import javax.xml.namespace.QName JavaDoc;
50 import javax.xml.rpc.JAXRPCException JavaDoc;
51 import javax.xml.rpc.encoding.SerializerFactory JavaDoc;
52 import javax.xml.rpc.encoding.DeserializerFactory JavaDoc;
53
54 // X import org.apache.axis.encoding.ser.SimpleDeserializerFactory;
55
// X import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
56
// import org.apache.axis.encoding.ser.Base64DeserializerFactory;
57
// import org.apache.axis.encoding.ser.BeanDeserializerFactory;
58
// import org.apache.axis.encoding.ser.DateDeserializerFactory;
59
// import org.apache.axis.encoding.ser.ElementDeserializerFactory;
60
// import org.apache.axis.encoding.ser.HexDeserializerFactory;
61
// import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
62
// import org.apache.axis.encoding.ser.MapDeserializerFactory;
63
// import org.apache.axis.encoding.ser.QNameDeserializerFactory;
64
// import org.apache.axis.encoding.ser.VectorDeserializerFactory;
65
// import org.apache.axis.encoding.ser.DocumentDeserializerFactory;
66

67 import org.openlaszlo.remote.soap.encoding.LZArraySerializerFactory;
68 import org.openlaszlo.remote.soap.encoding.LZObjectSerializerFactory;
69 import org.openlaszlo.remote.soap.encoding.SWFArrayDeserializerFactory;
70 import org.openlaszlo.remote.soap.encoding.SWFObjectDeserializer;
71 import org.openlaszlo.remote.soap.encoding.SWFSimpleDeserializer;
72 import org.openlaszlo.remote.soap.encoding.SWFSimpleDeserializerFactory;
73
74
75 public class LZDefaultTypeMapping extends TypeMappingImpl {
76
77     private static LZDefaultTypeMapping tm = null;
78     private boolean doneInit = false; // have we completed initalization
79

80     /**
81      * Obtain the singleton default typemapping.
82      */

83     public static synchronized TypeMapping getSingleton() {
84         if (tm == null) {
85             tm = new LZDefaultTypeMapping();
86         }
87         return tm;
88     }
89
90     protected LZDefaultTypeMapping() {
91         super(null);
92         delegate = null;
93
94         // Notes:
95
// 1) The registration statements are order dependent. The last one
96
// wins. So if two javaTypes of String are registered, the
97
// ser factory for the last one registered will be chosen. Likewise
98
// if two javaTypes for XSD_DATE are registered, the deserializer
99
// factory for the last one registered will be chosen.
100
// Corollary: Please be very careful with the order. The
101
// runtime, Java2WSDL and WSDL2Java emitters all
102
// use this code to get type mapping information.
103
// 2) Even if the SOAP 1.1 format is used over the wire, an
104
// attempt is made to receive SOAP 1.2 format from the wire.
105
// This is the reason why the soap encoded primitives are
106
// registered without serializers.
107

108
109         // anySimpleType is mapped to java.lang.String according to JAX-RPC 1.1 spec.
110
myRegisterSimple(Constants.XSD_ANYSIMPLETYPE, java.lang.String JavaDoc.class);
111         
112         // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
113
myRegisterSimple(Constants.XSD_STRING, java.lang.String JavaDoc.class);
114         myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean JavaDoc.class);
115         myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double JavaDoc.class);
116         myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float JavaDoc.class);
117         myRegisterSimple(Constants.XSD_INT, java.lang.Integer JavaDoc.class);
118         myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger JavaDoc.class
119         );
120         myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal JavaDoc.class
121         );
122         myRegisterSimple(Constants.XSD_LONG, java.lang.Long JavaDoc.class);
123         myRegisterSimple(Constants.XSD_SHORT, java.lang.Short JavaDoc.class);
124         myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte JavaDoc.class);
125
126         // The XSD Primitives are mapped to java primitives.
127
myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class);
128         myRegisterSimple(Constants.XSD_DOUBLE, double.class);
129         myRegisterSimple(Constants.XSD_FLOAT, float.class);
130         myRegisterSimple(Constants.XSD_INT, int.class);
131         myRegisterSimple(Constants.XSD_LONG, long.class);
132         myRegisterSimple(Constants.XSD_SHORT, short.class);
133         myRegisterSimple(Constants.XSD_BYTE, byte.class);
134
135 // // Map QNAME to the jax rpc QName class
136
// myRegister(Constants.XSD_QNAME,
137
// javax.xml.namespace.QName.class,
138
// new QNameSerializerFactory(javax.xml.namespace.QName.class,
139
// Constants.XSD_QNAME),
140
// new QNameDeserializerFactory(javax.xml.namespace.QName.class,
141
// Constants.XSD_QNAME)
142
// );
143

144 // // The closest match for anytype is Object
145
// myRegister(Constants.XSD_ANYTYPE, java.lang.Object.class,
146
// null, null);
147

148 // // See the SchemaVersion classes for where the registration of
149
// // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
150
// myRegister(Constants.XSD_DATE, java.sql.Date.class,
151
// new DateSerializerFactory(java.sql.Date.class,
152
// Constants.XSD_DATE),
153
// new DateDeserializerFactory(java.sql.Date.class,
154
// Constants.XSD_DATE)
155
// );
156

157 // // See the SchemaVersion classes for where the registration of
158
// // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
159
// myRegister(Constants.XSD_DATE, java.util.Date.class,
160
// new DateSerializerFactory(java.util.Date.class,
161
// Constants.XSD_DATE),
162
// new DateDeserializerFactory(java.util.Date.class,
163
// Constants.XSD_DATE)
164
// );
165

166 // // Mapping for xsd:time. Map to Axis type Time
167
// myRegister(Constants.XSD_TIME, org.apache.axis.types.Time.class,
168
// new SimpleSerializerFactory(org.apache.axis.types.Time.class,
169
// Constants.XSD_TIME),
170
// new SimpleDeserializerFactory(org.apache.axis.types.Time.class,
171
// Constants.XSD_TIME)
172
// );
173
// // These are the g* types (gYearMonth, etc) which map to Axis types
174
// myRegister(Constants.XSD_YEARMONTH, org.apache.axis.types.YearMonth.class,
175
// new SimpleSerializerFactory(org.apache.axis.types.YearMonth.class,
176
// Constants.XSD_YEARMONTH),
177
// new SimpleDeserializerFactory(org.apache.axis.types.YearMonth.class,
178
// Constants.XSD_YEARMONTH)
179
// );
180
// myRegister(Constants.XSD_YEAR, org.apache.axis.types.Year.class,
181
// new SimpleSerializerFactory(org.apache.axis.types.Year.class,
182
// Constants.XSD_YEAR),
183
// new SimpleDeserializerFactory(org.apache.axis.types.Year.class,
184
// Constants.XSD_YEAR)
185
// );
186
// myRegister(Constants.XSD_MONTH, org.apache.axis.types.Month.class,
187
// new SimpleSerializerFactory(org.apache.axis.types.Month.class,
188
// Constants.XSD_MONTH),
189
// new SimpleDeserializerFactory(org.apache.axis.types.Month.class,
190
// Constants.XSD_MONTH)
191
// );
192
// myRegister(Constants.XSD_DAY, org.apache.axis.types.Day.class,
193
// new SimpleSerializerFactory(org.apache.axis.types.Day.class,
194
// Constants.XSD_DAY),
195
// new SimpleDeserializerFactory(org.apache.axis.types.Day.class,
196
// Constants.XSD_DAY)
197
// );
198
// myRegister(Constants.XSD_MONTHDAY, org.apache.axis.types.MonthDay.class,
199
// new SimpleSerializerFactory(org.apache.axis.types.MonthDay.class,
200
// Constants.XSD_MONTHDAY),
201
// new SimpleDeserializerFactory(org.apache.axis.types.MonthDay.class,
202
// Constants.XSD_MONTHDAY)
203
// );
204

205 // // Serialize all extensions of Map to SOAP_MAP
206
// // The SOAP_MAP will be deserialized into a HashMap by default.
207
// myRegister(Constants.SOAP_MAP, java.util.HashMap.class,
208
// new MapSerializerFactory(java.util.Map.class,
209
// Constants.SOAP_MAP),
210
// new MapDeserializerFactory(java.util.HashMap.class,
211
// Constants.SOAP_MAP)
212
// );
213
// myRegister(Constants.SOAP_MAP, java.util.Hashtable.class,
214
// new MapSerializerFactory(java.util.Hashtable.class,
215
// Constants.SOAP_MAP),
216
// null // Make sure not to override the deser mapping
217
// );
218
// myRegister(Constants.SOAP_MAP, java.util.Map.class,
219
// new MapSerializerFactory(java.util.Map.class,
220
// Constants.SOAP_MAP),
221
// null // Make sure not to override the deser mapping
222
// );
223

224 // // Use the Element Serializeration for elements
225
// myRegister(Constants.SOAP_ELEMENT, org.w3c.dom.Element.class,
226
// new ElementSerializerFactory(),
227
// new ElementDeserializerFactory());
228

229 // // Use the Document Serializeration for Document's
230
// myRegister(Constants.SOAP_DOCUMENT, org.w3c.dom.Document.class,
231
// new DocumentSerializerFactory(),
232
// new DocumentDeserializerFactory());
233

234 // myRegister(Constants.SOAP_VECTOR, java.util.Vector.class,
235
// new VectorSerializerFactory(java.util.Vector.class,
236
// Constants.SOAP_VECTOR),
237
// new VectorDeserializerFactory(java.util.Vector.class,
238
// Constants.SOAP_VECTOR)
239
// );
240

241 // // xsd:token
242
// myRegister(Constants.XSD_TOKEN, org.apache.axis.types.Token.class,
243
// new SimpleSerializerFactory(org.apache.axis.types.Token.class,
244
// Constants.XSD_TOKEN),
245
// new SimpleDeserializerFactory(org.apache.axis.types.Token.class,
246
// Constants.XSD_TOKEN)
247
// );
248

249 // // a xsd:normalizedString
250
// myRegister(Constants.XSD_NORMALIZEDSTRING, org.apache.axis.types.NormalizedString.class,
251
// new SimpleSerializerFactory(org.apache.axis.types.NormalizedString.class,
252
// Constants.XSD_NORMALIZEDSTRING),
253
// new SimpleDeserializerFactory(org.apache.axis.types.NormalizedString.class,
254
// Constants.XSD_NORMALIZEDSTRING)
255
// );
256

257 // // a xsd:unsignedLong
258
// myRegister(Constants.XSD_UNSIGNEDLONG, org.apache.axis.types.UnsignedLong.class,
259
// new SimpleSerializerFactory(org.apache.axis.types.UnsignedLong.class,
260
// Constants.XSD_UNSIGNEDLONG),
261
// new SimpleDeserializerFactory(org.apache.axis.types.UnsignedLong.class,
262
// Constants.XSD_UNSIGNEDLONG)
263
// );
264

265 // // a xsd:unsignedInt
266
// myRegister(Constants.XSD_UNSIGNEDINT, org.apache.axis.types.UnsignedInt.class,
267
// new SimpleSerializerFactory(org.apache.axis.types.UnsignedInt.class,
268
// Constants.XSD_UNSIGNEDINT),
269
// new SimpleDeserializerFactory(org.apache.axis.types.UnsignedInt.class,
270
// Constants.XSD_UNSIGNEDINT)
271
// );
272

273 // // a xsd:unsignedShort
274
// myRegister(Constants.XSD_UNSIGNEDSHORT, org.apache.axis.types.UnsignedShort.class,
275
// new SimpleSerializerFactory(org.apache.axis.types.UnsignedShort.class,
276
// Constants.XSD_UNSIGNEDSHORT),
277
// new SimpleDeserializerFactory(org.apache.axis.types.UnsignedShort.class,
278
// Constants.XSD_UNSIGNEDSHORT)
279
// );
280

281 // // a xsd:unsignedByte
282
// myRegister(Constants.XSD_UNSIGNEDBYTE, org.apache.axis.types.UnsignedByte.class,
283
// new SimpleSerializerFactory(org.apache.axis.types.UnsignedByte.class,
284
// Constants.XSD_UNSIGNEDBYTE),
285
// new SimpleDeserializerFactory(org.apache.axis.types.UnsignedByte.class,
286
// Constants.XSD_UNSIGNEDBYTE)
287
// );
288

289 // // a xsd:nonNegativeInteger
290
// myRegister(Constants.XSD_NONNEGATIVEINTEGER, org.apache.axis.types.NonNegativeInteger.class,
291
// new SimpleSerializerFactory(org.apache.axis.types.NonNegativeInteger.class,
292
// Constants.XSD_NONNEGATIVEINTEGER),
293
// new SimpleDeserializerFactory(org.apache.axis.types.NonNegativeInteger.class,
294
// Constants.XSD_NONNEGATIVEINTEGER)
295
// );
296

297 // // a xsd:negativeInteger
298
// myRegister(Constants.XSD_NEGATIVEINTEGER, org.apache.axis.types.NegativeInteger.class,
299
// new SimpleSerializerFactory(org.apache.axis.types.NegativeInteger.class,
300
// Constants.XSD_NEGATIVEINTEGER),
301
// new SimpleDeserializerFactory(org.apache.axis.types.NegativeInteger.class,
302
// Constants.XSD_NEGATIVEINTEGER)
303
// );
304

305 // // a xsd:positiveInteger
306
// myRegister(Constants.XSD_POSITIVEINTEGER, org.apache.axis.types.PositiveInteger.class,
307
// new SimpleSerializerFactory(org.apache.axis.types.PositiveInteger.class,
308
// Constants.XSD_POSITIVEINTEGER),
309
// new SimpleDeserializerFactory(org.apache.axis.types.PositiveInteger.class,
310
// Constants.XSD_POSITIVEINTEGER)
311
// );
312

313 // // a xsd:nonPositiveInteger
314
// myRegister(Constants.XSD_NONPOSITIVEINTEGER, org.apache.axis.types.NonPositiveInteger.class,
315
// new SimpleSerializerFactory(org.apache.axis.types.NonPositiveInteger.class,
316
// Constants.XSD_NONPOSITIVEINTEGER),
317
// new SimpleDeserializerFactory(org.apache.axis.types.NonPositiveInteger.class,
318
// Constants.XSD_NONPOSITIVEINTEGER)
319
// );
320

321 // // a xsd:Name
322
// myRegister(Constants.XSD_NAME, org.apache.axis.types.Name.class,
323
// new SimpleSerializerFactory(org.apache.axis.types.Name.class,
324
// Constants.XSD_NAME),
325
// new SimpleDeserializerFactory(org.apache.axis.types.Name.class,
326
// Constants.XSD_NAME)
327
// );
328

329 // // a xsd:NCName
330
// myRegister(Constants.XSD_NCNAME, org.apache.axis.types.NCName.class,
331
// new SimpleSerializerFactory(org.apache.axis.types.NCName.class,
332
// Constants.XSD_NCNAME),
333
// new SimpleDeserializerFactory(org.apache.axis.types.NCName.class,
334
// Constants.XSD_NCNAME)
335
// );
336

337 // // a xsd:ID
338
// myRegister(Constants.XSD_ID, org.apache.axis.types.Id.class,
339
// new SimpleSerializerFactory(org.apache.axis.types.Id.class,
340
// Constants.XSD_ID),
341
// new SimpleDeserializerFactory(org.apache.axis.types.Id.class,
342
// Constants.XSD_ID)
343
// );
344

345 // // a xsd:language
346
// myRegister(Constants.XSD_LANGUAGE, org.apache.axis.types.Language.class,
347
// new SimpleSerializerFactory(org.apache.axis.types.Language.class,
348
// Constants.XSD_LANGUAGE),
349
// new SimpleDeserializerFactory(org.apache.axis.types.Language.class,
350
// Constants.XSD_LANGUAGE)
351
// );
352

353 // // a xml:lang
354
// myRegister(Constants.XML_LANG, org.apache.axis.types.Language.class,
355
// new SimpleSerializerFactory(org.apache.axis.types.Language.class,
356
// Constants.XML_LANG),
357
// new SimpleDeserializerFactory(org.apache.axis.types.Language.class,
358
// Constants.XML_LANG)
359
// );
360

361 // // a xsd:NmToken
362
// myRegister(Constants.XSD_NMTOKEN, org.apache.axis.types.NMToken.class,
363
// new SimpleSerializerFactory(org.apache.axis.types.NMToken.class,
364
// Constants.XSD_NMTOKEN),
365
// new SimpleDeserializerFactory(org.apache.axis.types.NMToken.class,
366
// Constants.XSD_NMTOKEN)
367
// );
368

369 // // a xsd:NmTokens
370
// myRegister(Constants.XSD_NMTOKENS, org.apache.axis.types.NMTokens.class,
371
// new SimpleSerializerFactory(org.apache.axis.types.NMTokens.class,
372
// Constants.XSD_NMTOKENS),
373
// new SimpleDeserializerFactory(org.apache.axis.types.NMTokens.class,
374
// Constants.XSD_NMTOKENS)
375
// );
376

377 // // a xsd:NOTATION
378
// myRegister(Constants.XSD_NOTATION, org.apache.axis.types.Notation.class,
379
// new BeanSerializerFactory(org.apache.axis.types.Notation.class,
380
// Constants.XSD_NOTATION),
381
// new BeanDeserializerFactory(org.apache.axis.types.Notation.class,
382
// Constants.XSD_NOTATION)
383
// );
384

385 // // a xsd:XSD_ENTITY
386
// myRegister(Constants.XSD_ENTITY, org.apache.axis.types.Entity.class,
387
// new SimpleSerializerFactory(org.apache.axis.types.Entity.class,
388
// Constants.XSD_ENTITY),
389
// new SimpleDeserializerFactory(org.apache.axis.types.Entity.class,
390
// Constants.XSD_ENTITY)
391
// );
392

393 // // a xsd:XSD_ENTITIES
394
// myRegister(Constants.XSD_ENTITIES, org.apache.axis.types.Entities.class,
395
// new SimpleSerializerFactory(org.apache.axis.types.Entities.class,
396
// Constants.XSD_ENTITIES),
397
// new SimpleDeserializerFactory(org.apache.axis.types.Entities.class,
398
// Constants.XSD_ENTITIES)
399
// );
400

401 // // a xsd:XSD_IDREF
402
// myRegister(Constants.XSD_IDREF, org.apache.axis.types.IDRef.class,
403
// new SimpleSerializerFactory(org.apache.axis.types.IDRef.class,
404
// Constants.XSD_IDREF),
405
// new SimpleDeserializerFactory(org.apache.axis.types.IDRef.class,
406
// Constants.XSD_IDREF)
407
// );
408

409 // // a xsd:XSD_XSD_IDREFS
410
// myRegister(Constants.XSD_IDREFS, org.apache.axis.types.IDRefs.class,
411
// new SimpleSerializerFactory(org.apache.axis.types.IDRefs.class,
412
// Constants.XSD_IDREFS),
413
// new SimpleDeserializerFactory(org.apache.axis.types.IDRefs.class,
414
// Constants.XSD_IDREFS)
415
// );
416

417 // // a xsd:Duration
418
// myRegister(Constants.XSD_DURATION, org.apache.axis.types.Duration.class,
419
// new SimpleSerializerFactory(org.apache.axis.types.Duration.class,
420
// Constants.XSD_DURATION),
421
// new SimpleDeserializerFactory(org.apache.axis.types.Duration.class,
422
// Constants.XSD_DURATION)
423
// );
424

425 // // a xsd:anyURI
426
// myRegister(Constants.XSD_ANYURI, org.apache.axis.types.URI.class,
427
// new SimpleSerializerFactory(org.apache.axis.types.URI.class,
428
// Constants.XSD_ANYURI),
429
// new SimpleDeserializerFactory(org.apache.axis.types.URI.class,
430
// Constants.XSD_ANYURI)
431
// );
432

433 // // a xsd:schema
434
// myRegister(Constants.XSD_SCHEMA, org.apache.axis.types.Schema.class,
435
// new BeanSerializerFactory(org.apache.axis.types.Schema.class,
436
// Constants.XSD_SCHEMA),
437
// new BeanDeserializerFactory(org.apache.axis.types.Schema.class,
438
// Constants.XSD_SCHEMA)
439
// );
440

441         // TODO: move it to the DefaultSOAPEncodingTypeMappingImpl class
442
myRegister(Constants.SOAP_ARRAY12, java.util.Collection JavaDoc.class,
443                    new LZArraySerializerFactory(),
444                    new SWFArrayDeserializerFactory()
445         );
446         // TODO: move it to the DefaultSOAPEncodingTypeMappingImpl class
447
myRegister(Constants.SOAP_ARRAY12, java.util.ArrayList JavaDoc.class,
448                    new LZArraySerializerFactory(),
449                    new SWFArrayDeserializerFactory()
450         );
451
452         myRegister(Constants.SOAP_ARRAY12, Object JavaDoc[].class,
453                    new LZArraySerializerFactory(),
454                    new SWFArrayDeserializerFactory()
455         );
456
457         myRegister(Constants.SOAP_ARRAY, java.util.ArrayList JavaDoc.class,
458                    new LZArraySerializerFactory(),
459                    new SWFArrayDeserializerFactory()
460         );
461         
462         // All array objects automatically get associated with the SOAP_ARRAY.
463
// There is no way to do this with a hash table,
464
// so it is done directly in getArrayItemTypeQName.
465
// Internally the runtime uses ArrayList objects to hold arrays...
466
// which is the reason that ArrayList is associated with SOAP_ARRAY.
467
// In addition, handle all objects that implement the List interface
468
// as a SOAP_ARRAY
469
myRegister(Constants.SOAP_ARRAY, java.util.Collection JavaDoc.class,
470                    new LZArraySerializerFactory(),
471                    new SWFArrayDeserializerFactory()
472         );
473
474         myRegister(Constants.SOAP_ARRAY, Object JavaDoc[].class,
475                    new LZArraySerializerFactory(),
476                    new SWFArrayDeserializerFactory()
477         );
478
479         //
480
// Now register the schema specific types
481
//
482
SchemaVersion.SCHEMA_1999.registerSchemaSpecificTypes(this);
483         SchemaVersion.SCHEMA_2000.registerSchemaSpecificTypes(this);
484         SchemaVersion.SCHEMA_2001.registerSchemaSpecificTypes(this);
485
486         SerializerFactory sf = new SimpleSerializerFactory(java.util.Date JavaDoc.class, Constants.XSD_DATETIME);
487         DeserializerFactory JavaDoc df = new SWFSimpleDeserializerFactory(java.util.Date JavaDoc.class, Constants.XSD_DATETIME);
488         myRegister(Constants.XSD_DATETIME, java.util.Date JavaDoc.class, sf, df);
489         
490         doneInit = true;
491     }
492
493     protected void myRegisterSimple(QName JavaDoc xmlType, Class JavaDoc javaType) {
494         SerializerFactory sf = new SimpleSerializerFactory(javaType, xmlType);
495         DeserializerFactory JavaDoc df = null;
496         if (javaType != java.lang.Object JavaDoc.class) {
497             df = new SWFSimpleDeserializerFactory(javaType, xmlType);
498         }
499         myRegister(xmlType, javaType, sf, df);
500     }
501
502     /**
503      * Construct TypeMapping for all the [xmlType, javaType] for all of the
504      * known xmlType namespaces. This is the shotgun approach, which works
505      * in 99% of the cases. The other cases that are Schema version specific
506      * (i.e. timeInstant vs. dateTime) are handled by the SchemaVersion
507      * Interface registerSchemaSpecificTypes().
508      *
509      * @param xmlType is the QName type
510      * @param javaType is the java type
511      * @param sf is the ser factory (if null, the simple factory is used)
512      * @param df is the deser factory (if null, the simple factory is used)
513      */

514     protected void myRegister(QName JavaDoc xmlType, Class JavaDoc javaType,
515                               SerializerFactory sf, DeserializerFactory JavaDoc df) {
516         // Register all known flavors of the namespace.
517
try {
518             if (xmlType.getNamespaceURI().equals(
519                     Constants.URI_DEFAULT_SCHEMA_XSD)) {
520                 for (int i=0; i < Constants.URIS_SCHEMA_XSD.length; i++) {
521                     QName JavaDoc qName = new QName JavaDoc(Constants.URIS_SCHEMA_XSD[i],
522                                             xmlType.getLocalPart());
523                     super.internalRegister(javaType, qName, sf, df);
524                 }
525             }
526             else if (xmlType.getNamespaceURI().equals(
527                     Constants.URI_DEFAULT_SOAP_ENC)) {
528                 for (int i=0; i < Constants.URIS_SOAP_ENC.length; i++) {
529                     QName JavaDoc qName = new QName JavaDoc(Constants.URIS_SOAP_ENC[i],
530                                             xmlType.getLocalPart());
531                     super.internalRegister(javaType, qName, sf, df);
532                 }
533             } else {
534                 // Register with the specified xmlType.
535
// This is the prefered mapping and the last registed one wins
536
super.internalRegister(javaType, xmlType, sf, df);
537             }
538         } catch (JAXRPCException JavaDoc e) { }
539     }
540
541     // Don't allow anyone to muck with the default type mapping because
542
// it is a singleton used for the whole system.
543
public void register(Class JavaDoc javaType, QName JavaDoc xmlType,
544                          javax.xml.rpc.encoding.SerializerFactory JavaDoc sf,
545                          javax.xml.rpc.encoding.DeserializerFactory JavaDoc dsf)
546         throws JAXRPCException JavaDoc {
547         // Don't allow anyone but init to modify us.
548
super.register(javaType, xmlType, sf, dsf);
549     }
550
551     public void removeSerializer(Class JavaDoc javaType, QName JavaDoc xmlType)
552         throws JAXRPCException JavaDoc {
553         throw new JAXRPCException JavaDoc(Messages.getMessage("fixedTypeMapping"));
554     }
555     public void removeDeserializer(Class JavaDoc javaType, QName JavaDoc xmlType)
556         throws JAXRPCException JavaDoc {
557         throw new JAXRPCException JavaDoc(Messages.getMessage("fixedTypeMapping"));
558     }
559     public void setSupportedEncodings(String JavaDoc[] namespaceURIs) {
560     }
561 }
562
Popular Tags