1 8 13 14 package org.webjmx.tags; 15 16 import java.util.*; 17 import javax.management.*; 18 import javax.servlet.jsp.*; 19 import javax.servlet.jsp.tagext.*; 20 21 import org.webjmx.adapter.*; 22 23 28 public class GetServerTag extends TagSupport 29 implements ILocatorTag, JMXTaglibConstants 30 { 31 32 33 private String id; 34 35 36 private String locator; 37 38 39 private String attribute; 40 41 42 public GetServerTag() 43 { } 44 45 49 public int doStartTag() 50 throws JspException 51 { 52 return (EVAL_BODY_INCLUDE); 53 } 54 55 59 public int doEndTag() 60 throws JspException 61 { 62 if(attribute != null && locator == null) 63 locator = pageContext.getAttribute(attribute).toString(); 64 65 pageContext.setAttribute(id, getMBeanServer(locator)); 66 67 return (EVAL_PAGE); 68 } 69 70 75 public static MBeanServer getMBeanServer(String locator) 76 throws JspException 77 { 78 List l = AdapterFactory.findMBeanServer(locator); 80 if(l.size() == 1) 81 return (MBeanServer)l.get(0); 82 else if(l.size() > 1) 83 throw new JspException("multiple MBeanServers found, defaultDomain parameter is required to chose one"); 84 else 85 throw new JspException("no MBeanServer found for locator: " +locator); 86 } 87 88 91 public String getId() 92 { 93 return id; 94 } 95 96 99 public void setId(String id) 100 { 101 this.id = id; 102 } 103 104 107 public String getLocator() 108 { 109 return locator; 110 } 111 112 115 public void setLocator(String locator) 116 { 117 this.locator = locator; 118 } 119 120 123 public void release() 124 { 125 attribute = locator = id = null; 126 } 127 128 131 public String getAttribute() 132 { 133 return attribute; 134 } 135 136 139 public void setAttribute(String attribute) 140 { 141 this.attribute = attribute; 142 } 143 144 } 145 | Popular Tags |