01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package mx4j.tools.remote.soap.axis.ser;
10:
11: import java.lang.reflect.Constructor;
12:
13: import org.xml.sax.SAXException;
14:
15: /**
16: * @version $Revision: 1.5 $
17: */
18: public class PrincipalDeser extends AxisDeserializer {
19: private String className;
20: private String name;
21:
22: public void onSetChildValue(Object value, Object hint)
23: throws SAXException {
24: if (PrincipalSer.CLASS_NAME.equals(hint))
25: className = (String) value;
26: else if (PrincipalSer.NAME.equals(hint))
27: name = (String) value;
28: }
29:
30: protected Object createObject() throws SAXException {
31: try {
32: Class principalClass = Thread.currentThread()
33: .getContextClassLoader().loadClass(className);
34: Constructor ctor = principalClass
35: .getConstructor(new Class[] { String.class });
36: return ctor.newInstance(new Object[] { name });
37: } catch (Exception x) {
38: throw new SAXException(x);
39: }
40: }
41: }
|