KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.IOException JavaDoc;
12 import javax.management.ObjectInstance JavaDoc;
13 import javax.xml.namespace.QName JavaDoc;
14
15 import org.apache.axis.encoding.SerializationContext;
16 import org.apache.axis.encoding.XMLType;
17 import org.apache.axis.wsdl.fromJava.Types;
18 import org.w3c.dom.Element JavaDoc;
19 import org.xml.sax.Attributes JavaDoc;
20
21 /**
22  * @version $Revision: 1.5 $
23  */

24 public class ObjectInstanceSer extends AxisSerializer
25 {
26    static final String JavaDoc TYPE = "ObjectInstance";
27    static final String JavaDoc OBJECT_NAME = "objectName";
28    static final String JavaDoc CLASS_NAME = "className";
29    private static final QName JavaDoc OBJECTNAME_QNAME = new QName JavaDoc("", OBJECT_NAME);
30    private static final QName JavaDoc CLASS_NAME_QNAME = new QName JavaDoc("", CLASS_NAME);
31
32    public void serialize(QName JavaDoc name, Attributes JavaDoc attributes, Object JavaDoc value, SerializationContext context) throws IOException JavaDoc
33    {
34       ObjectInstance JavaDoc instance = (ObjectInstance JavaDoc)value;
35       context.startElement(name, attributes);
36       context.serialize(OBJECTNAME_QNAME, null, instance.getObjectName());
37       context.serialize(CLASS_NAME_QNAME, null, instance.getClassName());
38       context.endElement();
39    }
40
41    public Element JavaDoc writeSchema(Class JavaDoc aClass, Types types) throws Exception JavaDoc
42    {
43       Element JavaDoc complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
44       complexType.setAttribute("name", TYPE);
45       Element JavaDoc allElement = types.createElement(SCHEMA_ALL);
46       complexType.appendChild(allElement);
47
48       Element JavaDoc objectNameElement = types.createElement(SCHEMA_ELEMENT);
49       objectNameElement.setAttribute("name", OBJECT_NAME);
50       objectNameElement.setAttribute("type", ObjectNameSer.TYPE);
51       allElement.appendChild(objectNameElement);
52
53       Element JavaDoc classNameElement = types.createElement(SCHEMA_ELEMENT);
54       classNameElement.setAttribute("name", CLASS_NAME);
55       classNameElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart());
56       allElement.appendChild(classNameElement);
57
58       return complexType;
59    }
60 }
61
Popular Tags