KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > mbean > View


1 /*
2
3  * EJTools, the Enterprise Java Tools
4
5  *
6
7  * Distributable under LGPL license.
8
9  * See terms of license at www.gnu.org.
10
11  */

12
13 package org.ejtools.jmx.browser.mbean;
14
15
16
17 import java.beans.beancontext.BeanContextSupport JavaDoc;
18
19 import java.util.Collection JavaDoc;
20
21 import java.util.Iterator JavaDoc;
22
23 import java.util.Vector JavaDoc;
24
25
26
27 import javax.management.MBeanFeatureInfo JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30
31
32
33 import org.apache.log4j.Logger;
34
35 import org.ejtools.beans.Sort;
36
37 import org.ejtools.jmx.MBeanAccessor;
38
39
40
41
42
43 /**
44
45  * Description of the Class
46
47  *
48
49  * @author letiemble
50
51  * @created 13 décembre 2001
52
53  * @version $Revision: 1.6 $
54
55  * @todo Javadoc to complete
56
57  */

58
59 public class View extends BeanContextSupport JavaDoc
60
61 {
62
63    /** Description of the Field */
64
65    protected String JavaDoc displayName = "<undefined>";
66
67    /** Description of the Field */
68
69    protected String JavaDoc name = "<undefined>";
70
71    /** Description of the Field */
72
73    private static Logger logger = Logger.getLogger(View.class);
74
75    /** Description of the Field */
76
77    public final static int ATTRIBUTE_TYPE = 0;
78
79    /** Description of the Field */
80
81    public final static int OPERATION_TYPE = 1;
82
83
84
85
86
87    /** Constructor */
88
89    public View() { }
90
91
92
93
94
95    /**
96
97     * Adds a feature to the AttributeLine attribute of the View object
98
99     *
100
101     * @param objectName The feature to be added to the AttributeLine attribute
102
103     * @param name The feature to be added to the AttributeLine attribute
104
105     */

106
107    public void addAttributeLine(ObjectName JavaDoc objectName, String JavaDoc name)
108
109    {
110
111       ViewLine line = new ViewLine();
112
113       line.setType(View.ATTRIBUTE_TYPE);
114
115       line.setObjectName(objectName);
116
117       line.setName(name);
118
119       add(line);
120
121       logger.debug("Atrribute Line added (" + objectName + " => " + name + ")");
122
123    }
124
125
126
127
128
129    /**
130
131     * Adds a feature to the AttributeLine attribute of the View object
132
133     *
134
135     * @param expression The feature to be added to the AttributeLine attribute
136
137     * @param name The feature to be added to the AttributeLine attribute
138
139     */

140
141    public void addAttributeLine(String JavaDoc expression, String JavaDoc name)
142
143    {
144
145       try
146
147       {
148
149          ObjectName JavaDoc objectName = new ObjectName JavaDoc(expression);
150
151          addAttributeLine(objectName, name);
152
153       }
154
155       catch (Exception JavaDoc e)
156
157       {
158
159          logger.error("Exception while creating Attribute Line : " + e.getMessage());
160
161       }
162
163    }
164
165
166
167
168
169    /**
170
171     * Adds a feature to the AttributeResult attribute of the View object
172
173     *
174
175     * @param accessor The feature to be added to the AttributeResult attribute
176
177     * @param info The feature to be added to the AttributeResult attribute
178
179     */

180
181    public void addAttributeResult(MBeanAccessor accessor, MBeanFeatureInfo JavaDoc info)
182
183    {
184
185       ResultLine line = new ResultLine();
186
187       line.setType(View.ATTRIBUTE_TYPE);
188
189       line.setAccessor(accessor);
190
191       line.setInfo(info);
192
193       add(line);
194
195       logger.debug("Atrribute Result added (" + accessor + " => " + info + ")");
196
197    }
198
199
200
201
202
203    /**
204
205     * Adds a feature to the OperationLine attribute of the View object
206
207     *
208
209     * @param objectName The feature to be added to the OperationLine attribute
210
211     * @param name The feature to be added to the OperationLine attribute
212
213     */

214
215    public void addOperationLine(ObjectName JavaDoc objectName, String JavaDoc name)
216
217    {
218
219       ViewLine line = new ViewLine();
220
221       line.setType(View.OPERATION_TYPE);
222
223       line.setObjectName(objectName);
224
225       line.setName(name);
226
227       add(line);
228
229       logger.debug("Operation Line added (" + objectName + " => " + name + ")");
230
231    }
232
233
234
235
236
237    /**
238
239     * Adds a feature to the OperationLine attribute of the View object
240
241     *
242
243     * @param expression The feature to be added to the OperationLine attribute
244
245     * @param name The feature to be added to the OperationLine attribute
246
247     */

248
249    public void addOperationLine(String JavaDoc expression, String JavaDoc name)
250
251    {
252
253       try
254
255       {
256
257          ObjectName JavaDoc objectName = new ObjectName JavaDoc(expression);
258
259          addOperationLine(objectName, name);
260
261       }
262
263       catch (Exception JavaDoc e)
264
265       {
266
267          logger.error("Exception while creating Operation Line : " + e.getMessage());
268
269       }
270
271    }
272
273
274
275
276
277    /**
278
279     * Adds a feature to the OperationResult attribute of the View object
280
281     *
282
283     * @param accessor The feature to be added to the OperationResult attribute
284
285     * @param info The feature to be added to the OperationResult attribute
286
287     */

288
289    public void addOperationResult(MBeanAccessor accessor, MBeanFeatureInfo JavaDoc info)
290
291    {
292
293       ResultLine line = new ResultLine();
294
295       line.setType(View.OPERATION_TYPE);
296
297       line.setAccessor(accessor);
298
299       line.setInfo(info);
300
301       add(line);
302
303       logger.debug("Operation Result added (" + accessor + " => " + info + ")");
304
305    }
306
307
308
309
310
311    /**
312
313     * Gets the attributeLines attribute of the View object
314
315     *
316
317     * @return The attributeLines value
318
319     */

320
321    public Collection JavaDoc getAttributeLines()
322
323    {
324
325       Vector JavaDoc result = new Vector JavaDoc();
326
327       Iterator JavaDoc iterator = Sort.getChildrenByClass(iterator(), ViewLine.class);
328
329       while (iterator.hasNext())
330
331       {
332
333          ViewLine line = (ViewLine) iterator.next();
334
335          if (line.getType() == View.ATTRIBUTE_TYPE)
336
337          {
338
339             result.add(line);
340
341          }
342
343       }
344
345       return result;
346
347    }
348
349
350
351
352
353    /**
354
355     * Gets the attributeResults attribute of the View object
356
357     *
358
359     * @return The attributeResults value
360
361     */

362
363    public Collection JavaDoc getAttributeResults()
364
365    {
366
367       Vector JavaDoc result = new Vector JavaDoc();
368
369       Iterator JavaDoc iterator = Sort.getChildrenByClass(iterator(), ResultLine.class);
370
371       while (iterator.hasNext())
372
373       {
374
375          ResultLine line = (ResultLine) iterator.next();
376
377          if (line.getType() == View.ATTRIBUTE_TYPE)
378
379          {
380
381             result.add(line);
382
383          }
384
385       }
386
387       return result;
388
389    }
390
391
392
393
394
395    /**
396
397     * Gets the displayName attribute of the View object
398
399     *
400
401     * @return The displayName value
402
403     */

404
405    public String JavaDoc getDisplayName()
406
407    {
408
409       return this.displayName;
410
411    }
412
413
414
415
416
417    /**
418
419     * Gets the name attribute of the View object
420
421     *
422
423     * @return The name value
424
425     */

426
427    public String JavaDoc getName()
428
429    {
430
431       return this.name;
432
433    }
434
435
436
437
438
439    /**
440
441     * Gets the operationLines attribute of the View object
442
443     *
444
445     * @return The operationLines value
446
447     */

448
449    public Collection JavaDoc getOperationLines()
450
451    {
452
453       Vector JavaDoc result = new Vector JavaDoc();
454
455       Iterator JavaDoc iterator = Sort.getChildrenByClass(iterator(), ViewLine.class);
456
457       while (iterator.hasNext())
458
459       {
460
461          ViewLine line = (ViewLine) iterator.next();
462
463          if (line.getType() == View.OPERATION_TYPE)
464
465          {
466
467             result.add(line);
468
469          }
470
471       }
472
473       return result;
474
475    }
476
477
478
479
480
481    /**
482
483     * Gets the operationResults attribute of the View object
484
485     *
486
487     * @return The operationResults value
488
489     */

490
491    public Collection JavaDoc getOperationResults()
492
493    {
494
495       Vector JavaDoc result = new Vector JavaDoc();
496
497       Iterator JavaDoc iterator = Sort.getChildrenByClass(iterator(), ResultLine.class);
498
499       while (iterator.hasNext())
500
501       {
502
503          ResultLine line = (ResultLine) iterator.next();
504
505          if (line.getType() == View.OPERATION_TYPE)
506
507          {
508
509             result.add(line);
510
511          }
512
513       }
514
515       return result;
516
517    }
518
519
520
521
522
523    /**
524
525     * Description of the Method
526
527     *
528
529     * @return Description of the Return Value
530
531     */

532
533    public Iterator JavaDoc iterator()
534
535    {
536
537       return Sort.sortByName(super.iterator());
538
539    }
540
541
542
543
544
545
546
547    /**
548
549     * Sets the displayName attribute of the View object
550
551     *
552
553     * @param displayName The new displayName value
554
555     */

556
557    public void setDisplayName(String JavaDoc displayName)
558
559    {
560
561       this.displayName = displayName;
562
563    }
564
565
566
567
568
569    /**
570
571     * Sets the name attribute of the View object
572
573     *
574
575     * @param name The new name value
576
577     */

578
579    public void setName(String JavaDoc name)
580
581    {
582
583       this.name = name;
584
585    }
586
587
588
589
590
591    /**
592
593     * Description of the Method
594
595     *
596
597     * @return Description of the Return Value
598
599     */

600
601    public String JavaDoc toString()
602
603    {
604
605       return this.displayName;
606
607    }
608
609 }
610
611
Popular Tags