KickJava   Java API By Example, From Geeks To Geeks.

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


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.lang.reflect.Constructor JavaDoc;
12 import java.security.AccessController JavaDoc;
13 import java.security.PrivilegedActionException JavaDoc;
14 import java.security.PrivilegedExceptionAction JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16 import javax.management.monitor.MonitorNotification JavaDoc;
17
18 import org.xml.sax.SAXException JavaDoc;
19
20 /**
21  * @version $Revision: 1.4 $
22  */

23 public class MonitorNotificationDeser extends NotificationDeser
24 {
25    private ObjectName JavaDoc monitoredName;
26    private String JavaDoc monitoredAttribute;
27    private Object JavaDoc gaugeValue;
28    private Object JavaDoc triggerValue;
29
30    public void onSetChildValue(Object JavaDoc value, Object JavaDoc hint) throws SAXException JavaDoc
31    {
32       super.onSetChildValue(value, hint);
33       if (MonitorNotificationSer.DERIVED_GAUGE.equals(hint))
34          gaugeValue = value;
35       else if (MonitorNotificationSer.OBSERVED_ATTRIBUTE.equals(hint))
36          monitoredAttribute = (String JavaDoc)value;
37       else if (MonitorNotificationSer.OBSERVED_OBJECT.equals(hint))
38          monitoredName = (ObjectName JavaDoc)value;
39       else if (MonitorNotificationSer.TRIGGER.equals(hint)) triggerValue = value;
40    }
41
42    protected Object JavaDoc createObject() throws SAXException JavaDoc
43    {
44       // MonitorNotification's constructor is package private:
45
// MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String message, ObjectName monitoredName, String attribute, Object gauge, Object trigger)
46
try
47       {
48          return AccessController.doPrivileged(new PrivilegedExceptionAction JavaDoc()
49          {
50             public Object JavaDoc run() throws Exception JavaDoc
51             {
52                Constructor JavaDoc ctor = MonitorNotification JavaDoc.class.getDeclaredConstructor(new Class JavaDoc[]{String JavaDoc.class, Object JavaDoc.class, long.class, long.class, String JavaDoc.class, ObjectName JavaDoc.class, String JavaDoc.class, Object JavaDoc.class, Object JavaDoc.class});
53                // Necessary to invoke package-level constructor
54
ctor.setAccessible(true);
55                return ctor.newInstance(new Object JavaDoc[]{getType(), getSource(), new Long JavaDoc(getSequenceNumber()), new Long JavaDoc(getTimeStamp()), getMessage(), monitoredName, monitoredAttribute, gaugeValue, triggerValue});
56             }
57          });
58       }
59       catch (PrivilegedActionException JavaDoc x)
60       {
61          throw new SAXException JavaDoc(x.getException());
62       }
63    }
64 }
65
Popular Tags