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.io.IOException;
12: import javax.management.ObjectInstance;
13: import javax.xml.namespace.QName;
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;
19: import org.xml.sax.Attributes;
20:
21: /**
22: * @version $Revision: 1.5 $
23: */
24: public class ObjectInstanceSer extends AxisSerializer {
25: static final String TYPE = "ObjectInstance";
26: static final String OBJECT_NAME = "objectName";
27: static final String CLASS_NAME = "className";
28: private static final QName OBJECTNAME_QNAME = new QName("",
29: OBJECT_NAME);
30: private static final QName CLASS_NAME_QNAME = new QName("",
31: CLASS_NAME);
32:
33: public void serialize(QName name, Attributes attributes,
34: Object value, SerializationContext context)
35: throws IOException {
36: ObjectInstance instance = (ObjectInstance) value;
37: context.startElement(name, attributes);
38: context.serialize(OBJECTNAME_QNAME, null, instance
39: .getObjectName());
40: context.serialize(CLASS_NAME_QNAME, null, instance
41: .getClassName());
42: context.endElement();
43: }
44:
45: public Element writeSchema(Class aClass, Types types)
46: throws Exception {
47: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
48: complexType.setAttribute("name", TYPE);
49: Element allElement = types.createElement(SCHEMA_ALL);
50: complexType.appendChild(allElement);
51:
52: Element objectNameElement = types.createElement(SCHEMA_ELEMENT);
53: objectNameElement.setAttribute("name", OBJECT_NAME);
54: objectNameElement.setAttribute("type", ObjectNameSer.TYPE);
55: allElement.appendChild(objectNameElement);
56:
57: Element classNameElement = types.createElement(SCHEMA_ELEMENT);
58: classNameElement.setAttribute("name", CLASS_NAME);
59: classNameElement.setAttribute("type", XMLType.XSD_STRING
60: .getLocalPart());
61: allElement.appendChild(classNameElement);
62:
63: return complexType;
64: }
65: }
|