1 8 9 package mx4j.tools.remote.soap.axis.ser; 10 11 import java.io.IOException ; 12 import javax.management.MBeanInfo ; 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 24 public class MBeanInfoSer extends AxisSerializer 25 { 26 static final String TYPE = "MBeanInfo"; 27 static final String CLASS_NAME = "className"; 28 static final String DESCRIPTION = "description"; 29 static final String ATTRIBUTES = "attributes"; 30 static final String CONSTRUCTORS = "constructors"; 31 static final String OPERATIONS = "operations"; 32 static final String NOTIFICATIONS = "notifications"; 33 private static final QName CLASS_NAME_QNAME = new QName ("", CLASS_NAME); 34 private static final QName DESCRIPTION_QNAME = new QName ("", DESCRIPTION); 35 private static final QName ATTRIBUTES_QNAME = new QName ("", ATTRIBUTES); 36 private static final QName CONSTRUCTORS_QNAME = new QName ("", CONSTRUCTORS); 37 private static final QName OPERATIONS_QNAME = new QName ("", OPERATIONS); 38 private static final QName NOTIFICATIONS_QNAME = new QName ("", NOTIFICATIONS); 39 40 public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException 41 { 42 MBeanInfo info = (MBeanInfo )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 writeSchema(Class javaType, Types types) throws Exception 54 { 55 Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE); 56 complexType.setAttribute("name", TYPE); 57 Element allElement = types.createElement(SCHEMA_ALL); 58 complexType.appendChild(allElement); 59 60 Element 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 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 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 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 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 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 |