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