Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.common.jmx.notifications.JmxNotification Class Reference

List of all members.

Public Member Functions

 JmxNotification (String priority, String sequence, String type, String description, String time, String controllerName, String mbeanClass, String mbeanName, String mbeanServerIP, String mbeanServerPort, Hashtable dataList)
Hashtable getDataList ()
String getDataValue (String key)
String getControllerName ()
String getControllerJmxName ()
void setControllerName (String controllerName)
String getDescription ()
void setDescription (String description)
String getMbeanClass ()
void setMbeanClass (String mbeanClass)
String getMbeanName ()
void setMbeanName (String mbeanName)
String getMbeanServerIP ()
void setMbeanServerIP (String mbeanServerIP)
String getMbeanServerPort ()
void setMbeanServerPort (String mbeanServerPort)
String getPriority ()
void setPriority (String priority)
String getSequence ()
void setSequence (String sequence)
String getType ()
void setType (String type)
Document toXmlDocument ()
String toString ()
String getTime ()
void setTime (String time)
void setDataList (Hashtable dataList)

Static Public Member Functions

JmxNotification createNotificationFromXmlString (String xml) throws Exception
JmxNotification createNotificationFromXml (Document document)

Package Attributes

String priority
String sequence
String type
String description
String controllerName
String mbeanClass
String mbeanName
String mbeanServerIP
String mbeanServerPort
String time
Hashtable dataList

Detailed Description

This class defines a JmxNotification class. This class is used by the RmiConnector on the controller to send a JMXNotification. This is done by the following code:

 JmxNotification cjdbcNotification = new JmxNotification(priority,
                                       "" + sequence, type, description, ""
                                           + time, controllerName, mbean
                                           .getClass().getName(), "mbeanName",
                                       hostName, "" + port, data);
 

This create an instance of this JmxNotification class, specific to CJDBC. We then create a new instance of the Notification object as specified in the javax.management package

 Notification notification = new Notification(type, mbean, sequence, myDate
     .getTime(), description);
 

This class accepts a userData object. We wanted to set this user object to a specific CJDBC class but this forces generic JMX client to have this class in their classpath. We just serialize the JmxNotification into an XML string and feed it in the notification.

 notification.setUserData(cjdbcNotification.toString());
 

This can be retrieved on any jmx client, and on C-JDBC specific clients, the xml is transformed into an instance of this class again for easier notification handling.

Author:
Nicolas Modrzyk

Definition at line 79 of file JmxNotification.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.JmxNotification String  priority,
String  sequence,
String  type,
String  description,
String  time,
String  controllerName,
String  mbeanClass,
String  mbeanName,
String  mbeanServerIP,
String  mbeanServerPort,
Hashtable  dataList
 

Create a new JmxNotification object

Parameters:
priority notification priority
sequence sequence number
type notification type
description notification description
time time the notification was issued
controllerName name of the controller issuing the notification
mbeanClass class of the mbean issuing the notification
mbeanName name of the mbean issuing the notification
mbeanServerIP IP address of the mbean
mbeanServerPort Port of the mbean
dataList Additional data

Definition at line 130 of file JmxNotification.java.

00134   {
00135     this.priority = priority;
00136     this.sequence = sequence;
00137     this.type = type;
00138     this.description = description;
00139     this.controllerName = controllerName;
00140     this.mbeanClass = mbeanClass;
00141     this.mbeanName = mbeanName;
00142     this.mbeanServerIP = mbeanServerIP;
00143     this.mbeanServerPort = mbeanServerPort;
00144     this.time = time;
00145     this.dataList = dataList;
00146   }


Member Function Documentation

JmxNotification org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.createNotificationFromXml Document  document  )  [static]
 

Used as a factory to create an instance of this class from a xml document

Parameters:
document a dom4j document
Returns:
an instance of this class with the corresponding parameters

Definition at line 348 of file JmxNotification.java.

