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 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: /**
25: * @version $Revision: 1.3 $
26: */
27: public class RoleSer extends AxisSerializer {
28: static final String TYPE = "Role";
29: static final String ROLE_NAME = "roleName";
30: static final String ROLE_VALUE = "roleValue";
31: protected static final QName ROLE_NAME_QNAME = new QName("",
32: ROLE_NAME);
33: protected static final QName ROLE_VALUE_QNAME = new QName("",
34: ROLE_VALUE);
35:
36: public void serialize(QName name, Attributes attributes,
37: Object value, SerializationContext context)
38: throws IOException {
39: Role role = (Role) value;
40: context.startElement(name, attributes);
41: context.serialize(ROLE_NAME_QNAME, null, role.getRoleName());
42: for (Iterator i = role.getRoleValue().iterator(); i.hasNext();) {
43: ObjectName on = (ObjectName) i.next();
44: context.serialize(Constants.QNAME_LITERAL_ITEM, null, on);
45: }
46: context.endElement();
47: }
48:
49: public Element writeSchema(Class aClass, Types types)
50: throws Exception {
51: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
52: complexType.setAttribute("name", TYPE);
53:
54: Element nameElement = types.createElement(SCHEMA_ELEMENT);
55: nameElement.setAttribute("name", ROLE_NAME);
56: nameElement.setAttribute("type", XMLType.XSD_STRING
57: .getLocalPart());
58: complexType.appendChild(nameElement);
59:
60: types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
61: Element sequence = types.createElement(SCHEMA_SEQUENCE);
62: complexType.appendChild(sequence);
63: Element element = types.createElement(SCHEMA_ELEMENT);
64: element.setAttribute("name", Constants.QNAME_LITERAL_ITEM
65: .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: }
|