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.MBeanOperationInfo;
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 MBeanOperationInfoSer extends AxisSerializer {
25: static final String TYPE = "MBeanOperationInfo";
26: static final String NAME = "name";
27: static final String CLASS_NAME = "type";
28: static final String DESCRIPTION = "description";
29: static final String SIGNATURE = "signature";
30: static final String IMPACT = "impact";
31: private static final QName NAME_QNAME = new QName("", NAME);
32: private static final QName CLASS_NAME_QNAME = new QName("",
33: CLASS_NAME);
34: private static final QName DESCRIPTION_QNAME = new QName("",
35: DESCRIPTION);
36: private static final QName SIGNATURE_QNAME = new QName("",
37: SIGNATURE);
38: private static final QName IMPACT_QNAME = new QName("", IMPACT);
39:
40: public void serialize(QName name, Attributes attributes,
41: Object value, SerializationContext context)
42: throws IOException {
43: MBeanOperationInfo info = (MBeanOperationInfo) value;
44: context.startElement(name, attributes);
45: context.serialize(NAME_QNAME, null, info.getName());
46: context.serialize(DESCRIPTION_QNAME, null, info
47: .getDescription());
48: context.serialize(SIGNATURE_QNAME, null, info.getSignature());
49: context.serialize(CLASS_NAME_QNAME, null, info.getReturnType());
50: context.serialize(IMPACT_QNAME, null, new Integer(info
51: .getImpact()));
52: context.endElement();
53: }
54:
55: public Element writeSchema(Class javaType, Types types)
56: throws Exception {
57: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
58: complexType.setAttribute("name", TYPE);
59: Element allElement = types.createElement(SCHEMA_ALL);
60: complexType.appendChild(allElement);
61:
62: Element nameElement = types.createElement(SCHEMA_ELEMENT);
63: nameElement.setAttribute("name", NAME);
64: nameElement.setAttribute("type", XMLType.XSD_STRING
65: .getLocalPart());
66: allElement.appendChild(nameElement);
67:
68: Element descrElement = types.createElement(SCHEMA_ELEMENT);
69: descrElement.setAttribute("name", DESCRIPTION);
70: descrElement.setAttribute("type", XMLType.XSD_STRING
71: .getLocalPart());
72: allElement.appendChild(descrElement);
73:
74: Element signatureElement = types.createElement(SCHEMA_ELEMENT);
75: signatureElement.setAttribute("name", SIGNATURE);
76: signatureElement.setAttribute("type", XMLType.SOAP_ARRAY
77: .getLocalPart());
78: allElement.appendChild(signatureElement);
79:
80: Element typeElement = types.createElement(SCHEMA_ELEMENT);
81: typeElement.setAttribute("name", CLASS_NAME);
82: typeElement.setAttribute("type", XMLType.XSD_STRING
83: .getLocalPart());
84: allElement.appendChild(typeElement);
85:
86: Element impactElement = types.createElement(SCHEMA_ELEMENT);
87: impactElement.setAttribute("name", IMPACT);
88: impactElement.setAttribute("type", XMLType.XSD_INT
89: .getLocalPart());
90: allElement.appendChild(impactElement);
91:
92: return complexType;
93: }
94: }
|