1 16 17 package org.apache.axis.encoding.ser; 18 19 import java.io.IOException ; 20 21 import org.apache.axis.description.TypeDesc; 22 import org.apache.axis.encoding.Serializer; 23 import org.apache.axis.utils.BeanPropertyDescriptor; 24 import org.apache.axis.utils.BeanUtils; 25 import org.apache.axis.utils.JavaUtils; 26 27 import javax.xml.namespace.QName ; 28 import javax.xml.rpc.JAXRPCException ; 29 30 35 public class BeanSerializerFactory extends BaseSerializerFactory { 36 37 protected transient TypeDesc typeDesc = null; 38 protected transient BeanPropertyDescriptor[] propertyDescriptor = null; 39 40 public BeanSerializerFactory(Class javaType, QName xmlType) { 41 super(BeanSerializer.class, xmlType, javaType); 42 init(javaType); 43 44 } 45 46 private void init(Class javaType) { 47 if (JavaUtils.isEnumClass(javaType)) { 50 serClass = EnumSerializer.class; 51 } 52 53 typeDesc = TypeDesc.getTypeDescForClass(javaType); 54 55 if (typeDesc != null) { 56 propertyDescriptor = typeDesc.getPropertyDescriptors(); 57 } else { 58 propertyDescriptor = BeanUtils.getPd(javaType, null); 59 } 60 } 61 62 public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType) 63 throws JAXRPCException { 64 return (Serializer) super.getSerializerAs(mechanismType); 65 } 66 67 71 protected Serializer getGeneralPurpose(String mechanismType) { 72 if (javaType == null || xmlType == null) { 73 return super.getGeneralPurpose(mechanismType); 74 } 75 76 if (serClass == EnumSerializer.class) { 77 return super.getGeneralPurpose(mechanismType); 78 } 79 80 return new BeanSerializer(javaType, xmlType, typeDesc, 81 propertyDescriptor); 82 } 83 84 private void readObject(java.io.ObjectInputStream in) throws IOException , ClassNotFoundException { 85 in.defaultReadObject(); 86 init(javaType); 87 } 88 89 } 90 | Popular Tags |