1 4 5 9 10 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 ; 50 import javax.xml.rpc.JAXRPCException ; 51 import javax.xml.rpc.encoding.SerializerFactory ; 52 import javax.xml.rpc.encoding.DeserializerFactory ; 53 54 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; 80 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 108 109 myRegisterSimple(Constants.XSD_ANYSIMPLETYPE, java.lang.String .class); 111 112 myRegisterSimple(Constants.XSD_STRING, java.lang.String .class); 114 myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean .class); 115 myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double .class); 116 myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float .class); 117 myRegisterSimple(Constants.XSD_INT, java.lang.Integer .class); 118 myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger .class 119 ); 120 myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal .class 121 ); 122 myRegisterSimple(Constants.XSD_LONG, java.lang.Long .class); 123 myRegisterSimple(Constants.XSD_SHORT, java.lang.Short .class); 124 myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte .class); 125 126 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 144 148 157 166 205 224 229 234 241 249 257 265 273 281 289 297 305 313 321 329 337 345 353 361 369 377 385 393 401 409 417 425 433 441 myRegister(Constants.SOAP_ARRAY12, java.util.Collection .class, 443 new LZArraySerializerFactory(), 444 new SWFArrayDeserializerFactory() 445 ); 446 myRegister(Constants.SOAP_ARRAY12, java.util.ArrayList .class, 448 new LZArraySerializerFactory(), 449 new SWFArrayDeserializerFactory() 450 ); 451 452 myRegister(Constants.SOAP_ARRAY12, Object [].class, 453 new LZArraySerializerFactory(), 454 new SWFArrayDeserializerFactory() 455 ); 456 457 myRegister(Constants.SOAP_ARRAY, java.util.ArrayList .class, 458 new LZArraySerializerFactory(), 459 new SWFArrayDeserializerFactory() 460 ); 461 462 myRegister(Constants.SOAP_ARRAY, java.util.Collection .class, 470 new LZArraySerializerFactory(), 471 new SWFArrayDeserializerFactory() 472 ); 473 474 myRegister(Constants.SOAP_ARRAY, Object [].class, 475 new LZArraySerializerFactory(), 476 new SWFArrayDeserializerFactory() 477 ); 478 479 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 .class, Constants.XSD_DATETIME); 487 DeserializerFactory df = new SWFSimpleDeserializerFactory(java.util.Date .class, Constants.XSD_DATETIME); 488 myRegister(Constants.XSD_DATETIME, java.util.Date .class, sf, df); 489 490 doneInit = true; 491 } 492 493 protected void myRegisterSimple(QName xmlType, Class javaType) { 494 SerializerFactory sf = new SimpleSerializerFactory(javaType, xmlType); 495 DeserializerFactory df = null; 496 if (javaType != java.lang.Object .class) { 497 df = new SWFSimpleDeserializerFactory(javaType, xmlType); 498 } 499 myRegister(xmlType, javaType, sf, df); 500 } 501 502 514 protected void myRegister(QName xmlType, Class javaType, 515 SerializerFactory sf, DeserializerFactory df) { 516 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 qName = new QName (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 qName = new QName (Constants.URIS_SOAP_ENC[i], 530 xmlType.getLocalPart()); 531 super.internalRegister(javaType, qName, sf, df); 532 } 533 } else { 534 super.internalRegister(javaType, xmlType, sf, df); 537 } 538 } catch (JAXRPCException e) { } 539 } 540 541 public void register(Class javaType, QName xmlType, 544 javax.xml.rpc.encoding.SerializerFactory sf, 545 javax.xml.rpc.encoding.DeserializerFactory dsf) 546 throws JAXRPCException { 547 super.register(javaType, xmlType, sf, dsf); 549 } 550 551 public void removeSerializer(Class javaType, QName xmlType) 552 throws JAXRPCException { 553 throw new JAXRPCException (Messages.getMessage("fixedTypeMapping")); 554 } 555 public void removeDeserializer(Class javaType, QName xmlType) 556 throws JAXRPCException { 557 throw new JAXRPCException (Messages.getMessage("fixedTypeMapping")); 558 } 559 public void setSupportedEncodings(String [] namespaceURIs) { 560 } 561 } 562 | Popular Tags |