KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > data > DispatchData


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.monitor.data;
21
22 import org.w3c.dom.*;
23 import org.xml.sax.InputSource JavaDoc;
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 JavaDoc CLIENTDATA = "ClientData"; // NOI18N
37
static public final String JavaDoc SESSIONDATA = "SessionData"; // NOI18N
38
static public final String JavaDoc COOKIESDATA = "CookiesData"; // NOI18N
39
static public final String JavaDoc REQUESTDATA = "RequestData"; // NOI18N
40
static public final String JavaDoc SERVLETDATA = "ServletData"; // NOI18N
41
static public final String JavaDoc CONTEXTDATA = "ContextData"; // NOI18N
42
static public final String JavaDoc ENGINEDATA = "EngineData"; // NOI18N
43
static public final String JavaDoc DISPATCHES = "Dispatches"; // NOI18N
44

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, // NOI18N
52
Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
53                 ClientData.class);
54     this.createAttribute(CLIENTDATA, "protocol", "Protocol", // NOI18N
55
AttrProp.CDATA | AttrProp.REQUIRED,
56                  null, null);
57     this.createAttribute(CLIENTDATA, "remoteAddress", "RemoteAddress", // NOI18N
58
AttrProp.CDATA | AttrProp.REQUIRED,
59                  null, null);
60     this.createAttribute(CLIENTDATA, "software", "Software", // NOI18N
61
AttrProp.CDATA | AttrProp.IMPLIED,
62                  null, null);
63     this.createAttribute(CLIENTDATA, "locale", "Locale", // NOI18N
64
AttrProp.CDATA | AttrProp.IMPLIED,
65                  null, null);
66     this.createAttribute(CLIENTDATA, "formatsAccepted", "FormatsAccepted", // NOI18N
67
AttrProp.CDATA | AttrProp.IMPLIED,
68                  null, null);
69     this.createAttribute(CLIENTDATA, "encodingsAccepted", "EncodingsAccepted", // NOI18N
70
AttrProp.CDATA | AttrProp.IMPLIED,
71                  null, null);
72     this.createAttribute(CLIENTDATA, "charsetsAccepted", "CharsetsAccepted", // NOI18N
73
AttrProp.CDATA | AttrProp.IMPLIED,
74                  null, null);
75     this.createProperty("SessionData", SESSIONDATA, // NOI18N
76
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
77                 SessionData.class);
78     this.createAttribute(SESSIONDATA, "before", "Before", // NOI18N
79
AttrProp.ENUM | AttrProp.REQUIRED,
80                  new String JavaDoc[] {
81                  "false", // NOI18N
82
"true" // NOI18N
83
}, "false"); // NOI18N
84
this.createAttribute(SESSIONDATA, "after", "After", // NOI18N
85
AttrProp.ENUM | AttrProp.REQUIRED,
86                  new String JavaDoc[] {
87                  "false", // NOI18N
88
"true" // NOI18N
89
}, "false"); // NOI18N
90
this.createAttribute(SESSIONDATA, "id", "Id", // NOI18N
91
AttrProp.CDATA | AttrProp.IMPLIED,
92                  null, null);
93     this.createAttribute(SESSIONDATA, "created", "Created", // NOI18N
94
AttrProp.CDATA | AttrProp.IMPLIED,
95                  null, null);
96     this.createProperty("CookiesData", COOKIESDATA, // NOI18N
97
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
98                 CookiesData.class);
99
100     // PENDING - I think I need to move this to the request data
101
// class to make it an independent class that can be handled
102
// on its own (if I want to pass less data about).
103
this.createProperty("RequestData", REQUESTDATA, // NOI18N
104
Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
105                 RequestData.class);
106     this.createAttribute(REQUESTDATA, "uri", "Uri", // NOI18N
107
AttrProp.CDATA | AttrProp.REQUIRED,
108                  null, null);
109     this.createAttribute(REQUESTDATA, "method", "Method", // NOI18N
110
AttrProp.CDATA | AttrProp.REQUIRED,
111                  null, null);
112     this.createAttribute(REQUESTDATA, "urlencoded", "Urlencoded", // NOI18N
113
AttrProp.CDATA | AttrProp.IMPLIED,
114                  null, null);
115     this.createAttribute(REQUESTDATA, "queryString", "QueryString", // NOI18N
116
AttrProp.CDATA | AttrProp.IMPLIED,
117                  null, null);
118     this.createAttribute(REQUESTDATA, "replace", "Replace", // NOI18N
119
AttrProp.CDATA | AttrProp.IMPLIED,
120                  null, null);
121     this.createAttribute(REQUESTDATA, "protocol", "Protocol", // NOI18N
122
AttrProp.CDATA | AttrProp.IMPLIED,
123                  null, null);
124     this.createAttribute(REQUESTDATA, "ipaddress", "Ipaddress", // NOI18N
125
AttrProp.CDATA | AttrProp.IMPLIED,
126                  null, null);
127     this.createAttribute(REQUESTDATA, "scheme", "Scheme", // NOI18N
128
AttrProp.CDATA | AttrProp.IMPLIED,
129                  null, null);
130     this.createAttribute(REQUESTDATA, "status", "Status", // NOI18N
131
AttrProp.CDATA | AttrProp.IMPLIED,
132                  null, null);
133
134     this.createProperty("ServletData", SERVLETDATA, // NOI18N
135
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
136                 ServletData.class);
137     this.createAttribute(SERVLETDATA, "name", "Name", // NOI18N
138
AttrProp.CDATA | AttrProp.IMPLIED,
139                  null, null);
140     this.createAttribute(SERVLETDATA, "className", "ClassName", // NOI18N
141
AttrProp.CDATA | AttrProp.IMPLIED,
142                  null, null);
143     this.createAttribute(SERVLETDATA, "packageName", "PackageName", // NOI18N
144
AttrProp.CDATA | AttrProp.IMPLIED,
145                  null, null);
146     this.createAttribute(SERVLETDATA, "servletInfo", "ServletInfo", // NOI18N
147
AttrProp.CDATA | AttrProp.IMPLIED,
148                  null, null);
149     this.createAttribute(SERVLETDATA, "relPath", "RelPath", // NOI18N
150
AttrProp.CDATA | AttrProp.IMPLIED,
151                  null, null);
152     this.createAttribute(SERVLETDATA, "transPath", "TransPath", // NOI18N
153
AttrProp.CDATA | AttrProp.IMPLIED,
154                  null, null);
155     this.createAttribute(SERVLETDATA, "contextName", "ContextName", // NOI18N
156
AttrProp.CDATA | AttrProp.IMPLIED,
157                  null, null);
158     this.createAttribute(SERVLETDATA, "absPath", "AbsPath", // NOI18N
159
AttrProp.CDATA | AttrProp.IMPLIED,
160                  null, null);
161     this.createAttribute(SERVLETDATA, "jre", "Jre", // NOI18N
162
AttrProp.CDATA | AttrProp.IMPLIED,
163                  null, null);
164     this.createAttribute(SERVLETDATA, "platform", "Platform", // NOI18N
165
AttrProp.CDATA | AttrProp.IMPLIED,
166                  null, null);
167     this.createAttribute(SERVLETDATA, "serverPort", "ServerPort", // NOI18N
168
AttrProp.NMTOKEN | AttrProp.IMPLIED,
169                  null, null);
170     this.createAttribute(SERVLETDATA, "serverName", "ServerName", // NOI18N
171
AttrProp.CDATA | AttrProp.IMPLIED,
172                  null, null);
173
174     this.createAttribute(SERVLETDATA, "collected", "Collected", // NOI18N
175
AttrProp.CDATA | AttrProp.IMPLIED,
176                  null, null);
177
178     this.createProperty("ContextData", CONTEXTDATA, // NOI18N
179
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
180                 ContextData.class);
181     this.createAttribute(CONTEXTDATA, "contextName", "ContextName", // NOI18N
182
AttrProp.CDATA | AttrProp.IMPLIED,
183                  null, null);
184     this.createAttribute(CONTEXTDATA, "absPath", "AbsPath", // NOI18N
185
AttrProp.CDATA | AttrProp.IMPLIED,
186                  null, null);
187
188     this.createProperty("EngineData", ENGINEDATA, // NOI18N
189
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
190                 EngineData.class);
191
192     this.createAttribute(ENGINEDATA, "jre", "Jre", // NOI18N
193
AttrProp.CDATA | AttrProp.IMPLIED,
194                  null, null);
195     this.createAttribute(ENGINEDATA, "platform", "Platform", // NOI18N
196
AttrProp.CDATA | AttrProp.IMPLIED,
197                  null, null);
198     this.createAttribute(ENGINEDATA, "serverPort", "ServerPort", // NOI18N
199
AttrProp.NMTOKEN | AttrProp.IMPLIED,
200                  null, null);
201     this.createAttribute(ENGINEDATA, "serverName", "ServerName", // NOI18N
202
AttrProp.CDATA | AttrProp.IMPLIED,
203                  null, null);
204     this.createProperty("Dispatches", DISPATCHES, // NOI18N
205
Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
206                 Dispatches.class);
207
208
209     this.initialize(options);
210     }
211
212     // Setting the default values of the properties
213
void initialize(int options) {
214     }
215
216     // This attribute is mandatory
217
public void setClientData(ClientData value) {
218     this.setValue(CLIENTDATA, value);
219     }
220
221     //
222
public ClientData getClientData() {
223     return (ClientData)this.getValue(CLIENTDATA);
224     }
225
226     // This attribute is optional
227
public void setSessionData(SessionData value) {
228     this.setValue(SESSIONDATA, value);
229     }
230
231     //
232
public SessionData getSessionData() {
233     return (SessionData)this.getValue(SESSIONDATA);
234     }
235
236     // This attribute is optional
237
public void setCookiesData(CookiesData value) {
238     this.setValue(COOKIESDATA, value);
239     }
240
241     //
242
public CookiesData getCookiesData() {
243     return (CookiesData)this.getValue(COOKIESDATA);
244     }
245
246     // This attribute is optional
247
public void setDispatches(Dispatches value) {
248     this.setValue(DISPATCHES, value);
249     }
250
251     //
252
public Dispatches getDispatches() {
253     if(debug) System.out.println("Running getDispatches"); //NOI18N
254
return (Dispatches)this.getValue(DISPATCHES);
255     }
256
257     // This attribute is mandatory
258
public void setRequestData(RequestData value) {
259     this.setValue(REQUESTDATA, value);
260     }
261
262     //
263
public RequestData getRequestData() {
264     return (RequestData)this.getValue(REQUESTDATA);
265     }
266
267     // This attribute is optional
268
public void setServletData(ServletData value) {
269     this.setValue(SERVLETDATA, value);
270     }
271
272     //
273
public ServletData getServletData() {
274     return (ServletData)this.getValue(SERVLETDATA);
275     }
276
277     // This attribute is optional
278
public void setEngineData(EngineData value) {
279     this.setValue(ENGINEDATA, value);
280     }
281
282     //
283
public EngineData getEngineData() {
284     return (EngineData)this.getValue(ENGINEDATA);
285     }
286
287     // This attribute is optional
288
public void setContextData(ContextData value) {
289     this.setValue(CONTEXTDATA, value);
290     }
291
292     //
293
public ContextData getContextData() {
294     return (ContextData)this.getValue(CONTEXTDATA);
295     }
296
297     // This method verifies that the mandatory properties are set
298
public boolean verify() {
299     return true;
300     }
301
302     public String JavaDoc getServerAndPort()
303     {
304     String JavaDoc server = null;
305     String JavaDoc port = null;
306         
307     try {
308         server = getEngineData().getAttributeValue("serverName"); // NOI18N
309
port = getEngineData().getAttributeValue("serverPort"); // NOI18N
310
return server.concat(":").concat(port); //NOI18N
311
}
312     catch(NullPointerException JavaDoc npe) {
313     }
314         
315     // Backwards compatibility
316
server = getServletData().getAttributeValue("serverName"); // NOI18N
317
port = getServletData().getAttributeValue("serverPort"); // NOI18N
318
return server.concat(":").concat(port); //NOI18N
319
}
320
321
322     public String JavaDoc getServerName() {
323     
324     try {
325         return getEngineData().getAttributeValue("serverName"); // NOI18N
326
}
327     catch(NullPointerException JavaDoc npe) {
328     }
329         
330     // Backwards compatibility
331
return getServletData().getAttributeValue("serverName"); // NOI18N
332
}
333
334     public int getServerPort() {
335     
336     String JavaDoc portS = null;
337     try {
338         portS = getEngineData().getAttributeValue("serverPort"); // NOI18N
339
}
340     catch(NullPointerException JavaDoc npe) {
341     }
342     if(portS == null)
343         portS = getServletData().getAttributeValue("serverPort"); // NOI18N
344
return Integer.parseInt(portS);
345     }
346
347
348     public String JavaDoc getServerPortAsString() {
349     
350     String JavaDoc portS = null;
351     try {
352         portS = getEngineData().getAttributeValue("serverPort"); // NOI18N
353
}
354     catch(NullPointerException JavaDoc npe) {
355     }
356     if(portS == null)
357         portS = getServletData().getAttributeValue("serverPort"); // NOI18N
358
return portS;
359     
360     
361     }
362
363
364     public void setServerName(String JavaDoc server) {
365     
366     try {
367         getEngineData().setAttributeValue("serverName", server); // NOI18N
368
return;
369     }
370     catch(NullPointerException JavaDoc npe) {
371     }
372         
373     try {
374         getServletData().getAttributeValue("serverName, server"); // NOI18N
375
return;
376     }
377     catch(NullPointerException JavaDoc npe) {
378     }
379     }
380
381     public void setServerPort(int port) {
382     
383     try {
384         getEngineData().setAttributeValue("serverPort", // NOI18N
385
String.valueOf(port));
386         return;
387     }
388     catch(NullPointerException JavaDoc npe) {
389     }
390     
391
392     try {
393         getServletData().setAttributeValue("serverPort", // NOI18N
394
String.valueOf(port));
395         return;
396     }
397     catch(NullPointerException JavaDoc npe) {
398     }
399     }
400
401     public void setServerPort(String JavaDoc port) {
402     
403     try {
404         getEngineData().setAttributeValue("serverPort", // NOI18N
405
port);
406         return;
407     }
408     catch(NullPointerException JavaDoc npe) {
409     }
410     
411
412     try {
413         getServletData().setAttributeValue("serverPort", // NOI18N
414
port);
415         return;
416     }
417     catch(NullPointerException JavaDoc npe) {
418     }
419     }
420     
421
422     //
423
static public void addComparator(BeanComparator c) {
424     MonitorData.comparators.add(c);
425     }
426
427     //
428
static public void removeComparator(BeanComparator c) {
429     MonitorData.comparators.remove(c);
430     }
431     //
432
public void addPropertyChangeListener(PropertyChangeListener l) {
433     BeanProp p = this.beanProp();
434     if (p != null)
435         p.addPCListener(l);
436     }
437
438     //
439
public void removePropertyChangeListener(PropertyChangeListener l) {
440     BeanProp p = this.beanProp();
441     if (p != null)
442         p.removePCListener(l);
443     }
444
445     //
446
public void addPropertyChangeListener(String JavaDoc n, PropertyChangeListener l){
447     BeanProp p = this.beanProp(n);
448     if (p != null)
449         p.addPCListener(l);
450     }
451
452     //
453
public void removePropertyChangeListener(String JavaDoc n,
454                          PropertyChangeListener l) {
455     BeanProp p = this.beanProp(n);
456     if (p != null)
457         p.removePCListener(l);
458     }
459
460     
461     // Dump the content of this bean returning it as a String
462
public void dump(StringBuffer JavaDoc str, String JavaDoc indent) {
463     String JavaDoc s;
464     BaseBean n;
465     str.append(indent);
466     str.append("ClientData"); // NOI18N
467
n = this.getClientData();
468     if (n != null)
469         n.dump(str, indent + "\t"); // NOI18N
470
else
471         str.append(indent+"\tnull"); // NOI18N
472
this.dumpAttributes(CLIENTDATA, 0, str, indent);
473
474     str.append(indent);
475     str.append("SessionData"); // NOI18N
476
n = this.getSessionData();
477     if (n != null)
478         n.dump(str, indent + "\t"); // NOI18N
479
else
480         str.append(indent+"\tnull"); // NOI18N
481
this.dumpAttributes(SESSIONDATA, 0, str, indent);
482
483     str.append(indent);
484     str.append("CookiesData"); // NOI18N
485
n = this.getCookiesData();
486     if (n != null)
487         n.dump(str, indent + "\t"); // NOI18N
488
else
489         str.append(indent+"\tnull"); // NOI18N
490
this.dumpAttributes(COOKIESDATA, 0, str, indent);
491
492     str.append(indent);
493     str.append("RequestData"); // NOI18N
494
n = this.getRequestData();
495     if (n != null)
496         n.dump(str, indent + "\t"); // NOI18N
497
else
498         str.append(indent+"\tnull"); // NOI18N
499
this.dumpAttributes(REQUESTDATA, 0, str, indent);
500
501     str.append(indent);
502     str.append("ServletData"); // NOI18N
503
n = this.getServletData();
504     if (n != null)
505         n.dump(str, indent + "\t"); // NOI18N
506
else
507         str.append(indent+"\tnull"); // NOI18N
508
this.dumpAttributes(SERVLETDATA, 0, str, indent);
509
510     str.append("ContextData"); // NOI18N
511
n = this.getContextData();
512     if (n != null)
513         n.dump(str, indent + "\t"); // NOI18N
514
else
515         str.append(indent+"\tnull"); // NOI18N
516
this.dumpAttributes(CONTEXTDATA, 0, str, indent);
517
518     str.append(indent);
519     str.append("Dispatches"); // NOI18N
520
n = this.getDispatches();
521     if (n != null)
522         n.dump(str, indent + "\t"); // NOI18N
523
else
524         str.append(indent+"\tnull"); // NOI18N
525
this.dumpAttributes(DISPATCHES, 0, str, indent);
526     }
527
528     public String JavaDoc dumpBeanNode() {
529     StringBuffer JavaDoc str = new StringBuffer JavaDoc();
530     str.append("MonitorData\n"); // NOI18N
531
this.dump(str, "\n "); // NOI18N
532
return str.toString();
533     }
534 }
535
Popular Tags