1 3 4 package org.enhydra.shark.wfxml.util; 5 6 import java.util.HashMap ; 7 import java.util.Map ; 8 9 import javax.xml.namespace.QName ; 10 11 import org.apache.axis.description.TypeDesc; 12 import org.apache.axis.encoding.Deserializer; 13 import org.apache.axis.encoding.ser.BaseDeserializerFactory; 14 import org.apache.axis.encoding.ser.EnumDeserializer; 15 import org.apache.axis.utils.*; 16 17 23 public class AltBeanDeserializerFactory extends BaseDeserializerFactory { 24 25 26 protected TypeDesc typeDesc = null; 27 protected Map propertyMap = null; 28 29 public AltBeanDeserializerFactory(Class javaType, QName xmlType) { 30 super(BeanDeserializerShark.class, xmlType, javaType); 31 32 if (JavaUtils.isEnumClass(javaType)) { 35 deserClass = EnumDeserializer.class; 36 } 37 38 typeDesc = TypeDesc.getTypeDescForClass(javaType); 39 propertyMap = getProperties(javaType, typeDesc); 40 } 41 42 45 public static Map getProperties(Class javaType, TypeDesc typeDesc ) { 46 Map propertyMap = null; 47 48 if (typeDesc != null) { 49 propertyMap = typeDesc.getPropertyDescriptorMap(); 50 } else { 51 BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType, null); 52 propertyMap = new HashMap (); 53 for (int i = 0; i < pd.length; i++) { 55 BeanPropertyDescriptor descriptor = pd[i]; 56 propertyMap.put(descriptor.getName(), descriptor); 57 } 58 } 59 60 return propertyMap; 61 } 62 63 67 protected Deserializer getGeneralPurpose(String mechanismType) { 68 if (javaType == null || xmlType == null) { 69 return super.getGeneralPurpose(mechanismType); 70 } 71 72 if (deserClass == EnumDeserializer.class) { 73 return super.getGeneralPurpose(mechanismType); 74 } 75 76 return new BeanDeserializerShark(javaType, xmlType, typeDesc, propertyMap); 77 } 78 } 79 | Popular Tags |