001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package mx4j.tools.remote.soap.axis.ser;
010:
011: import java.io.IOException;
012: import javax.management.MBeanInfo;
013: import javax.xml.namespace.QName;
014:
015: import org.apache.axis.encoding.SerializationContext;
016: import org.apache.axis.encoding.XMLType;
017: import org.apache.axis.wsdl.fromJava.Types;
018: import org.w3c.dom.Element;
019: import org.xml.sax.Attributes;
020:
021: /**
022: * @version $Revision: 1.5 $
023: */
024: public class MBeanInfoSer extends AxisSerializer {
025: static final String TYPE = "MBeanInfo";
026: static final String CLASS_NAME = "className";
027: static final String DESCRIPTION = "description";
028: static final String ATTRIBUTES = "attributes";
029: static final String CONSTRUCTORS = "constructors";
030: static final String OPERATIONS = "operations";
031: static final String NOTIFICATIONS = "notifications";
032: private static final QName CLASS_NAME_QNAME = new QName("",
033: CLASS_NAME);
034: private static final QName DESCRIPTION_QNAME = new QName("",
035: DESCRIPTION);
036: private static final QName ATTRIBUTES_QNAME = new QName("",
037: ATTRIBUTES);
038: private static final QName CONSTRUCTORS_QNAME = new QName("",
039: CONSTRUCTORS);
040: private static final QName OPERATIONS_QNAME = new QName("",
041: OPERATIONS);
042: private static final QName NOTIFICATIONS_QNAME = new QName("",
043: NOTIFICATIONS);
044:
045: public void serialize(QName name, Attributes attributes,
046: Object value, SerializationContext context)
047: throws IOException {
048: MBeanInfo info = (MBeanInfo) value;
049: context.startElement(name, attributes);
050: context.serialize(CLASS_NAME_QNAME, null, info.getClassName());
051: context.serialize(DESCRIPTION_QNAME, null, info
052: .getDescription());
053: context.serialize(ATTRIBUTES_QNAME, null, info.getAttributes());
054: context.serialize(CONSTRUCTORS_QNAME, null, info
055: .getConstructors());
056: context.serialize(OPERATIONS_QNAME, null, info.getOperations());
057: context.serialize(NOTIFICATIONS_QNAME, null, info
058: .getNotifications());
059: context.endElement();
060: }
061:
062: public Element writeSchema(Class javaType, Types types)
063: throws Exception {
064: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
065: complexType.setAttribute("name", TYPE);
066: Element allElement = types.createElement(SCHEMA_ALL);
067: complexType.appendChild(allElement);
068:
069: Element typeElement = types.createElement(SCHEMA_ELEMENT);
070: typeElement.setAttribute("name", CLASS_NAME);
071: typeElement.setAttribute("type", XMLType.XSD_STRING
072: .getLocalPart());
073: allElement.appendChild(typeElement);
074:
075: Element descrElement = types.createElement(SCHEMA_ELEMENT);
076: descrElement.setAttribute("name", DESCRIPTION);
077: descrElement.setAttribute("type", XMLType.XSD_STRING
078: .getLocalPart());
079: allElement.appendChild(descrElement);
080:
081: Element attributesElement = types.createElement(SCHEMA_ELEMENT);
082: attributesElement.setAttribute("name", ATTRIBUTES);
083: attributesElement.setAttribute("type", XMLType.SOAP_ARRAY
084: .getLocalPart());
085: allElement.appendChild(attributesElement);
086:
087: Element constructorsElement = types
088: .createElement(SCHEMA_ELEMENT);
089: constructorsElement.setAttribute("name", CONSTRUCTORS);
090: constructorsElement.setAttribute("type", XMLType.SOAP_ARRAY
091: .getLocalPart());
092: allElement.appendChild(constructorsElement);
093:
094: Element operationsElement = types.createElement(SCHEMA_ELEMENT);
095: operationsElement.setAttribute("name", OPERATIONS);
096: operationsElement.setAttribute("type", XMLType.SOAP_ARRAY
097: .getLocalPart());
098: allElement.appendChild(operationsElement);
099:
100: Element notificationsElement = types
101: .createElement(SCHEMA_ELEMENT);
102: notificationsElement.setAttribute("name", NOTIFICATIONS);
103: notificationsElement.setAttribute("type", XMLType.SOAP_ARRAY
104: .getLocalPart());
105: allElement.appendChild(notificationsElement);
106:
107: return complexType;
108: }
109: }
|