1 12 13 package org.ejtools.jmx.browser.web.taglib; 14 15 16 17 import javax.management.MBeanAttributeInfo ; 18 19 import javax.servlet.jsp.JspException ; 20 21 import javax.servlet.jsp.tagext.TagSupport ; 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 50 51 public class MBeanAttributeAccessTag extends TagSupport 52 53 { 54 55 56 57 protected boolean filter = true; 58 59 60 61 protected boolean ignore = false; 62 63 64 65 protected String name = null; 66 67 68 69 protected String scope = null; 70 71 72 73 private static MessageResources messages = MessageResources.getMessageResources("org.ejtools.jmx.browser.web.taglib.MBeanAttributeInfoAccess"); 74 75 76 77 78 79 90 91 public int doStartTag() 92 93 throws JspException 94 95 { 96 97 99 MBeanAttributeInfo info = (MBeanAttributeInfo ) 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 115 } 116 117 118 119 String 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 141 return (SKIP_BODY); 142 143 } 144 145 146 147 148 149 160 161 public boolean getFilter() 162 163 { 164 165 return (this.filter); 166 167 } 168 169 170 171 172 173 184 185 public boolean getIgnore() 186 187 { 188 189 return (this.ignore); 190 191 } 192 193 194 195 196 197 208 209 public String getName() 210 211 { 212 213 return (this.name); 214 215 } 216 217 218 219 220 221 232 233 public String getScope() 234 235 { 236 237 return (this.scope); 238 239 } 240 241 242 243 244 245 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 280 281 public void setFilter(boolean filter) 282 283 { 284 285 this.filter = filter; 286 287 } 288 289 290 291 292 293 302 303 public void setIgnore(boolean ignore) 304 305 { 306 307 this.ignore = ignore; 308 309 } 310 311 312 313 314 315 324 325 public void setName(String name) 326 327 { 328 329 this.name = name; 330 331 } 332 333 334 335 336 337 346 347 public void setScope(String scope) 348 349 { 350 351 this.scope = scope; 352 353 } 354 355 356 357 358 359 370 371 protected String computeAccess(MBeanAttributeInfo info) 372 373 { 374 375 String 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 |