1 8 9 package mx4j.tools.remote.soap.axis.ser; 10 11 import java.io.IOException ; 12 import java.util.Iterator ; 13 import javax.management.ObjectName ; 14 import javax.management.relation.Role ; 15 import javax.xml.namespace.QName ; 16 17 import org.apache.axis.Constants; 18 import org.apache.axis.encoding.SerializationContext; 19 import org.apache.axis.encoding.XMLType; 20 import org.apache.axis.wsdl.fromJava.Types; 21 import org.w3c.dom.Element ; 22 import org.xml.sax.Attributes ; 23 24 27 public class RoleSer extends AxisSerializer 28 { 29 static final String TYPE = "Role"; 30 static final String ROLE_NAME = "roleName"; 31 static final String ROLE_VALUE = "roleValue"; 32 protected static final QName ROLE_NAME_QNAME = new QName ("", ROLE_NAME); 33 protected static final QName ROLE_VALUE_QNAME = new QName ("", ROLE_VALUE); 34 35 36 public void serialize(QName name, Attributes attributes, Object value, 37 SerializationContext context) 38 throws IOException 39 { 40 Role role = (Role )value; 41 context.startElement(name, attributes); 42 context.serialize(ROLE_NAME_QNAME, null, role.getRoleName()); 43 for (Iterator i = role.getRoleValue().iterator(); i.hasNext();) 44 { 45 ObjectName on = (ObjectName )i.next(); 46 context.serialize(Constants.QNAME_LITERAL_ITEM, null, on); 47 } 48 context.endElement(); 49 } 50 51 public Element writeSchema(Class aClass, Types types) throws Exception 52 { 53 Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE); 54 complexType.setAttribute("name", TYPE); 55 56 Element nameElement = types.createElement(SCHEMA_ELEMENT); 57 nameElement.setAttribute("name", ROLE_NAME); 58 nameElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart()); 59 complexType.appendChild(nameElement); 60 61 types.writeSchemaElement(Constants.SOAP_VECTOR, complexType); 62 Element sequence = types.createElement(SCHEMA_SEQUENCE); 63 complexType.appendChild(sequence); 64 Element element = types.createElement(SCHEMA_ELEMENT); 65 element.setAttribute("name", Constants.QNAME_LITERAL_ITEM.getLocalPart()); 66 element.setAttribute("minOccurs", "0"); 67 element.setAttribute("maxOccurs", "unbounded"); 68 element.setAttribute("type", AttributeSer.TYPE); 69 sequence.appendChild(element); 70 return complexType; 71 } 72 73 } 74 | Popular Tags |