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.MBeanParameterInfo;
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 MBeanParameterInfoSer extends AxisSerializer {
25: static final String TYPE = "MBeanParameterInfo";
26: static final String NAME = "name";
27: static final String CLASS_NAME = "type";
28: static final String DESCRIPTION = "description";
29: private static final QName NAME_QNAME = new QName("", NAME);
30: private static final QName CLASS_NAME_QNAME = new QName("",
31: CLASS_NAME);
32: private static final QName DESCRIPTION_QNAME = new QName("",
33: DESCRIPTION);
34:
35: public void serialize(QName name, Attributes attributes,
36: Object value, SerializationContext context)
37: throws IOException {
38: MBeanParameterInfo info = (MBeanParameterInfo) value;
39: context.startElement(name, attributes);
40: context.serialize(NAME_QNAME, null, info.getName());
41: context.serialize(CLASS_NAME_QNAME, null, info.getType());
42: context.serialize(DESCRIPTION_QNAME, null, info
43: .getDescription());
44: context.endElement();
45: }
46:
47: public Element writeSchema(Class aClass, Types types)
48: throws Exception {
49: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
50: complexType.setAttribute("name", TYPE);
51: Element allElement = types.createElement(SCHEMA_ALL);
52: complexType.appendChild(allElement);
53:
54: Element nameElement = types.createElement(SCHEMA_ELEMENT);
55: nameElement.setAttribute("name", NAME);
56: nameElement.setAttribute("type", XMLType.XSD_STRING
57: .getLocalPart());
58: allElement.appendChild(nameElement);
59:
60: Element typeElement = types.createElement(SCHEMA_ELEMENT);
61: typeElement.setAttribute("name", CLASS_NAME);
62: typeElement.setAttribute("type", XMLType.XSD_STRING
63: .getLocalPart());
64: allElement.appendChild(typeElement);
65:
66: Element descrElement = types.createElement(SCHEMA_ELEMENT);
67: descrElement.setAttribute("name", DESCRIPTION);
68: descrElement.setAttribute("type", XMLType.XSD_STRING
69: .getLocalPart());
70: allElement.appendChild(descrElement);
71:
72: return complexType;
73: }
74: }
|