1 16 17 package org.apache.axis.encoding; 18 19 import org.apache.axis.Constants; 20 import org.apache.axis.attachments.OctetStream; 21 import org.apache.axis.encoding.ser.ArrayDeserializerFactory; 22 import org.apache.axis.encoding.ser.ArraySerializerFactory; 23 import org.apache.axis.encoding.ser.Base64DeserializerFactory; 24 import org.apache.axis.encoding.ser.Base64SerializerFactory; 25 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 26 import org.apache.axis.encoding.ser.BeanSerializerFactory; 27 import org.apache.axis.encoding.ser.DateDeserializerFactory; 28 import org.apache.axis.encoding.ser.DateSerializerFactory; 29 import org.apache.axis.encoding.ser.DocumentDeserializerFactory; 30 import org.apache.axis.encoding.ser.DocumentSerializerFactory; 31 import org.apache.axis.encoding.ser.ElementDeserializerFactory; 32 import org.apache.axis.encoding.ser.ElementSerializerFactory; 33 import org.apache.axis.encoding.ser.HexDeserializerFactory; 34 import org.apache.axis.encoding.ser.HexSerializerFactory; 35 import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory; 36 import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; 37 import org.apache.axis.encoding.ser.MapDeserializerFactory; 38 import org.apache.axis.encoding.ser.MapSerializerFactory; 39 import org.apache.axis.encoding.ser.QNameDeserializerFactory; 40 import org.apache.axis.encoding.ser.QNameSerializerFactory; 41 import org.apache.axis.encoding.ser.SimpleDeserializerFactory; 42 import org.apache.axis.encoding.ser.SimpleSerializerFactory; 43 import org.apache.axis.encoding.ser.VectorDeserializerFactory; 44 import org.apache.axis.encoding.ser.VectorSerializerFactory; 45 import org.apache.axis.schema.SchemaVersion; 46 import org.apache.axis.types.HexBinary; 47 import org.apache.axis.utils.JavaUtils; 48 import org.apache.axis.utils.Messages; 49 50 import javax.xml.namespace.QName ; 51 import javax.xml.rpc.JAXRPCException ; 52 import javax.xml.rpc.encoding.DeserializerFactory ; 53 54 75 public class DefaultTypeMappingImpl extends TypeMappingImpl { 76 77 private static DefaultTypeMappingImpl tm = null; 78 private boolean inInitMappings = false; 79 80 83 public static synchronized TypeMappingDelegate getSingletonDelegate() { 84 if (tm == null) { 85 tm = new DefaultTypeMappingImpl(); 86 } 87 return new TypeMappingDelegate(tm); 88 } 89 90 protected DefaultTypeMappingImpl() { 91 initMappings(); 92 } 93 94 protected DefaultTypeMappingImpl(boolean noMappings) { 95 if (!noMappings) { 96 initMappings(); 97 } 98 } 99 100 protected void initMappings() { 101 inInitMappings = true; 102 103 117 if (JavaUtils.isAttachmentSupported()) { 120 myRegister(Constants.MIME_PLAINTEXT, java.lang.String .class, 121 new JAFDataHandlerSerializerFactory( 122 java.lang.String .class, 123 Constants.MIME_PLAINTEXT), 124 new JAFDataHandlerDeserializerFactory( 125 java.lang.String .class, 126 Constants.MIME_PLAINTEXT)); 127 } 128 129 myRegister(Constants.XSD_HEXBIN, HexBinary.class, 131 new HexSerializerFactory( 132 HexBinary.class, Constants.XSD_HEXBIN), 133 new HexDeserializerFactory( 134 HexBinary.class, Constants.XSD_HEXBIN)); 135 myRegister(Constants.XSD_HEXBIN, byte[].class, 136 new HexSerializerFactory( 137 byte[].class, Constants.XSD_HEXBIN), 138 new HexDeserializerFactory( 139 byte[].class, Constants.XSD_HEXBIN)); 140 141 myRegister(Constants.XSD_BYTE, byte[].class, 155 new ArraySerializerFactory(), 156 null 157 ); 158 159 myRegister(Constants.XSD_BASE64, byte[].class, 160 new Base64SerializerFactory(byte[].class, 161 Constants.XSD_BASE64 ), 162 new Base64DeserializerFactory(byte[].class, 163 Constants.XSD_BASE64)); 164 165 myRegisterSimple(Constants.XSD_ANYSIMPLETYPE, java.lang.String .class); 167 168 myRegisterSimple(Constants.XSD_STRING, java.lang.String .class); 170 myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean .class); 171 myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double .class); 172 myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float .class); 173 myRegisterSimple(Constants.XSD_INT, java.lang.Integer .class); 174 myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger .class 175 ); 176 myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal .class 177 ); 178 myRegisterSimple(Constants.XSD_LONG, java.lang.Long .class); 179 myRegisterSimple(Constants.XSD_SHORT, java.lang.Short .class); 180 myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte .class); 181 182 myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class); 184 myRegisterSimple(Constants.XSD_DOUBLE, double.class); 185 myRegisterSimple(Constants.XSD_FLOAT, float.class); 186 myRegisterSimple(Constants.XSD_INT, int.class); 187 myRegisterSimple(Constants.XSD_LONG, long.class); 188 myRegisterSimple(Constants.XSD_SHORT, short.class); 189 myRegisterSimple(Constants.XSD_BYTE, byte.class); 190 191 myRegister(Constants.XSD_QNAME, 193 javax.xml.namespace.QName .class, 194 new QNameSerializerFactory(javax.xml.namespace.QName .class, 195 Constants.XSD_QNAME), 196 new QNameDeserializerFactory(javax.xml.namespace.QName .class, 197 Constants.XSD_QNAME) 198 ); 199 200 myRegister(Constants.XSD_ANYTYPE, java.lang.Object .class, 202 null, null); 203 204 myRegister(Constants.XSD_DATE, java.sql.Date .class, 207 new DateSerializerFactory(java.sql.Date .class, 208 Constants.XSD_DATE), 209 new DateDeserializerFactory(java.sql.Date .class, 210 Constants.XSD_DATE) 211 ); 212 213 myRegister(Constants.XSD_DATE, java.util.Date .class, 216 new DateSerializerFactory(java.util.Date .class, 217 Constants.XSD_DATE), 218 new DateDeserializerFactory(java.util.Date .class, 219 Constants.XSD_DATE) 220 ); 221 222 myRegister(Constants.XSD_TIME, org.apache.axis.types.Time.class, 224 new SimpleSerializerFactory(org.apache.axis.types.Time.class, 225 Constants.XSD_TIME), 226 new SimpleDeserializerFactory(org.apache.axis.types.Time.class, 227 Constants.XSD_TIME) 228 ); 229 myRegister(Constants.XSD_YEARMONTH, org.apache.axis.types.YearMonth.class, 231 new SimpleSerializerFactory(org.apache.axis.types.YearMonth.class, 232 Constants.XSD_YEARMONTH), 233 new SimpleDeserializerFactory(org.apache.axis.types.YearMonth.class, 234 Constants.XSD_YEARMONTH) 235 ); 236 myRegister(Constants.XSD_YEAR, org.apache.axis.types.Year.class, 237 new SimpleSerializerFactory(org.apache.axis.types.Year.class, 238 Constants.XSD_YEAR), 239 new SimpleDeserializerFactory(org.apache.axis.types.Year.class, 240 Constants.XSD_YEAR) 241 ); 242 myRegister(Constants.XSD_MONTH, org.apache.axis.types.Month.class, 243 new SimpleSerializerFactory(org.apache.axis.types.Month.class, 244 Constants.XSD_MONTH), 245 new SimpleDeserializerFactory(org.apache.axis.types.Month.class, 246 Constants.XSD_MONTH) 247 ); 248 myRegister(Constants.XSD_DAY, org.apache.axis.types.Day.class, 249 new SimpleSerializerFactory(org.apache.axis.types.Day.class, 250 Constants.XSD_DAY), 251 new SimpleDeserializerFactory(org.apache.axis.types.Day.class, 252 Constants.XSD_DAY) 253 ); 254 myRegister(Constants.XSD_MONTHDAY, org.apache.axis.types.MonthDay.class, 255 new SimpleSerializerFactory(org.apache.axis.types.MonthDay.class, 256 Constants.XSD_MONTHDAY), 257 new SimpleDeserializerFactory(org.apache.axis.types.MonthDay.class, 258 Constants.XSD_MONTHDAY) 259 ); 260 261 myRegister(Constants.SOAP_MAP, java.util.Hashtable .class, 264 new MapSerializerFactory(java.util.Hashtable .class, 265 Constants.SOAP_MAP), 266 null ); 268 myRegister(Constants.SOAP_MAP, java.util.Map .class, 269 new MapSerializerFactory(java.util.Map .class, 270 Constants.SOAP_MAP), 271 null ); 273 myRegister(Constants.SOAP_MAP, java.util.HashMap .class, 275 new MapSerializerFactory(java.util.Map .class, 276 Constants.SOAP_MAP), 277 new MapDeserializerFactory(java.util.HashMap .class, 278 Constants.SOAP_MAP) 279 ); 280 281 myRegister(Constants.SOAP_ELEMENT, org.w3c.dom.Element .class, 283 new ElementSerializerFactory(), 284 new ElementDeserializerFactory()); 285 286 myRegister(Constants.SOAP_DOCUMENT, org.w3c.dom.Document .class, 288 new DocumentSerializerFactory(), 289 new DocumentDeserializerFactory()); 290 291 myRegister(Constants.SOAP_VECTOR, java.util.Vector .class, 292 new VectorSerializerFactory(java.util.Vector .class, 293 Constants.SOAP_VECTOR), 294 new VectorDeserializerFactory(java.util.Vector .class, 295 Constants.SOAP_VECTOR) 296 ); 297 298 if (JavaUtils.isAttachmentSupported()) { 301 myRegister(Constants.MIME_IMAGE, java.awt.Image .class, 302 new JAFDataHandlerSerializerFactory( 303 java.awt.Image .class, 304 Constants.MIME_IMAGE), 305 new JAFDataHandlerDeserializerFactory( 306 java.awt.Image .class, 307 Constants.MIME_IMAGE)); 308 myRegister(Constants.MIME_MULTIPART, javax.mail.internet.MimeMultipart .class, 309 new JAFDataHandlerSerializerFactory( 310 javax.mail.internet.MimeMultipart .class, 311 Constants.MIME_MULTIPART), 312 new JAFDataHandlerDeserializerFactory( 313 javax.mail.internet.MimeMultipart .class, 314 Constants.MIME_MULTIPART)); 315 myRegister(Constants.MIME_SOURCE, javax.xml.transform.Source .class, 316 new JAFDataHandlerSerializerFactory( 317 javax.xml.transform.Source .class, 318 Constants.MIME_SOURCE), 319 new JAFDataHandlerDeserializerFactory( 320 javax.xml.transform.Source .class, 321 Constants.MIME_SOURCE)); 322 myRegister(Constants.MIME_OCTETSTREAM, OctetStream.class, 323 new JAFDataHandlerSerializerFactory( 324 OctetStream.class, 325 Constants.MIME_OCTETSTREAM), 326 new JAFDataHandlerDeserializerFactory( 327 OctetStream.class, 328 Constants.MIME_OCTETSTREAM)); 329 myRegister(Constants.MIME_DATA_HANDLER, javax.activation.DataHandler .class, 330 new JAFDataHandlerSerializerFactory(), 331 new JAFDataHandlerDeserializerFactory()); 332 } 333 334 myRegister(Constants.XSD_TOKEN, org.apache.axis.types.Token.class, 336 new SimpleSerializerFactory(org.apache.axis.types.Token.class, 337 Constants.XSD_TOKEN), 338 new SimpleDeserializerFactory(org.apache.axis.types.Token.class, 339 Constants.XSD_TOKEN) 340 ); 341 342 myRegister(Constants.XSD_NORMALIZEDSTRING, org.apache.axis.types.NormalizedString.class, 344 new SimpleSerializerFactory(org.apache.axis.types.NormalizedString.class, 345 Constants.XSD_NORMALIZEDSTRING), 346 new SimpleDeserializerFactory(org.apache.axis.types.NormalizedString.class, 347 Constants.XSD_NORMALIZEDSTRING) 348 ); 349 350 myRegister(Constants.XSD_UNSIGNEDLONG, org.apache.axis.types.UnsignedLong.class, 352 new SimpleSerializerFactory(org.apache.axis.types.UnsignedLong.class, 353 Constants.XSD_UNSIGNEDLONG), 354 new SimpleDeserializerFactory(org.apache.axis.types.UnsignedLong.class, 355 Constants.XSD_UNSIGNEDLONG) 356 ); 357 358 myRegister(Constants.XSD_UNSIGNEDINT, org.apache.axis.types.UnsignedInt.class, 360 new SimpleSerializerFactory(org.apache.axis.types.UnsignedInt.class, 361 Constants.XSD_UNSIGNEDINT), 362 new SimpleDeserializerFactory(org.apache.axis.types.UnsignedInt.class, 363 Constants.XSD_UNSIGNEDINT) 364 ); 365 366 myRegister(Constants.XSD_UNSIGNEDSHORT, org.apache.axis.types.UnsignedShort.class, 368 new SimpleSerializerFactory(org.apache.axis.types.UnsignedShort.class, 369 Constants.XSD_UNSIGNEDSHORT), 370 new SimpleDeserializerFactory(org.apache.axis.types.UnsignedShort.class, 371 Constants.XSD_UNSIGNEDSHORT) 372 ); 373 374 myRegister(Constants.XSD_UNSIGNEDBYTE, org.apache.axis.types.UnsignedByte.class, 376 new SimpleSerializerFactory(org.apache.axis.types.UnsignedByte.class, 377 Constants.XSD_UNSIGNEDBYTE), 378 new SimpleDeserializerFactory(org.apache.axis.types.UnsignedByte.class, 379 Constants.XSD_UNSIGNEDBYTE) 380 ); 381 382 myRegister(Constants.XSD_NONNEGATIVEINTEGER, org.apache.axis.types.NonNegativeInteger.class, 384 new SimpleSerializerFactory(org.apache.axis.types.NonNegativeInteger.class, 385 Constants.XSD_NONNEGATIVEINTEGER), 386 new SimpleDeserializerFactory(org.apache.axis.types.NonNegativeInteger.class, 387 Constants.XSD_NONNEGATIVEINTEGER) 388 ); 389 390 myRegister(Constants.XSD_NEGATIVEINTEGER, org.apache.axis.types.NegativeInteger.class, 392 new SimpleSerializerFactory(org.apache.axis.types.NegativeInteger.class, 393 Constants.XSD_NEGATIVEINTEGER), 394 new SimpleDeserializerFactory(org.apache.axis.types.NegativeInteger.class, 395 Constants.XSD_NEGATIVEINTEGER) 396 ); 397 398 myRegister(Constants.XSD_POSITIVEINTEGER, org.apache.axis.types.PositiveInteger.class, 400 new SimpleSerializerFactory(org.apache.axis.types.PositiveInteger.class, 401 Constants.XSD_POSITIVEINTEGER), 402 new SimpleDeserializerFactory(org.apache.axis.types.PositiveInteger.class, 403 Constants.XSD_POSITIVEINTEGER) 404 ); 405 406 myRegister(Constants.XSD_NONPOSITIVEINTEGER, org.apache.axis.types.NonPositiveInteger.class, 408 new SimpleSerializerFactory(org.apache.axis.types.NonPositiveInteger.class, 409 Constants.XSD_NONPOSITIVEINTEGER), 410 new SimpleDeserializerFactory(org.apache.axis.types.NonPositiveInteger.class, 411 Constants.XSD_NONPOSITIVEINTEGER) 412 ); 413 414 myRegister(Constants.XSD_NAME, org.apache.axis.types.Name.class, 416 new SimpleSerializerFactory(org.apache.axis.types.Name.class, 417 Constants.XSD_NAME), 418 new SimpleDeserializerFactory(org.apache.axis.types.Name.class, 419 Constants.XSD_NAME) 420 ); 421 422 myRegister(Constants.XSD_NCNAME, org.apache.axis.types.NCName.class, 424 new SimpleSerializerFactory(org.apache.axis.types.NCName.class, 425 Constants.XSD_NCNAME), 426 new SimpleDeserializerFactory(org.apache.axis.types.NCName.class, 427 Constants.XSD_NCNAME) 428 ); 429 430 myRegister(Constants.XSD_ID, org.apache.axis.types.Id.class, 432 new SimpleSerializerFactory(org.apache.axis.types.Id.class, 433 Constants.XSD_ID), 434 new SimpleDeserializerFactory(org.apache.axis.types.Id.class, 435 Constants.XSD_ID) 436 ); 437 438 myRegister(Constants.XML_LANG, org.apache.axis.types.Language.class, 440 new SimpleSerializerFactory(org.apache.axis.types.Language.class, 441 Constants.XML_LANG), 442 new SimpleDeserializerFactory(org.apache.axis.types.Language.class, 443 Constants.XML_LANG) 444 ); 445 446 myRegister(Constants.XSD_LANGUAGE, org.apache.axis.types.Language.class, 448 new SimpleSerializerFactory(org.apache.axis.types.Language.class, 449 Constants.XSD_LANGUAGE), 450 new SimpleDeserializerFactory(org.apache.axis.types.Language.class, 451 Constants.XSD_LANGUAGE) 452 ); 453 454 myRegister(Constants.XSD_NMTOKEN, org.apache.axis.types.NMToken.class, 456 new SimpleSerializerFactory(org.apache.axis.types.NMToken.class, 457 Constants.XSD_NMTOKEN), 458 new SimpleDeserializerFactory(org.apache.axis.types.NMToken.class, 459 Constants.XSD_NMTOKEN) 460 ); 461 462 myRegister(Constants.XSD_NMTOKENS, org.apache.axis.types.NMTokens.class, 464 new SimpleSerializerFactory(org.apache.axis.types.NMTokens.class, 465 Constants.XSD_NMTOKENS), 466 new SimpleDeserializerFactory(org.apache.axis.types.NMTokens.class, 467 Constants.XSD_NMTOKENS) 468 ); 469 470 myRegister(Constants.XSD_NOTATION, org.apache.axis.types.Notation.class, 472 new BeanSerializerFactory(org.apache.axis.types.Notation.class, 473 Constants.XSD_NOTATION), 474 new BeanDeserializerFactory(org.apache.axis.types.Notation.class, 475 Constants.XSD_NOTATION) 476 ); 477 478 myRegister(Constants.XSD_ENTITY, org.apache.axis.types.Entity.class, 480 new SimpleSerializerFactory(org.apache.axis.types.Entity.class, 481 Constants.XSD_ENTITY), 482 new SimpleDeserializerFactory(org.apache.axis.types.Entity.class, 483 Constants.XSD_ENTITY) 484 ); 485 486 myRegister(Constants.XSD_ENTITIES, org.apache.axis.types.Entities.class, 488 new SimpleSerializerFactory(org.apache.axis.types.Entities.class, 489 Constants.XSD_ENTITIES), 490 new SimpleDeserializerFactory(org.apache.axis.types.Entities.class, 491 Constants.XSD_ENTITIES) 492 ); 493 494 myRegister(Constants.XSD_IDREF, org.apache.axis.types.IDRef.class, 496 new SimpleSerializerFactory(org.apache.axis.types.IDRef.class, 497 Constants.XSD_IDREF), 498 new SimpleDeserializerFactory(org.apache.axis.types.IDRef.class, 499 Constants.XSD_IDREF) 500 ); 501 502 myRegister(Constants.XSD_IDREFS, org.apache.axis.types.IDRefs.class, 504 new SimpleSerializerFactory(org.apache.axis.types.IDRefs.class, 505 Constants.XSD_IDREFS), 506 new SimpleDeserializerFactory(org.apache.axis.types.IDRefs.class, 507 Constants.XSD_IDREFS) 508 ); 509 510 myRegister(Constants.XSD_DURATION, org.apache.axis.types.Duration.class, 512 new SimpleSerializerFactory(org.apache.axis.types.Duration.class, 513 Constants.XSD_DURATION), 514 new SimpleDeserializerFactory(org.apache.axis.types.Duration.class, 515 Constants.XSD_DURATION) 516 ); 517 518 myRegister(Constants.XSD_ANYURI, org.apache.axis.types.URI.class, 520 new SimpleSerializerFactory(org.apache.axis.types.URI.class, 521 Constants.XSD_ANYURI), 522 new SimpleDeserializerFactory(org.apache.axis.types.URI.class, 523 Constants.XSD_ANYURI) 524 ); 525 526 myRegister(Constants.XSD_SCHEMA, org.apache.axis.types.Schema.class, 528 new BeanSerializerFactory(org.apache.axis.types.Schema.class, 529 Constants.XSD_SCHEMA), 530 new BeanDeserializerFactory(org.apache.axis.types.Schema.class, 531 Constants.XSD_SCHEMA) 532 ); 533 534 myRegister(Constants.SOAP_ARRAY, java.util.ArrayList .class, 539 new ArraySerializerFactory(), 540 new ArrayDeserializerFactory() 541 ); 542 543 SchemaVersion.SCHEMA_1999.registerSchemaSpecificTypes(this); 547 SchemaVersion.SCHEMA_2000.registerSchemaSpecificTypes(this); 548 SchemaVersion.SCHEMA_2001.registerSchemaSpecificTypes(this); 549 550 inInitMappings = false; 551 } 552 553 558 protected void myRegisterSimple(QName xmlType, Class javaType) { 559 SerializerFactory sf = new SimpleSerializerFactory(javaType, xmlType); 560 DeserializerFactory df = null; 561 if (javaType != java.lang.Object .class) { 562 df = new SimpleDeserializerFactory(javaType, xmlType); 563 } 564 565 myRegister(xmlType, javaType, sf, df); 566 } 567 568 580 protected void myRegister(QName xmlType, Class javaType, 581 SerializerFactory sf, DeserializerFactory df) { 582 try { 584 if (xmlType.getNamespaceURI().equals( 585 Constants.URI_DEFAULT_SCHEMA_XSD)) { 586 for (int i=0; i < Constants.URIS_SCHEMA_XSD.length; i++) { 587 QName qName = new QName (Constants.URIS_SCHEMA_XSD[i], 588 xmlType.getLocalPart()); 589 super.internalRegister(javaType, qName, sf, df); 590 } 591 } 592 else if (xmlType.getNamespaceURI().equals( 593 Constants.URI_DEFAULT_SOAP_ENC)) { 594 for (int i=0; i < Constants.URIS_SOAP_ENC.length; i++) { 595 QName qName = new QName (Constants.URIS_SOAP_ENC[i], 596 xmlType.getLocalPart()); 597 super.internalRegister(javaType, qName, sf, df); 598 } 599 } else { 600 super.internalRegister(javaType, xmlType, sf, df); 603 } 604 } catch (JAXRPCException e) { } 605 } 606 607 public void register(Class javaType, QName xmlType, 610 javax.xml.rpc.encoding.SerializerFactory sf, 611 javax.xml.rpc.encoding.DeserializerFactory dsf) 612 throws JAXRPCException { 613 super.register(javaType, xmlType, sf, dsf); 614 } 615 public void removeSerializer(Class javaType, QName xmlType) 616 throws JAXRPCException { 617 throw new JAXRPCException (Messages.getMessage("fixedTypeMapping")); 618 } 619 public void removeDeserializer(Class javaType, QName xmlType) 620 throws JAXRPCException { 621 throw new JAXRPCException (Messages.getMessage("fixedTypeMapping")); 622 } 623 public void setSupportedEncodings(String [] namespaceURIs) { 624 } 625 } 626 | Popular Tags |