| 102 |
|
public void run() { |
| 103 |
|
HashMap hostList = new HashMap(); |
| 104 |
|
try { |
| 105 |
< |
_data.start(); |
| 106 |
< |
while(true) { |
| 107 |
< |
synchronized (_data) { |
| 108 |
< |
_data.wait(); |
| 105 |
> |
_data.start(); |
| 106 |
> |
while(true) { |
| 107 |
> |
synchronized (_data) { |
| 108 |
> |
_data.wait(); |
| 109 |
> |
} |
| 110 |
> |
String xml = _data.getXML(); |
| 111 |
> |
if (xml == null) { |
| 112 |
> |
// shouldn't really happen...but not sure |
| 113 |
> |
_status.setText("No XML to update..."); |
| 114 |
> |
} else { |
| 115 |
> |
_status.setText("Got inbound data...handling"); |
| 116 |
> |
// Get a string without any null characters in it. |
| 117 |
> |
// -- maybe String.trim() would be better here ? |
| 118 |
> |
if (xml.indexOf(0) != -1) { |
| 119 |
> |
xml = xml.substring(0, xml.indexOf(0)); |
| 120 |
> |
} |
| 121 |
> |
else { |
| 122 |
> |
xml = xml.substring(0, xml.length()); |
| 123 |
> |
} |
| 124 |
> |
|
| 125 |
> |
// Use XMLPacketMaker to make an XMLPacket object. |
| 126 |
> |
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
| 127 |
> |
XMLPacket packet = xmlPacketMaker.createXMLPacket(); |
| 128 |
> |
String hostName = packet.getParam("packet.attributes.machine_name"); |
| 129 |
> |
if(!hostList.containsKey(hostName)) { |
| 130 |
> |
host = new HostDisplayPanel(); |
| 131 |
> |
_tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName); |
| 132 |
> |
hostList.put(hostName, host); |
| 133 |
> |
_status.setText("New Host added: " + hostName); |
| 134 |
> |
} |
| 135 |
> |
((HostDisplayPanel) hostList.get(hostName)).updateHost(packet); |
| 136 |
> |
} |
| 137 |
|
} |
| 110 |
– |
String xml = _data.getXML(); |
| 111 |
– |
if (xml == null) { |
| 112 |
– |
_status.setText("No XML to update..."); |
| 113 |
– |
} else { |
| 114 |
– |
|
| 115 |
– |
// Get a string without any null characters in it. |
| 116 |
– |
// -- maybe String.trim() would be better here ? |
| 117 |
– |
if (xml.indexOf(0) != -1) { |
| 118 |
– |
xml = xml.substring(0, xml.indexOf(0)); |
| 119 |
– |
} |
| 120 |
– |
else { |
| 121 |
– |
xml = xml.substring(0, xml.length()); |
| 122 |
– |
} |
| 123 |
– |
|
| 124 |
– |
// Use XMLPacketMaker to make an XMLPacket object. |
| 125 |
– |
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
| 126 |
– |
XMLPacket packet = xmlPacketMaker.createXMLPacket(); |
| 127 |
– |
String hostName = packet.getParam("packet.attributes.machine_name"); |
| 128 |
– |
if(!hostList.containsKey(hostName)) { |
| 129 |
– |
host = new HostDisplayPanel(); |
| 130 |
– |
_tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName); |
| 131 |
– |
hostList.put(hostName, host); |
| 132 |
– |
_status.setText("New Host added: " + hostName); |
| 133 |
– |
} |
| 134 |
– |
((HostDisplayPanel) hostList.get(hostName)).updateHost(packet); |
| 135 |
– |
} |
| 136 |
– |
} |
| 138 |
|
} catch (Exception e) { |
| 139 |
|
System.err.println("ERROR RUN: " + e); |
| 140 |
|
} |