1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.description.TypeDesc; 20 import org.apache.axis.encoding.Deserializer; 21 import org.apache.axis.utils.BeanPropertyDescriptor; 22 import org.apache.axis.utils.BeanUtils; 23 import org.apache.axis.utils.JavaUtils; 24 25 import javax.xml.namespace.QName ; 26 import java.util.HashMap ; 27 import java.util.Map ; 28 import java.io.IOException ; 29 30 36 public class BeanDeserializerFactory extends BaseDeserializerFactory { 37 38 39 protected transient TypeDesc typeDesc = null; 40 protected transient Map propertyMap = null; 41 42 public BeanDeserializerFactory(Class javaType, QName xmlType) { 43 super(BeanDeserializer.class, xmlType, javaType); 44 45 if (JavaUtils.isEnumClass(javaType)) { 48 deserClass = EnumDeserializer.class; 49 } 50 51 typeDesc = TypeDesc.getTypeDescForClass(javaType); 52 propertyMap = getProperties(javaType, typeDesc); 53 } 54 55 58 public static Map getProperties(Class javaType, TypeDesc typeDesc ) { 59 Map propertyMap = null; 60 61 if (typeDesc != null) { 62 propertyMap = typeDesc.getPropertyDescriptorMap(); 63 } else { 64 BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType, null); 65 propertyMap = new HashMap (); 66 for (int i = 0; i < pd.length; i++) { 68 BeanPropertyDescriptor descriptor = pd[i]; 69 propertyMap.put(descriptor.getName(), descriptor); 70 } 71 } 72 73 return propertyMap; 74 } 75 76 80 protected Deserializer getGeneralPurpose(String mechanismType) { 81 if (javaType == null || xmlType == null) { 82 return super.getGeneralPurpose(mechanismType); 83 } 84 85 if (deserClass == EnumDeserializer.class) { 86 return super.getGeneralPurpose(mechanismType); 87 } 88 89 return new BeanDeserializer(javaType, xmlType, typeDesc, propertyMap); 90 } 91 92 93 private void readObject(java.io.ObjectInputStream in) throws IOException , ClassNotFoundException { 94 in.defaultReadObject(); 95 typeDesc = TypeDesc.getTypeDescForClass(javaType); 96 propertyMap = getProperties(javaType, typeDesc); 97 } 98 } 99 | Popular Tags |