1 8 13 14 package org.webjmx.tags; 15 16 import java.io.*; 17 import javax.management.*; 18 import javax.servlet.jsp.*; 19 import javax.servlet.jsp.tagext.*; 20 21 26 public class GetMBeanInfoTag extends TagSupport 27 implements JMXTaglibConstants 28 { 29 30 private String id; 31 32 33 private String server; 34 35 36 private String name; 37 38 39 public GetMBeanInfoTag() 40 { } 41 42 44 public int doStartTag() 45 throws JspException 46 { 47 Object o = pageContext.getAttribute(server); 48 if(o == null ||!(o instanceof MBeanServer)) 49 throw new JspException("GetMBeanInfoTag requires type MBeanServer, Illegal server: " +o.getClass()); 50 MBeanServer s = (MBeanServer)o; 51 o = pageContext.getAttribute(name); 52 if(o == null) 53 { 54 try{ o = new ObjectName(name); } 55 catch(MalformedObjectNameException mex) { throw new JspException(mex.toString()); } 56 }else if(!(o instanceof ObjectName)) 57 throw new JspException("GetMBeanInfoTag requires type ObjectName, Illegal name: " +o); 58 ObjectName n = (ObjectName)o; 59 try 60 { 61 MBeanInfo mbi = s.getMBeanInfo(n); 62 if(mbi != null) 63 pageContext.setAttribute(id, mbi); 64 }catch(Exception ex) { ex.printStackTrace(); } 65 return (SKIP_BODY); 66 } 67 68 71 public String getId() 72 { 73 return id; 74 } 75 76 79 public void setId(String id) 80 { 81 this.id = id; 82 } 83 84 87 public String getServer() 88 { 89 return server; 90 } 91 92 95 public void setServer(String server) 96 { 97 this.server = server; 98 } 99 100 103 public String getName() 104 { 105 return name; 106 } 107 108 111 public void setName(String name) 112 { 113 this.name = name; 114 } 115 116 119 public void release() 120 { 121 name = id = server = null; 122 } 123 } 124 | Popular Tags |