00349   {
00350     String priority = document.selectSingleNode(
00351         "//" + ELT_jmxevent + "/" + ELT_info + "/" + ELT_priority).getText();
00352     String sequence = document.selectSingleNode(
00353         "//" + ELT_jmxevent + "/" + ELT_info + "/" + ELT_sequence).getText();
00354     String type = document.selectSingleNode(
00355         "//" + ELT_jmxevent + "/" + ELT_info + "/" + ELT_type).getText();
00356     String description = document.selectSingleNode(
00357         "//" + ELT_jmxevent + "/" + ELT_info + "/" + ELT_description).getText();
00358     String time = document.selectSingleNode(
00359         "//" + ELT_jmxevent + "/" + ELT_info + "/" + ELT_time).getText();
00360 
00361     String controllerName = document.selectSingleNode(
00362         "//" + ELT_jmxevent + "/" + ELT_source + "/" + ELT_controller)
00363         .getText();
00364     String mbeanclass = document.selectSingleNode(
00365         "//" + ELT_jmxevent + "/" + ELT_source + "/" + ELT_mbean + "/"
00366             + ELT_class).getText();
00367     String mbeanname = document.selectSingleNode(
00368         "//" + ELT_jmxevent + "/" + ELT_source + "/" + ELT_mbean).valueOf(
00369         "@" + ATT_name);
00370     String serverip = document.selectSingleNode(
00371         "//" + ELT_jmxevent + "/" + ELT_source + "/" + ELT_mbean + "/"
00372             + ELT_server).valueOf("@" + ATT_ip);
00373     String serverport = document.selectSingleNode(
00374         "//" + ELT_jmxevent + "/" + ELT_source + "/" + ELT_mbean + "/"
00375             + ELT_server).valueOf("@" + ATT_port);
00376 
00377     Element root = document.getRootElement();
00378 
00379     Hashtable dataList = new Hashtable();
00380     for (Iterator i = root.elementIterator(ELT_data); i.hasNext();)
00381     {
00382       Element data = (Element) i.next();
00383       ArrayList list = new ArrayList();
00384       for (Iterator j = data.elementIterator(ELT_value); j.hasNext();)
00385       {
00386         Element value = (Element) j.next();
00387         list.add(value.getTextTrim());
00388       }
00389       dataList.put(data.valueOf("@" + ATT_name), list);
00390     }
00391     JmxNotification notif = new JmxNotification(priority, sequence, type,
00392         description, time, controllerName, mbeanclass, mbeanname, serverip,
00393         serverport, dataList);
00394     return notif;
00395   }

JmxNotification org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.createNotificationFromXmlString String  xml  )  throws Exception [static]
 

Parse the given xml to create a notification

Parameters:
xml the xml to use to create a JmxNotification instance
Returns:
a JmxNotification instance which xml version is that of the given xml arg
Exceptions:
Exception if cannot create an instance (the xml is invalid)

Definition at line 157 of file JmxNotification.java.

00159   {
00160     StringReader sreader = new StringReader(xml);
00161     SAXReader reader = new SAXReader();
00162     Document document = reader.read(sreader);
00163     return createNotificationFromXml(document);
00164   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getControllerJmxName  ) 
 

Return the controller jmx name

Returns:
IP:Port

Definition at line 201 of file JmxNotification.java.

00202   {
00203     return getMbeanServerIP() + ":" + getMbeanServerPort();
00204   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getControllerName  ) 
 

Returns:
Returns the controllerName.

Definition at line 191 of file JmxNotification.java.

00192   {
00193     return controllerName;
00194   }

Hashtable org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getDataList  ) 
 

Returns:
Returns the dataList.

Definition at line 169 of file JmxNotification.java.

00170   {
00171     return dataList;
00172   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getDataValue String  key  ) 
 

Returns the first value of an entry in the data list of values

Parameters:
key value of a data parameter in the list
Returns:
String value of the corresponding key

Definition at line 180 of file JmxNotification.java.

00181   {
00182     if (!dataList.containsKey(key))
00183       return null;
00184     else
00185       return (String) ((ArrayList) dataList.get(key)).get(0);
00186   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getDescription  ) 
 

Returns:
Returns the description.

Definition at line 217 of file JmxNotification.java.

00218   {
00219     return description;
00220   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getMbeanClass  ) 
 

Returns:
Returns the mbeanClass.

Definition at line 233 of file JmxNotification.java.

00234   {
00235     return mbeanClass;
00236   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getMbeanName  ) 
 

Returns:
Returns the mbeanName.

Definition at line 249 of file JmxNotification.java.

00250   {
00251     return mbeanName;
00252   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getMbeanServerIP  ) 
 

Returns:
Returns the mbeanServerIP.

Definition at line 265 of file JmxNotification.java.

00266   {
00267     return mbeanServerIP;
00268   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getMbeanServerPort  ) 
 

Returns:
Returns the mbeanServerPort.

Definition at line 281 of file JmxNotification.java.

00282   {
00283     return mbeanServerPort;
00284   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getPriority  ) 
 

Returns:
Returns the priority.

Definition at line 297 of file JmxNotification.java.

00298   {
00299     return priority;
00300   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getSequence  ) 
 

Returns:
Returns the sequence.

Definition at line 313 of file JmxNotification.java.

00314   {
00315     return sequence;
00316   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getTime  ) 
 

Returns:
Returns the time.

Definition at line 476 of file JmxNotification.java.

00477   {
00478     return time;
00479   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.getType  ) 
 

Returns:
Returns the type.

Definition at line 329 of file JmxNotification.java.

Referenced by org.objectweb.cjdbc.console.gui.CjdbcGuiListener.handleNotification().

00330   {
00331     return type;
00332   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setControllerName String  controllerName  ) 
 

Parameters:
controllerName The controllerName to set.

Definition at line 209 of file JmxNotification.java.

00210   {
00211     this.controllerName = controllerName;
00212   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setDataList Hashtable  dataList  ) 
 

