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 29 public class ObjectNameTag extends TagSupport 30 implements JMXTaglibConstants 31 { 32 33 34 private String attribute; 35 36 37 private String parameter; 38 39 40 private String id; 41 42 43 public ObjectNameTag() 44 { } 45 46 50 public int doStartTag() 51 throws JspException 52 { 53 String s = null; 54 if(attribute != null) 55 s = pageContext.getAttribute(attribute).toString(); 56 else if(parameter != null) 57 { 58 68 69 s = pageContext.getRequest().getParameter(parameter).toString(); 70 } 71 72 if(s == null) 73 throw new JspException("tag ObjectName requires either the parameter or attribute to be set."); 74 75 if(id == null) 76 throw new JspException("tag ObjectName requires either the id attribute to be set."); 77 78 ObjectName name = null; 79 try{ name = new ObjectName(s); } 80 catch(Exception ex) { throw new JspException("tag ObjectName exception: " +ex.toString()); } 81 82 pageContext.setAttribute(id, name); 83 84 return (SKIP_BODY); 85 } 86 87 90 public void release() 91 { 92 attribute = parameter = id = null; 93 } 94 95 98 public String getAttribute() 99 { 100 return attribute; 101 } 102 103 106 public void setAttribute(String attribute) 107 { 108 this.attribute = attribute; 109 } 110 111 114 public String getParameter() 115 { 116 return parameter; 117 } 118 119 122 public void setParameter(String parameter) 123 { 124 this.parameter = parameter; 125 } 126 127 130 public String getId() 131 { 132 return id; 133 } 134 135 138 public void setId(String id) 139 { 140 this.id = id; 141 } 142 } 143 | Popular Tags |