KickJava   Java API By Example, From Geeks To Geeks.

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


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.management.MBeanAttributeInfo JavaDoc;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22
23
24
25 import org.apache.struts.util.MessageResources;
26
27 import org.apache.struts.util.RequestUtils;
28
29 import org.apache.struts.util.ResponseUtils;
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="mbeanAttributeAccess" body-content="empty"
48
49  */

50
51 public class MBeanAttributeAccessTag 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 ignore = false;
62
63    /** Name of the bean that contains the data we will be rendering. */
64
65    protected String JavaDoc name = null;
66
67    /** The scope to be searched to retrieve the specified bean. */
68
69    protected String JavaDoc scope = null;
70
71    /** Description of the Field */
72
73    private static MessageResources messages = MessageResources.getMessageResources("org.ejtools.jmx.browser.web.taglib.MBeanAttributeInfoAccess");
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       // Look up the requested bean (if necessary)
98

99       MBeanAttributeInfo JavaDoc info = (MBeanAttributeInfo JavaDoc) RequestUtils.lookup(pageContext, name, scope);
100
101       if (ignore)
102
103       {
104
105          if (info == null)
106
107          {
108
109             return (SKIP_BODY);
110
111          }
112
113          // Nothing to output
114

115       }
116
117
118
119       String JavaDoc output = computeAccess(info);
120
121       if (filter)
122
123       {
124
125          ResponseUtils.write(pageContext, ResponseUtils.filter(output));
126
127       }
128
129       else
130
131       {
132
133          ResponseUtils.write(pageContext, output);
134
135       }
136
137
138
139       // Continue processing this page
140

141       return (SKIP_BODY);
142
143    }
144
145
146
147
148
149    /**
150
151     * Getter for the filter attribute
152
153     *
154
155     * @return The value of filter attribute
156
157     * @jsp:attribute name="filter" required="false" rtexprvalue="true"
158
159     */

160
161    public boolean getFilter()
162
163    {
164
165       return (this.filter);
166
167    }
168
169
170
171
172
173    /**
174
175     * Getter for the ignore attribute
176
177     *
178
179     * @return The value of ignore attribute
180
181     * @jsp:attribute name="ignore" required="false" rtexprvalue="true"
182
183     */

184
185    public boolean getIgnore()
186
187    {
188
189       return (this.ignore);
190
191    }
192
193
194
195
196
197    /**
198
199     * Getter for the name attribute
200
201     *
202
203     * @return The value of name attribute
204
205     * @jsp:attribute name="name" required="true" rtexprvalue="true"
206
207     */

208
209    public String JavaDoc getName()
210
211    {
212
213       return (this.name);
214
215    }
216
217
218
219
220
221    /**
222
223     * Getter for the scope attribute
224
225     *
226
227     * @return The value of scope attribute
228
229     * @jsp:attribute name="scope" required="false" rtexprvalue="true"
230
231     */

232
233    public String JavaDoc getScope()
234
235    {
236
237       return (this.scope);
238
239    }
240
241
242
243
244
245    /** Release all allocated resources. */
246
247    public void release()
248
249    {
250
251
252
253       super.release();
254
255       filter = true;
256
257       ignore = false;
258
259       name = null;
260
261       scope = null;
262
263
264
265    }
266
267
268
269
270
271    /**
272
273     * Setter for the filter attribute
274
275     *
276
277     * @param filter The new filter value
278
279     */

280
281    public void setFilter(boolean filter)
282
283    {
284
285       this.filter = filter;
286
287    }
288
289
290
291
292
293    /**
294
295     * Setter for the ignore attribute
296
297     *
298
299     * @param ignore The new ignore value
300
301     */

302
303    public void setIgnore(boolean ignore)
304
305    {
306
307       this.ignore = ignore;
308
309    }
310
311
312
313
314
315    /**
316
317     * Setter for the name attribute
318
319     *
320
321     * @param name The new name value
322
323     */

324
325    public void setName(String JavaDoc name)
326
327    {
328
329       this.name = name;
330
331    }
332
333
334
335
336
337    /**
338
339     * Setter for the scope attribute
340
341     *
342
343     * @param scope The new scope value
344
345     */

346
347    public void setScope(String JavaDoc scope)
348
349    {
350
351       this.scope = scope;
352
353    }
354
355
356
357
358
359    /**
360
361     * Description of the Method
362
363     *
364
365     * @param info Description of the Parameter
366
367     * @return Description of the Returned Value
368
369     */

370
371    protected String JavaDoc computeAccess(MBeanAttributeInfo JavaDoc info)
372
373    {
374
375       String JavaDoc result = messages.getMessage("access.ro");
376
377
378
379       if (info.isIs() || info.isReadable())
380
381       {
382
383          if (info.isWritable())
384
385          {
386
387             result = messages.getMessage("access.rw");
388
389          }
390
391       }
392
393       else
394
395       {
396
397          if (info.isWritable())
398
399          {
400
401             result = messages.getMessage("access.wo");
402
403          }
404
405       }
406
407
408
409       return result;
410
411    }
412
413 }
414
415
416
417
Popular Tags