KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > web > taglib > MBeanNameTag


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.web.taglib;
14
15
16
17 import javax.servlet.jsp.JspException JavaDoc;
18
19 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
20
21
22
23 import org.apache.struts.util.RequestUtils;
24
25 import org.apache.struts.util.ResponseUtils;
26
27 import org.ejtools.jmx.browser.model.Node;
28
29 import org.ejtools.jmx.browser.model.Resource;
30
31
32
33 /**
34
35  * Description of the Class
36
37  *
38
39  * @author letiemble
40
41  * @created 25 avril 2002
42
43  * @version $Revision: 1.6 $
44
45  * @todo Javadoc to complete
46
47  * @jsp:tag name="mbeanName" body-content="empty"
48
49  */

50
51 public class MBeanNameTag extends TagSupport JavaDoc
52
53 {
54
55    /** Filter the rendered output for characters that are sensitive in HTML? */
56
57    protected boolean filter = true;
58
59    /** Should we ignore missing beans and simply output nothing? */
60
61    protected boolean full = true;
62
63    /** Should we ignore missing beans and simply output nothing? */
64
65    protected boolean ignore = false;
66
67    /** Name of the bean that contains the data we will be rendering. */
68
69    protected String JavaDoc name = null;
70
71    /** The scope to be searched to retrieve the specified bean. */
72
73    protected String JavaDoc scope = null;
74
75
76
77
78
79    /**
80
81     * Description of the Method
82
83     *
84
85     * @return Description of the Returned Value
86
87     * @exception JspException Description of the Exception
88
89     */

90
91    public int doStartTag()
92
93       throws JspException JavaDoc
94
95    {
96
97       String JavaDoc output = "";
98
99
100
101       // Look up the requested bean (if necessary)
102

103       Node node = (Node) RequestUtils.lookup(pageContext, name, scope);
104
105
106
107       if (ignore)
108
109       {
110
111          if (node == null)
112
113          {
114
115             return (SKIP_BODY);
116
117          }
118
119          // Nothing to output
120

121       }
122
123
124
125       if (node instanceof Resource)
126
127       {
128
129          Resource res = (Resource) node;
130
131          output = res.getCanonicalName();
132
133
134
135          if (!full)
136
137          {
138
139             output = output.substring(res.getDomain().length() + 1);
140
141          }
142
143       }
144
145       else
146
147       {
148
149          output = node.toString();
150
151       }
152
153
154
155       if (filter)
156
157       {
158
159          ResponseUtils.write(pageContext, ResponseUtils.filter(output));
160
161       }
162
163       else
164
165       {
166
167          ResponseUtils.write(pageContext, output);
168
169       }
170
171
172
173       // Continue processing this page
174

175       return (SKIP_BODY);
176
177    }
178
179
180
181
182
183    /**
184
185     * Getter for the filter attribute
186
187     *
188
189     * @return The value of filter attribute
190
191     * @jsp:attribute name="filter" required="false" rtexprvalue="true"
192
193     */

194
195    public boolean getFilter()
196
197    {
198
199       return (this.filter);
200
201    }
202
203
204
205
206
207    /**
208
209     * Gets the full attribute of the MBeanNameTag object
210
211     *
212
213     * @return The full value
214
215     * @jsp:attribute name="full" required="false" rtexprvalue="true"
216
217     */

218
219    public boolean getFull()
220
221    {
222
223       return (this.full);
224
225    }
226
227
228
229
230
231    /**
232
233     * Getter for the ignore attribute
234
235     *
236
237     * @return The value of ignore attribute
238
239     * @jsp:attribute name="ignore" required="false" rtexprvalue="true"
240
241     */

242
243    public boolean getIgnore()
244
245    {
246
247       return (this.ignore);
248
249    }
250
251
252
253
254
255    /**
256
257     * Getter for the name attribute
258
259     *
260
261     * @return The value of name attribute
262
263     * @jsp:attribute name="name" required="true" rtexprvalue="true"
264
265     */

266
267    public String JavaDoc getName()
268
269    {
270
271       return (this.name);
272
273    }
274
275
276
277
278
279    /**
280
281     * Getter for the scope attribute
282
283     *
284
285     * @return The value of scope attribute
286
287     * @jsp:attribute name="scope" required="false" rtexprvalue="true"
288
289     */

290
291    public String JavaDoc getScope()
292
293    {
294
295       return (this.scope);
296
297    }
298
299
300
301
302
303    /** Release all allocated resources. */
304
305    public void release()
306
307    {
308
309       super.release();
310
311       filter = true;
312
313       ignore = false;
314
315       full = false;
316
317       name = null;
318
319       scope = null;
320
321    }
322
323
324
325
326
327    /**
328
329     * Setter for the filter attribute
330
331     *
332
333     * @param filter The new filter value
334
335     */

336
337    public void setFilter(boolean filter)
338
339    {
340
341       this.filter = filter;
342
343    }
344
345
346
347
348
349    /**
350
351     * Sets the full attribute of the MBeanNameTag object
352
353     *
354
355     * @param full The new full value
356
357     */

358
359    public void setFull(boolean full)
360
361    {
362
363       this.full = full;
364
365    }
366
367
368
369
370
371    /**
372
373     * Setter for the ignore attribute
374
375     *
376
377     * @param ignore The new ignore value
378
379     */

380
381    public void setIgnore(boolean ignore)
382
383    {
384
385       this.ignore = ignore;
386
387    }
388
389
390
391
392
393    /**
394
395     * Setter for the name attribute
396
397     *
398
399     * @param name The new name value
400
401     */

402
403    public void setName(String JavaDoc name)
404
405    {
406
407       this.name = name;
408
409    }
410
411
412
413
414
415    /**
416
417     * Setter for the scope attribute
418
419     *
420
421     * @param scope The new scope value
422
423     */

424
425    public void setScope(String JavaDoc scope)
426
427    {
428
429       this.scope = scope;
430
431    }
432
433 }
434
435
436
437
Popular Tags