KickJava   Java API By Example, From Geeks To Geeks.

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


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.MBeanInfo 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 MBeanInfoSer extends AxisSerializer
25 {
26    static final String JavaDoc TYPE = "MBeanInfo";
27    static final String JavaDoc CLASS_NAME = "className";
28    static final String JavaDoc DESCRIPTION = "description";
29    static final String JavaDoc ATTRIBUTES = "attributes";
30    static final String JavaDoc CONSTRUCTORS = "constructors";
31    static final String JavaDoc OPERATIONS = "operations";
32    static final String JavaDoc NOTIFICATIONS = "notifications";
33    private static final QName JavaDoc CLASS_NAME_QNAME = new QName JavaDoc("", CLASS_NAME);
34    private static final QName JavaDoc DESCRIPTION_QNAME = new QName JavaDoc("", DESCRIPTION);
35    private static final QName JavaDoc ATTRIBUTES_QNAME = new QName JavaDoc("", ATTRIBUTES);
36    private static final QName JavaDoc CONSTRUCTORS_QNAME = new QName JavaDoc("", CONSTRUCTORS);
37    private static final QName JavaDoc OPERATIONS_QNAME = new QName JavaDoc("", OPERATIONS);
38    private static final QName JavaDoc NOTIFICATIONS_QNAME = new QName JavaDoc("", NOTIFICATIONS);
39
40    public void serialize(QName JavaDoc name, Attributes JavaDoc attributes, Object JavaDoc value, SerializationContext context) throws IOException JavaDoc
41    {
42       MBeanInfo JavaDoc info = (MBeanInfo JavaDoc)value;
43       context.startElement(name, attributes);
44       context.serialize(CLASS_NAME_QNAME, null, info.getClassName());
45       context.serialize(DESCRIPTION_QNAME, null, info.getDescription());
46       context.serialize(ATTRIBUTES_QNAME, null, info.getAttributes());
47       context.serialize(CONSTRUCTORS_QNAME, null, info.getConstructors());
48       context.serialize(OPERATIONS_QNAME, null, info.getOperations());
49       context.serialize(NOTIFICATIONS_QNAME, null, info.getNotifications());
50       context.endElement();
51    }
52
53    public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc
54    {
55       Element JavaDoc complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
56       complexType.setAttribute("name", TYPE);
57       Element JavaDoc allElement = types.createElement(SCHEMA_ALL);
58       complexType.appendChild(allElement);
59
60       Element JavaDoc typeElement = types.createElement(SCHEMA_ELEMENT);
61       typeElement.setAttribute("name", CLASS_NAME);
62       typeElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart());
63       allElement.appendChild(typeElement);
64
65       Element JavaDoc descrElement = types.createElement(SCHEMA_ELEMENT);
66       descrElement.setAttribute("name", DESCRIPTION);
67       descrElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart());
68       allElement.appendChild(descrElement);
69
70       Element JavaDoc attributesElement = types.createElement(SCHEMA_ELEMENT);
71       attributesElement.setAttribute("name", ATTRIBUTES);
72       attributesElement.setAttribute("type", XMLType.SOAP_ARRAY.getLocalPart());
73       allElement.appendChild(attributesElement);
74
75       Element JavaDoc constructorsElement = types.createElement(SCHEMA_ELEMENT);
76       constructorsElement.setAttribute("name", CONSTRUCTORS);
77       constructorsElement.setAttribute("type", XMLType.SOAP_ARRAY.getLocalPart());
78       allElement.appendChild(constructorsElement);
79
80       Element JavaDoc operationsElement = types.createElement(SCHEMA_ELEMENT);
81       operationsElement.setAttribute("name", OPERATIONS);
82       operationsElement.setAttribute("type", XMLType.SOAP_ARRAY.getLocalPart());
83       allElement.appendChild(operationsElement);
84
85       Element JavaDoc notificationsElement = types.createElement(SCHEMA_ELEMENT);
86       notificationsElement.setAttribute("name", NOTIFICATIONS);
87       notificationsElement.setAttribute("type", XMLType.SOAP_ARRAY.getLocalPart());
88       allElement.appendChild(notificationsElement);
89
90       return complexType;
91    }
92 }
93
Popular Tags