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.ArrayDeserializerFactory; 14 import org.apache.axis.encoding.ser.ArraySerializerFactory; 15 16 /** 17 * Factory to create a TypeMapping for array transfer objects. 18 * 19 * @author Linke 20 * 21 */ 22 public class ArrayTypeMappingFactory implements TypeMappingFactory { 23 24 private Class clazz = null; 25 private QName qName = null; 26 27 /** 28 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getJavaType() 29 */ 30 public Class getJavaType() { return clazz; } 31 32 /** 33 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getXmlType() 34 */ 35 public QName getXmlType() { return qName; } 36 37 /** 38 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getSerializerFactory() 39 */ 40 public SerializerFactory getSerializerFactory() { return new ArraySerializerFactory(getJavaType(), getXmlType()); } 41 42 /** 43 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#getDeserializerFactory() 44 */ 45 public DeserializerFactory getDeserializerFactory() { return new ArrayDeserializerFactory(getXmlType()); } 46 47 /** 48 * @see net.sf.crispy.impl.jaxrpc.TypeMappingFactory#setParameter(java.lang.String[]) 49 */ 50 public void setParameter(String[] pvParams) { 51 52 if (pvParams == null) { 53 throw new IllegalArgumentException ("The class name is null (in ArrayTypeMappingFactory)!"); 54 } 55 56 String lvClassName = pvParams[1]; 57 58 try { 59 clazz = Class.forName(lvClassName); 60 qName = Util.createQNameByClass(clazz); 61 } catch (Exception e) { 62 throw new InvocationException("Can't create class (in ArrayTypeMappingFactory) from string: " + lvClassName, e); 63 } 64 65 } 66 67 public String toString() { 68 return getJavaType() + " " + getXmlType(); 69 } 70 }