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 javax.management.remote.TargetedNotification;
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: /**
22: * @version $Revision: 1.4 $
23: */
24: public class TargetedNotificationSer extends AxisSerializer {
25: static final String NOTIFICATION = "notification";
26: static final String LISTENER_ID = "listenerID";
27: private static final QName NOTIFICATION_QNAME = new QName("",
28: NOTIFICATION);
29: private static final QName LISTENER_ID_QNAME = new QName("",
30: LISTENER_ID);
31: static final String TYPE = "TargetedNotification";
32:
33: public void serialize(QName name, Attributes attributes,
34: Object value, SerializationContext context)
35: throws IOException {
36: TargetedNotification targetedNotification = (TargetedNotification) value;
37: context.startElement(name, attributes);
38: context.serialize(NOTIFICATION_QNAME, null,
39: targetedNotification.getNotification());
40: context.serialize(LISTENER_ID_QNAME, null, targetedNotification
41: .getListenerID());
42: context.endElement();
43: }
44:
45: public Element writeSchema(Class aClass, Types types)
46: throws Exception {
47: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
48: complexType.setAttribute("name", TYPE);
49: Element allElement = types.createElement(SCHEMA_ALL);
50: complexType.appendChild(allElement);
51:
52: Element typeElement = types.createElement(SCHEMA_ELEMENT);
53: typeElement.setAttribute("name", NOTIFICATION);
54: typeElement.setAttribute("type", NotificationSer.TYPE);
55: allElement.appendChild(typeElement);
56:
57: Element sourceElement = types.createElement(SCHEMA_ELEMENT);
58: sourceElement.setAttribute("name", LISTENER_ID);
59: sourceElement.setAttribute("type", XMLType.XSD_INT
60: .getLocalPart());
61: allElement.appendChild(sourceElement);
62:
63: return complexType;
64: }
65: }
|