KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > soap > axis > ser > MonitorNotificationSer


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.soap.axis.ser;
10
11 import java.io.IOException JavaDoc;
12 import javax.management.Notification JavaDoc;
13 import javax.management.monitor.MonitorNotification JavaDoc;
14 import javax.xml.namespace.QName JavaDoc;
15
16 import org.apache.axis.encoding.SerializationContext;
17 import org.apache.axis.encoding.XMLType;
18 import org.apache.axis.wsdl.fromJava.Types;
19 import org.w3c.dom.Element JavaDoc;
20
21 /**
22  * @version $Revision: 1.4 $
23  */

24 public class MonitorNotificationSer extends NotificationSer
25 {
26    static final String JavaDoc TYPE = "MonitorNotification";
27    static final String JavaDoc DERIVED_GAUGE = "derivedGauge";
28    static final String JavaDoc OBSERVED_ATTRIBUTE = "observedAttribute";
29    static final String JavaDoc OBSERVED_OBJECT = "observedObject";
30    static final String JavaDoc TRIGGER = "trigger";
31    private static final QName JavaDoc DERIVED_GAUGE_QNAME = new QName JavaDoc("", DERIVED_GAUGE);
32    private static final QName JavaDoc OBSERVED_ATTRIBUTE_QNAME = new QName JavaDoc("", OBSERVED_ATTRIBUTE);
33    private static final QName JavaDoc OBSERVED_OBJECT_QNAME = new QName JavaDoc("", OBSERVED_OBJECT);
34    private static final QName JavaDoc TRIGGER_QNAME = new QName JavaDoc("", TRIGGER);
35
36    protected void onSerialize(SerializationContext context, Notification JavaDoc notification) throws IOException JavaDoc
37    {
38       super.onSerialize(context, notification);
39       MonitorNotification JavaDoc monNot = (MonitorNotification JavaDoc)notification;
40       context.serialize(DERIVED_GAUGE_QNAME, null, monNot.getDerivedGauge());
41       context.serialize(OBSERVED_ATTRIBUTE_QNAME, null, monNot.getObservedAttribute());
42       context.serialize(OBSERVED_OBJECT_QNAME, null, monNot.getObservedObject());
43       context.serialize(TRIGGER_QNAME, null, monNot.getTrigger());
44    }
45
46    public Element JavaDoc writeSchema(Class JavaDoc aClass, Types types) throws Exception JavaDoc
47    {
48       Element JavaDoc complexType = super.writeSchema(aClass, types);
49
50       Element JavaDoc derivedGaugeElement = types.createElement(SCHEMA_ELEMENT);
51       derivedGaugeElement.setAttribute("name", DERIVED_GAUGE);
52       derivedGaugeElement.setAttribute("type", XMLType.XSD_ANYTYPE.getLocalPart());
53       complexType.appendChild(derivedGaugeElement);
54
55       Element JavaDoc observedAttElement = types.createElement(SCHEMA_ELEMENT);
56       observedAttElement.setAttribute("name", OBSERVED_ATTRIBUTE);
57       observedAttElement.setAttribute("type", XMLType.XSD_STRING.getLocalPart());
58       complexType.appendChild(observedAttElement);
59
60       Element JavaDoc observedObjectElement = types.createElement(SCHEMA_ELEMENT);
61       observedObjectElement.setAttribute("name", OBSERVED_OBJECT);
62       observedObjectElement.setAttribute("type", ObjectNameSer.TYPE);
63       complexType.appendChild(observedObjectElement);
64
65       Element JavaDoc triggerElement = types.createElement(SCHEMA_ELEMENT);
66       triggerElement.setAttribute("name", TRIGGER);
67       triggerElement.setAttribute("type", XMLType.XSD_ANYTYPE.getLocalPart());
68       complexType.appendChild(triggerElement);
69
70       return complexType;
71    }
72 }
73
Popular Tags