1 /** 2 * 3 */ 4 package net.sf.crispy.impl.jaxrpc; 5 6 import javax.xml.namespace.QName; 7 import javax.xml.rpc.encoding.DeserializerFactory; 8 import javax.xml.rpc.encoding.SerializerFactory; 9 10 import net.sf.crispy.InvocationException; 11 import net.sf.crispy.util.Util; 12 13 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 14 import org.apache.axis.encoding.ser.BeanSerializerFactory; 15 16 /** 17 * 18 * Factory to create a TypeMapping for transfer for JavaBean-object. 19 * 20 * @author Linke 21 * 22 */ 23 public class BeanTypeMappingFactory implements TypeMappingFactory { 24 25 private Class clazz = null; 26 private QName qName = null; 27 28 public BeanTypeMappingFactory() { } 29 30 public void setParameter (String pvParams[]) { 31 if (pvParams == null) { 32 throw new IllegalArgumentException ("The class name is null (in BeanTypeMappingFactory)!"); 33 } 34 35 String lvClassName = pvParams[1]; 36 try { 37 clazz = Class.forName(lvClassName); 38 qName = Util.createQNameByClass(clazz); 39 } catch (Exception e) { 40 throw new InvocationException("Can't create class (in BeanTypeMappingFactory) from string: " + lvClassName, e); 41 } 42 } 43 /** 44 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getJavaType() 45 */ 46 public Class getJavaType() { return clazz; } 47 48 /** 49 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getXmlType() 50 */ 51 public QName getXmlType() { return qName; } 52 53 /** 54 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getSerializerFactory() 55 */ 56 public SerializerFactory getSerializerFactory() { return new BeanSerializerFactory(clazz, getXmlType()); } 57 58 /** 59 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getDeserializerFactory() 60 */ 61 public DeserializerFactory getDeserializerFactory() { return new BeanDeserializerFactory(clazz, getXmlType()); } 62 63 }