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.Notification;
13: import javax.management.monitor.MonitorNotification;
14: import javax.xml.namespace.QName;
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;
20:
21: /**
22: * @version $Revision: 1.4 $
23: */
24: public class MonitorNotificationSer extends NotificationSer {
25: static final String TYPE = "MonitorNotification";
26: static final String DERIVED_GAUGE = "derivedGauge";
27: static final String OBSERVED_ATTRIBUTE = "observedAttribute";
28: static final String OBSERVED_OBJECT = "observedObject";
29: static final String TRIGGER = "trigger";
30: private static final QName DERIVED_GAUGE_QNAME = new QName("",
31: DERIVED_GAUGE);
32: private static final QName OBSERVED_ATTRIBUTE_QNAME = new QName("",
33: OBSERVED_ATTRIBUTE);
34: private static final QName OBSERVED_OBJECT_QNAME = new QName("",
35: OBSERVED_OBJECT);
36: private static final QName TRIGGER_QNAME = new QName("", TRIGGER);
37:
38: protected void onSerialize(SerializationContext context,
39: Notification notification) throws IOException {
40: super .onSerialize(context, notification);
41: MonitorNotification monNot = (MonitorNotification) notification;
42: context.serialize(DERIVED_GAUGE_QNAME, null, monNot
43: .getDerivedGauge());
44: context.serialize(OBSERVED_ATTRIBUTE_QNAME, null, monNot
45: .getObservedAttribute());
46: context.serialize(OBSERVED_OBJECT_QNAME, null, monNot
47: .getObservedObject());
48: context.serialize(TRIGGER_QNAME, null, monNot.getTrigger());
49: }
50:
51: public Element writeSchema(Class aClass, Types types)
52: throws Exception {
53: Element complexType = super .writeSchema(aClass, types);
54:
55: Element derivedGaugeElement = types
56: .createElement(SCHEMA_ELEMENT);
57: derivedGaugeElement.setAttribute("name", DERIVED_GAUGE);
58: derivedGaugeElement.setAttribute("type", XMLType.XSD_ANYTYPE
59: .getLocalPart());
60: complexType.appendChild(derivedGaugeElement);
61:
62: Element observedAttElement = types
63: .createElement(SCHEMA_ELEMENT);
64: observedAttElement.setAttribute("name", OBSERVED_ATTRIBUTE);
65: observedAttElement.setAttribute("type", XMLType.XSD_STRING
66: .getLocalPart());
67: complexType.appendChild(observedAttElement);
68:
69: Element observedObjectElement = types
70: .createElement(SCHEMA_ELEMENT);
71: observedObjectElement.setAttribute("name", OBSERVED_OBJECT);
72: observedObjectElement.setAttribute("type", ObjectNameSer.TYPE);
73: complexType.appendChild(observedObjectElement);
74:
75: Element triggerElement = types.createElement(SCHEMA_ELEMENT);
76: triggerElement.setAttribute("name", TRIGGER);
77: triggerElement.setAttribute("type", XMLType.XSD_ANYTYPE
78: .getLocalPart());
79: complexType.appendChild(triggerElement);
80:
81: return complexType;
82: }
83: }
|