Parameters:
dataList The dataList to set.

Definition at line 492 of file JmxNotification.java.

References org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.dataList.

00493   {
00494     this.dataList = dataList;
00495   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setDescription String  description  ) 
 

Parameters:
description The description to set.

Definition at line 225 of file JmxNotification.java.

00226   {
00227     this.description = description;
00228   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setMbeanClass String  mbeanClass  ) 
 

Parameters:
mbeanClass The mbeanClass to set.

Definition at line 241 of file JmxNotification.java.

00242   {
00243     this.mbeanClass = mbeanClass;
00244   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setMbeanName String  mbeanName  ) 
 

Parameters:
mbeanName The mbeanName to set.

Definition at line 257 of file JmxNotification.java.

00258   {
00259     this.mbeanName = mbeanName;
00260   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setMbeanServerIP String  mbeanServerIP  ) 
 

Parameters:
mbeanServerIP The mbeanServerIP to set.

Definition at line 273 of file JmxNotification.java.

00274   {
00275     this.mbeanServerIP = mbeanServerIP;
00276   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setMbeanServerPort String  mbeanServerPort  ) 
 

Parameters:
mbeanServerPort The mbeanServerPort to set.

Definition at line 289 of file JmxNotification.java.

00290   {
00291     this.mbeanServerPort = mbeanServerPort;
00292   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setPriority String  priority  ) 
 

Parameters:
priority The priority to set.

Definition at line 305 of file JmxNotification.java.

00306   {
00307     this.priority = priority;
00308   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setSequence String  sequence  ) 
 

Parameters:
sequence The sequence to set.

Definition at line 321 of file JmxNotification.java.

00322   {
00323     this.sequence = sequence;
00324   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setTime String  time  ) 
 

Parameters:
time The time to set.

Definition at line 484 of file JmxNotification.java.

References org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.time.

00485   {
00486     this.time = time;
00487   }

void org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.setType String  type  ) 
 

Parameters:
type The type to set.

Definition at line 337 of file JmxNotification.java.

00338   {
00339     this.type = type;
00340   }

String org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.toString  ) 
 

Returns:
String version in xml formatted text

Definition at line 457 of file JmxNotification.java.

Referenced by org.objectweb.cjdbc.console.gui.CjdbcGuiListener.handleNotification().

00458   {
00459     StringWriter swriter = new StringWriter();
00460     OutputFormat format = OutputFormat.createCompactFormat();
00461     XMLWriter writer = new XMLWriter(swriter, format);
00462     try
00463     {
00464       writer.write(toXmlDocument());
00465     }
00466     catch (IOException e)
00467     {
00468       // ignore
00469     }
00470     return swriter.getBuffer().toString();
00471   }

Document org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.toXmlDocument  ) 
 

Convert the object to the corresponding xml document instance

Returns:
Document object with the proper values

Definition at line 402 of file JmxNotification.java.

00403   {
00404     Document document = DocumentHelper.createDocument();
00405     Element root = document.addElement(ELT_jmxevent);
00406 
00407     // Describe info
00408     Element info = root.addElement(ELT_info);
00409     info.addElement(ELT_priority).addText(priority);
00410     info.addElement(ELT_sequence).addText(sequence);
00411     info.addElement(ELT_type).addText(type);
00412     info.addElement(ELT_description).addText(description);
00413     info.addElement(ELT_time).addText(time);
00414 
00415     // Describe source
00416     Element source = root.addElement(ELT_source);
00417     source.addElement(ELT_controller).addText(controllerName);
00418 
00419     // Describe mbean
00420     Element mbean = source.addElement(ELT_mbean).addAttribute(ATT_name,
00421         mbeanName);
00422     mbean.addElement(ELT_class).addText(mbeanClass);
00423     mbean.addElement(ELT_server).addAttribute(ATT_ip, mbeanServerIP)
00424         .addAttribute(ATT_port, mbeanServerPort);
00425 
00426     // Describe data
00427     Enumeration keys = dataList.keys();
00428     while (keys.hasMoreElements())
00429     {
00430       String key = (String) keys.nextElement();
00431       Element data = root.addElement(ELT_data).addAttribute(ATT_name, key);
00432 
00433       Object entry = dataList.get(key);
00434       if (entry instanceof ArrayList)
00435       {
00436         ArrayList list = (ArrayList) entry;
00437         for (int i = 0; i < list.size(); i++)
00438           data.addElement(ELT_value).addText((String) list.get(i));
00439       }
00440       else if (entry instanceof String[])
00441       {
00442         String[] list = (String[]) entry;
00443         for (int i = 0; i < list.length; i++)
00444           data.addElement(ELT_value).addText(list[i]);
00445       }
00446       else if (entry instanceof String)
00447       {
00448         data.addElement(ELT_value).addText((String) entry);
00449       }
00450     }
00451     return document;
00452   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:01:42 2005 for C-JDBC by  doxygen 1.3.9.1