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 |
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.
Definition at line 79 of file JmxNotification.java.
|
Create a new JmxNotification object
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 }
|
|
Used as a factory to create an instance of this class from a xml document
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 }
|
|
Parse the given xml to create a notification
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 }
|
|
Return the controller jmx name
Definition at line 201 of file JmxNotification.java. 00202 { 00203 return getMbeanServerIP() + ":" + getMbeanServerPort(); 00204 }
|
|
Definition at line 191 of file JmxNotification.java. 00192 {
00193 return controllerName;
00194 }
|
|
Definition at line 169 of file JmxNotification.java. 00170 {
00171 return dataList;
00172 }
|
|
Returns the first value of an entry in the data list of values
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 }
|
|
Definition at line 217 of file JmxNotification.java. 00218 {
00219 return description;
00220 }
|
|
Definition at line 233 of file JmxNotification.java. 00234 {
00235 return mbeanClass;
00236 }
|
|
Definition at line 249 of file JmxNotification.java. 00250 {
00251 return mbeanName;
00252 }
|
|
Definition at line 265 of file JmxNotification.java. 00266 {
00267 return mbeanServerIP;
00268 }
|
|
Definition at line 281 of file JmxNotification.java. 00282 {
00283 return mbeanServerPort;
00284 }
|
|
Definition at line 297 of file JmxNotification.java. 00298 {
00299 return priority;
00300 }
|
|
Definition at line 313 of file JmxNotification.java. 00314 {
00315 return sequence;
00316 }
|
|
Definition at line 476 of file JmxNotification.java. 00477 {
00478 return time;
00479 }
|
|
Definition at line 329 of file JmxNotification.java. Referenced by org.objectweb.cjdbc.console.gui.CjdbcGuiListener.handleNotification(). 00330 {
00331 return type;
00332 }
|
|
Definition at line 209 of file JmxNotification.java. 00210 {
00211 this.controllerName = controllerName;
00212 }
|
|
Definition at line 492 of file JmxNotification.java. References org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.dataList. 00493 {
00494 this.dataList = dataList;
00495 }
|
|
Definition at line 225 of file JmxNotification.java. 00226 {
00227 this.description = description;
00228 }
|
|
Definition at line 241 of file JmxNotification.java. 00242 {
00243 this.mbeanClass = mbeanClass;
00244 }
|
|
Definition at line 257 of file JmxNotification.java. 00258 {
00259 this.mbeanName = mbeanName;
00260 }
|
|
Definition at line 273 of file JmxNotification.java. 00274 {
00275 this.mbeanServerIP = mbeanServerIP;
00276 }
|
|
Definition at line 289 of file JmxNotification.java. 00290 {
00291 this.mbeanServerPort = mbeanServerPort;
00292 }
|
|
Definition at line 305 of file JmxNotification.java. 00306 {
00307 this.priority = priority;
00308 }
|
|
Definition at line 321 of file JmxNotification.java. 00322 {
00323 this.sequence = sequence;
00324 }
|
|
Definition at line 484 of file JmxNotification.java. References org.objectweb.cjdbc.common.jmx.notifications.JmxNotification.time. 00485 {
00486 this.time = time;
00487 }
|
|
Definition at line 337 of file JmxNotification.java. 00338 {
00339 this.type = type;
00340 }
|
|
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 }
|
|
Convert the object to the corresponding xml document instance
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 }
|