1 19 20 package org.netbeans.modules.web.monitor.data; 21 22 import org.w3c.dom.*; 23 import org.xml.sax.InputSource ; 24 import org.netbeans.modules.schema2beans.*; 25 import java.beans.*; 26 import java.util.*; 27 import java.io.*; 28 import org.netbeans.modules.web.monitor.client.TransactionNode; 29 30 public class DispatchData extends BaseBean implements DataRecord { 31 32 private final static boolean debug = false; 33 34 static Vector comparators = new Vector(); 35 36 static public final String CLIENTDATA = "ClientData"; static public final String SESSIONDATA = "SessionData"; static public final String COOKIESDATA = "CookiesData"; static public final String REQUESTDATA = "RequestData"; static public final String SERVLETDATA = "ServletData"; static public final String CONTEXTDATA = "ContextData"; static public final String ENGINEDATA = "EngineData"; static public final String DISPATCHES = "Dispatches"; 45 public DispatchData() { 46 this(Common.USE_DEFAULT_VALUES); 47 } 48 49 public DispatchData(int options) { 50 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 0, 6)); 51 this.createProperty("ClientData", CLIENTDATA, Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 53 ClientData.class); 54 this.createAttribute(CLIENTDATA, "protocol", "Protocol", AttrProp.CDATA | AttrProp.REQUIRED, 56 null, null); 57 this.createAttribute(CLIENTDATA, "remoteAddress", "RemoteAddress", AttrProp.CDATA | AttrProp.REQUIRED, 59 null, null); 60 this.createAttribute(CLIENTDATA, "software", "Software", AttrProp.CDATA | AttrProp.IMPLIED, 62 null, null); 63 this.createAttribute(CLIENTDATA, "locale", "Locale", AttrProp.CDATA | AttrProp.IMPLIED, 65 null, null); 66 this.createAttribute(CLIENTDATA, "formatsAccepted", "FormatsAccepted", AttrProp.CDATA | AttrProp.IMPLIED, 68 null, null); 69 this.createAttribute(CLIENTDATA, "encodingsAccepted", "EncodingsAccepted", AttrProp.CDATA | AttrProp.IMPLIED, 71 null, null); 72 this.createAttribute(CLIENTDATA, "charsetsAccepted", "CharsetsAccepted", AttrProp.CDATA | AttrProp.IMPLIED, 74 null, null); 75 this.createProperty("SessionData", SESSIONDATA, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 77 SessionData.class); 78 this.createAttribute(SESSIONDATA, "before", "Before", AttrProp.ENUM | AttrProp.REQUIRED, 80 new String [] { 81 "false", "true" }, "false"); this.createAttribute(SESSIONDATA, "after", "After", AttrProp.ENUM | AttrProp.REQUIRED, 86 new String [] { 87 "false", "true" }, "false"); this.createAttribute(SESSIONDATA, "id", "Id", AttrProp.CDATA | AttrProp.IMPLIED, 92 null, null); 93 this.createAttribute(SESSIONDATA, "created", "Created", AttrProp.CDATA | AttrProp.IMPLIED, 95 null, null); 96 this.createProperty("CookiesData", COOKIESDATA, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 98 CookiesData.class); 99 100 this.createProperty("RequestData", REQUESTDATA, Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 105 RequestData.class); 106 this.createAttribute(REQUESTDATA, "uri", "Uri", AttrProp.CDATA | AttrProp.REQUIRED, 108 null, null); 109 this.createAttribute(REQUESTDATA, "method", "Method", AttrProp.CDATA | AttrProp.REQUIRED, 111 null, null); 112 this.createAttribute(REQUESTDATA, "urlencoded", "Urlencoded", AttrProp.CDATA | AttrProp.IMPLIED, 114 null, null); 115 this.createAttribute(REQUESTDATA, "queryString", "QueryString", AttrProp.CDATA | AttrProp.IMPLIED, 117 null, null); 118 this.createAttribute(REQUESTDATA, "replace", "Replace", AttrProp.CDATA | AttrProp.IMPLIED, 120 null, null); 121 this.createAttribute(REQUESTDATA, "protocol", "Protocol", AttrProp.CDATA | AttrProp.IMPLIED, 123 null, null); 124 this.createAttribute(REQUESTDATA, "ipaddress", "Ipaddress", AttrProp.CDATA | AttrProp.IMPLIED, 126 null, null); 127 this.createAttribute(REQUESTDATA, "scheme", "Scheme", AttrProp.CDATA | AttrProp.IMPLIED, 129 null, null); 130 this.createAttribute(REQUESTDATA, "status", "Status", AttrProp.CDATA | AttrProp.IMPLIED, 132 null, null); 133 134 this.createProperty("ServletData", SERVLETDATA, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 136 ServletData.class); 137 this.createAttribute(SERVLETDATA, "name", "Name", AttrProp.CDATA | AttrProp.IMPLIED, 139 null, null); 140 this.createAttribute(SERVLETDATA, "className", "ClassName", AttrProp.CDATA | AttrProp.IMPLIED, 142 null, null); 143 this.createAttribute(SERVLETDATA, "packageName", "PackageName", AttrProp.CDATA | AttrProp.IMPLIED, 145 null, null); 146 this.createAttribute(SERVLETDATA, "servletInfo", "ServletInfo", AttrProp.CDATA | AttrProp.IMPLIED, 148 null, null); 149 this.createAttribute(SERVLETDATA, "relPath", "RelPath", AttrProp.CDATA | AttrProp.IMPLIED, 151 null, null); 152 this.createAttribute(SERVLETDATA, "transPath", "TransPath", AttrProp.CDATA | AttrProp.IMPLIED, 154 null, null); 155 this.createAttribute(SERVLETDATA, "contextName", "ContextName", AttrProp.CDATA | AttrProp.IMPLIED, 157 null, null); 158 this.createAttribute(SERVLETDATA, "absPath", "AbsPath", AttrProp.CDATA | AttrProp.IMPLIED, 160 null, null); 161 this.createAttribute(SERVLETDATA, "jre", "Jre", AttrProp.CDATA | AttrProp.IMPLIED, 163 null, null); 164 this.createAttribute(SERVLETDATA, "platform", "Platform", AttrProp.CDATA | AttrProp.IMPLIED, 166 null, null); 167 this.createAttribute(SERVLETDATA, "serverPort", "ServerPort", AttrProp.NMTOKEN | AttrProp.IMPLIED, 169 null, null); 170 this.createAttribute(SERVLETDATA, "serverName", "ServerName", AttrProp.CDATA | AttrProp.IMPLIED, 172 null, null); 173 174 this.createAttribute(SERVLETDATA, "collected", "Collected", AttrProp.CDATA | AttrProp.IMPLIED, 176 null, null); 177 178 this.createProperty("ContextData", CONTEXTDATA, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 180 ContextData.class); 181 this.createAttribute(CONTEXTDATA, "contextName", "ContextName", AttrProp.CDATA | AttrProp.IMPLIED, 183 null, null); 184 this.createAttribute(CONTEXTDATA, "absPath", "AbsPath", AttrProp.CDATA | AttrProp.IMPLIED, 186 null, null); 187 188 this.createProperty("EngineData", ENGINEDATA, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 190 EngineData.class); 191 192 this.createAttribute(ENGINEDATA, "jre", "Jre", AttrProp.CDATA | AttrProp.IMPLIED, 194 null, null); 195 this.createAttribute(ENGINEDATA, "platform", "Platform", AttrProp.CDATA | AttrProp.IMPLIED, 197 null, null); 198 this.createAttribute(ENGINEDATA, "serverPort", "ServerPort", AttrProp.NMTOKEN | AttrProp.IMPLIED, 200 null, null); 201 this.createAttribute(ENGINEDATA, "serverName", "ServerName", AttrProp.CDATA | AttrProp.IMPLIED, 203 null, null); 204 this.createProperty("Dispatches", DISPATCHES, Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 206 Dispatches.class); 207 208 209 this.initialize(options); 210 } 211 212 void initialize(int options) { 214 } 215 216 public void setClientData(ClientData value) { 218 this.setValue(CLIENTDATA, value); 219 } 220 221 public ClientData getClientData() { 223 return (ClientData)this.getValue(CLIENTDATA); 224 } 225 226 public void setSessionData(SessionData value) { 228 this.setValue(SESSIONDATA, value); 229 } 230 231 public SessionData getSessionData() { 233 return (SessionData)this.getValue(SESSIONDATA); 234 } 235 236 public void setCookiesData(CookiesData value) { 238 this.setValue(COOKIESDATA, value); 239 } 240 241 public CookiesData getCookiesData() { 243 return (CookiesData)this.getValue(COOKIESDATA); 244 } 245 246 public void setDispatches(Dispatches value) { 248 this.setValue(DISPATCHES, value); 249 } 250 251 public Dispatches getDispatches() { 253 if(debug) System.out.println("Running getDispatches"); return (Dispatches)this.getValue(DISPATCHES); 255 } 256 257 public void setRequestData(RequestData value) { 259 this.setValue(REQUESTDATA, value); 260 } 261 262 public RequestData getRequestData() { 264 return (RequestData)this.getValue(REQUESTDATA); 265 } 266 267 public void setServletData(ServletData value) { 269 this.setValue(SERVLETDATA, value); 270 } 271 272 public ServletData getServletData() { 274 return (ServletData)this.getValue(SERVLETDATA); 275 } 276 277 public void setEngineData(EngineData value) { 279 this.setValue(ENGINEDATA, value); 280 } 281 282 public EngineData getEngineData() { 284 return (EngineData)this.getValue(ENGINEDATA); 285 } 286 287 public void setContextData(ContextData value) { 289 this.setValue(CONTEXTDATA, value); 290 } 291 292 public ContextData getContextData() { 294 return (ContextData)this.getValue(CONTEXTDATA); 295 } 296 297 public boolean verify() { 299 return true; 300 } 301 302 public String getServerAndPort() 303 { 304 String server = null; 305 String port = null; 306 307 try { 308 server = getEngineData().getAttributeValue("serverName"); port = getEngineData().getAttributeValue("serverPort"); return server.concat(":").concat(port); } 312 catch(NullPointerException npe) { 313 } 314 315 server = getServletData().getAttributeValue("serverName"); port = getServletData().getAttributeValue("serverPort"); return server.concat(":").concat(port); } 320 321 322 public String getServerName() { 323 324 try { 325 return getEngineData().getAttributeValue("serverName"); } 327 catch(NullPointerException npe) { 328 } 329 330 return getServletData().getAttributeValue("serverName"); } 333 334 public int getServerPort() { 335 336 String portS = null; 337 try { 338 portS = getEngineData().getAttributeValue("serverPort"); } 340 catch(NullPointerException npe) { 341 } 342 if(portS == null) 343 portS = getServletData().getAttributeValue("serverPort"); return Integer.parseInt(portS); 345 } 346 347 348 public String getServerPortAsString() { 349 350 String portS = null; 351 try { 352 portS = getEngineData().getAttributeValue("serverPort"); } 354 catch(NullPointerException npe) { 355 } 356 if(portS == null) 357 portS = getServletData().getAttributeValue("serverPort"); return portS; 359 360 361 } 362 363 364 public void setServerName(String server) { 365 366 try { 367 getEngineData().setAttributeValue("serverName", server); return; 369 } 370 catch(NullPointerException npe) { 371 } 372 373 try { 374 getServletData().getAttributeValue("serverName, server"); return; 376 } 377 catch(NullPointerException npe) { 378 } 379 } 380 381 public void setServerPort(int port) { 382 383 try { 384 getEngineData().setAttributeValue("serverPort", String.valueOf(port)); 386 return; 387 } 388 catch(NullPointerException npe) { 389 } 390 391 392 try { 393 getServletData().setAttributeValue("serverPort", String.valueOf(port)); 395 return; 396 } 397 catch(NullPointerException npe) { 398 } 399 } 400 401 public void setServerPort(String port) { 402 403 try { 404 getEngineData().setAttributeValue("serverPort", port); 406 return; 407 } 408 catch(NullPointerException npe) { 409 } 410 411 412 try { 413 getServletData().setAttributeValue("serverPort", port); 415 return; 416 } 417 catch(NullPointerException npe) { 418 } 419 } 420 421 422 static public void addComparator(BeanComparator c) { 424 MonitorData.comparators.add(c); 425 } 426 427 static public void removeComparator(BeanComparator c) { 429 MonitorData.comparators.remove(c); 430 } 431 public void addPropertyChangeListener(PropertyChangeListener l) { 433 BeanProp p = this.beanProp(); 434 if (p != null) 435 p.addPCListener(l); 436 } 437 438 public void removePropertyChangeListener(PropertyChangeListener l) { 440 BeanProp p = this.beanProp(); 441 if (p != null) 442 p.removePCListener(l); 443 } 444 445 public void addPropertyChangeListener(String n, PropertyChangeListener l){ 447 BeanProp p = this.beanProp(n); 448 if (p != null) 449 p.addPCListener(l); 450 } 451 452 public void removePropertyChangeListener(String n, 454 PropertyChangeListener l) { 455 BeanProp p = this.beanProp(n); 456 if (p != null) 457 p.removePCListener(l); 458 } 459 460 461 public void dump(StringBuffer str, String indent) { 463 String s; 464 BaseBean n; 465 str.append(indent); 466 str.append("ClientData"); n = this.getClientData(); 468 if (n != null) 469 n.dump(str, indent + "\t"); else 471 str.append(indent+"\tnull"); this.dumpAttributes(CLIENTDATA, 0, str, indent); 473 474 str.append(indent); 475 str.append("SessionData"); n = this.getSessionData(); 477 if (n != null) 478 n.dump(str, indent + "\t"); else 480 str.append(indent+"\tnull"); this.dumpAttributes(SESSIONDATA, 0, str, indent); 482 483 str.append(indent); 484 str.append("CookiesData"); n = this.getCookiesData(); 486 if (n != null) 487 n.dump(str, indent + "\t"); else 489 str.append(indent+"\tnull"); this.dumpAttributes(COOKIESDATA, 0, str, indent); 491 492 str.append(indent); 493 str.append("RequestData"); n = this.getRequestData(); 495 if (n != null) 496 n.dump(str, indent + "\t"); else 498 str.append(indent+"\tnull"); this.dumpAttributes(REQUESTDATA, 0, str, indent); 500 501 str.append(indent); 502 str.append("ServletData"); n = this.getServletData(); 504 if (n != null) 505 n.dump(str, indent + "\t"); else 507 str.append(indent+"\tnull"); this.dumpAttributes(SERVLETDATA, 0, str, indent); 509 510 str.append("ContextData"); n = this.getContextData(); 512 if (n != null) 513 n.dump(str, indent + "\t"); else 515 str.append(indent+"\tnull"); this.dumpAttributes(CONTEXTDATA, 0, str, indent); 517 518 str.append(indent); 519 str.append("Dispatches"); n = this.getDispatches(); 521 if (n != null) 522 n.dump(str, indent + "\t"); else 524 str.append(indent+"\tnull"); this.dumpAttributes(DISPATCHES, 0, str, indent); 526 } 527 528 public String dumpBeanNode() { 529 StringBuffer str = new StringBuffer (); 530 str.append("MonitorData\n"); this.dump(str, "\n "); return str.toString(); 533 } 534 } 535 | Popular Tags |