1 7 package org.jboss.net.taglib; 8 9 import java.util.Map ; 10 import java.util.Iterator ; 11 12 import java.net.URL ; 13 14 import javax.servlet.http.HttpServletRequest ; 15 import javax.servlet.jsp.tagext.TagSupport ; 16 import javax.servlet.jsp.JspTagException ; 17 import javax.servlet.jsp.JspWriter ; 18 19 import javax.management.MBeanServer ; 20 import javax.management.ObjectName ; 21 22 import org.jboss.mx.util.MBeanServerLocator; 23 24 62 public class FlashParametersTag extends TagSupport 63 { 64 final public static String DEFAULT_JBOSSNET_MBEAN_NAME = 65 "jboss.net:service=Axis"; 66 67 private String mbeanName = null; 68 private Map parms = null; 69 70 public FlashParametersTag() 71 { 72 super(); 73 74 } 75 76 83 public String getMbeanName() 84 { 85 return this.mbeanName; 86 } 87 88 public void setMbeanName(String mbeanName) 89 { 90 this.mbeanName = mbeanName; 91 } 92 93 100 public Map getParms() 101 { 102 return parms; 103 } 104 105 public void setParms(Map parms) 106 { 107 this.parms = parms; 108 } 109 110 public int doStartTag() throws JspTagException 111 { 112 HttpServletRequest request = 113 (HttpServletRequest ) pageContext.getRequest(); 114 115 try 116 { 117 JspWriter out = pageContext.getOut(); 118 120 if (null == mbeanName) 121 { 122 mbeanName = DEFAULT_JBOSSNET_MBEAN_NAME; 124 } 125 126 MBeanServer server = MBeanServerLocator.locateJBoss(); 127 ObjectName jbossNetObjName = new ObjectName (mbeanName); 128 129 String rootContext = 130 (String ) server.getAttribute(jbossNetObjName, "RootContext"); 131 132 134 URL reqUrl = new URL (request.getRequestURL().toString()); 135 String hostUrl = reqUrl.getHost() + ":" + reqUrl.getPort(); 136 137 out.print("?hostUrl=" + hostUrl + "&rootContext=" + rootContext); 138 if (null != parms) 139 { 140 Iterator iter = parms.entrySet().iterator(); 142 Map.Entry curEntry; 143 while (iter.hasNext()) 144 { 145 curEntry = (Map.Entry ) iter.next(); 146 out.print( 147 "&" 148 + curEntry.getKey().toString().trim() 149 + "=" 150 + curEntry.getValue().toString().trim()); 151 } 152 } 154 } 155 catch (Exception e) 156 { 157 e.printStackTrace(); 158 throw new JspTagException (e.toString()); 159 } 160 161 return SKIP_BODY; 162 } 163 164 } | Popular Tags |