KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > soap > axis > ser > PrincipalDeser


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.soap.axis.ser;
10
11 import java.lang.reflect.Constructor JavaDoc;
12
13 import org.xml.sax.SAXException JavaDoc;
14
15 /**
16  * @version $Revision: 1.5 $
17  */

18 public class PrincipalDeser extends AxisDeserializer
19 {
20    private String JavaDoc className;
21    private String JavaDoc name;
22
23    public void onSetChildValue(Object JavaDoc value, Object JavaDoc hint) throws SAXException JavaDoc
24    {
25       if (PrincipalSer.CLASS_NAME.equals(hint))
26          className = (String JavaDoc)value;
27       else if (PrincipalSer.NAME.equals(hint)) name = (String JavaDoc)value;
28    }
29
30    protected Object JavaDoc createObject() throws SAXException JavaDoc
31    {
32       try
33       {
34          Class JavaDoc principalClass = Thread.currentThread().getContextClassLoader().loadClass(className);
35          Constructor JavaDoc ctor = principalClass.getConstructor(new Class JavaDoc[]{String JavaDoc.class});
36          return ctor.newInstance(new Object JavaDoc[]{name});
37       }
38       catch (Exception JavaDoc x)
39       {
40          throw new SAXException JavaDoc(x);
41       }
42    }
43 }
44
Popular Tags