[Ejtools-cvs] CVS: applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib M
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-25 20:20:51
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib In directory usw-pr-cvs1:/tmp/cvs-serv27307 Added Files: MBeanAttributeAccessTag.java MBeanAttributeClassTag.java MBeanAttributeEditorTag.java MBeanAttributeValueTag.java MBeanParameterClassTag.java Log Message: Initial Import --- NEW FILE: MBeanAttributeAccessTag.java --- package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.management.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiembl * @created 25 avril 2002 */ public class MBeanAttributeAccessTag extends TagSupport { /** Description of the Field */ private static MessageResources messages = MessageResources.getMessageResources("MBeanAttributeInfoAccess"); /** Name of the bean that contains the data we will be rendering. */ protected String name = null; /** Should we ignore missing beans and simply output nothing? */ protected boolean ignore = false; /**Filter the rendered output for characters that are sensitive in HTML? */ protected boolean filter = true; /** The scope to be searched to retrieve the specified bean. */ protected String scope = null; /** * Setter for the name attribute * * @param name The new value for name attribute */ public void setName(String name) { this.name = name; } /** * Setter for the ignore attribute * * @param ignore The new value for ignore attribute */ public void setIgnore(boolean ignore) { this.ignore = ignore; } /** * Setter for the filter attribute * * @param filter The new value for filter attribute */ public void setFilter(boolean filter) { this.filter = filter; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } /** * Getter for the name attribute * * @return The value of name attribute */ public String getName() { return (this.name); } /** * Getter for the ignore attribute * * @return The value of ignore attribute */ public boolean getIgnore() { return (this.ignore); } /** * Getter for the filter attribute * * @return The value of filter attribute */ public boolean getFilter() { return (this.filter); } /** * Getter for the scope attribute * * @return The value of scope attribute */ public String getScope() { return (this.scope); } /** * Description of the Method * * @return Description of the Returned Value * @exception JspException Description of Exception */ public int doStartTag() throws JspException { // Look up the requested bean (if necessary) MBeanAttributeInfo info = (MBeanAttributeInfo) RequestUtils.lookup(pageContext, name, scope); if (ignore) { if (info == null) return (SKIP_BODY); // Nothing to output } String output = computeAccess(info); if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); // Continue processing this page return (SKIP_BODY); } /** Release all allocated resources. */ public void release() { super.release(); filter = true; ignore = false; name = null; scope = null; } /** * Description of the Method * * @param info Description of Parameter * @return Description of the Returned Value */ protected String computeAccess(MBeanAttributeInfo info) { String result = messages.getMessage("access.ro"); if (info.isIs() || info.isReadable()) { if (info.isWritable()) { result = messages.getMessage("access.rw"); } } else { if (info.isWritable()) { result = messages.getMessage("access.wo"); } } return result; } } --- NEW FILE: MBeanAttributeClassTag.java --- package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.management.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; import net.sourceforge.ejtools.util.ClassTools; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiembl * @created 25 avril 2002 */ public class MBeanAttributeClassTag extends TagSupport { /** Name of the bean that contains the data we will be rendering. */ protected String name = null; /** Should we ignore missing beans and simply output nothing? */ protected boolean ignore = false; /** Filter the rendered output for characters that are sensitive in HTML? */ protected boolean filter = true; /** The scope to be searched to retrieve the specified bean. */ protected String scope = null; /** * Setter for the name attribute * * @param name The new value for name attribute */ public void setName(String name) { this.name = name; } /** * Setter for the ignore attribute * * @param ignore The new value for ignore attribute */ public void setIgnore(boolean ignore) { this.ignore = ignore; } /** * Setter for the filter attribute * * @param filter The new value for filter attribute */ public void setFilter(boolean filter) { this.filter = filter; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } /** * Getter for the name attribute * * @return The value of name attribute */ public String getName() { return (this.name); } /** * Getter for the ignore attribute * * @return The value of ignore attribute */ public boolean getIgnore() { return (this.ignore); } /** * Getter for the filter attribute * * @return The value of filter attribute */ public boolean getFilter() { return (this.filter); } /** * Getter for the scope attribute * * @return The value of scope attribute */ public String getScope() { return (this.scope); } /** * Description of the Method * * @return Description of the Returned Value * @exception JspException Description of Exception */ public int doStartTag() throws JspException { // Look up the requested bean (if necessary) MBeanAttributeInfo info = (MBeanAttributeInfo) RequestUtils.lookup(pageContext, name, scope); if (ignore) { if (info == null) return (SKIP_BODY); // Nothing to output } String output = ClassTools.classDisplay(info.getType()); if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); // Continue processing this page return (SKIP_BODY); } /** Release all allocated resources. */ public void release() { super.release(); filter = true; ignore = false; name = null; scope = null; } } --- NEW FILE: MBeanAttributeEditorTag.java --- package net.sourceforge.ejtools.jmxbrowser.web.taglib; import java.beans.*; import javax.management.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; import net.sourceforge.ejtools.jmx.*; import net.sourceforge.ejtools.util.ClassTools; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiembl * @created 25 avril 2002 */ public class MBeanAttributeEditorTag extends TagSupport { /** Name of the bean that contains the data we will be rendering. */ protected String name = null; /** Should we ignore missing beans and simply output nothing? */ protected boolean ignore = false; /** Filter the rendered output for characters that are sensitive in HTML? */ protected boolean filter = true; /** The scope to be searched to retrieve the specified bean. */ protected String scope = null; /** Name of the property to be accessed on the specified bean. */ protected String property = null; /** * Setter for the name attribute * * @param name The new value for name attribute */ public void setName(String name) { this.name = name; } /** * Setter for the property attribute * * @param property The new value for property attribute */ public void setProperty(String property) { this.property = property; } /** * Setter for the ignore attribute * * @param ignore The new value for ignore attribute */ public void setIgnore(boolean ignore) { this.ignore = ignore; } /** * Setter for the filter attribute * * @param filter The new value for filter attribute */ public void setFilter(boolean filter) { this.filter = filter; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } /** * Getter for the property attribute * * @return The value of property attribute */ public String getProperty() { return (this.property); } /** * Getter for the name attribute * * @return The value of name attribute */ public String getName() { return (this.name); } /** * Getter for the ignore attribute * * @return The value of ignore attribute */ public boolean getIgnore() { return (this.ignore); } /** * Getter for the filter attribute * * @return The value of filter attribute */ public boolean getFilter() { return (this.filter); } /** * Getter for the scope attribute * * @return The value of scope attribute */ public String getScope() { return (this.scope); } /** * Description of the Method * * @return Description of the Returned Value * @exception JspException Description of Exception */ public int doStartTag() throws JspException { // Look up the requested bean (if necessary) MBeanAccessor bean = (MBeanAccessor) RequestUtils.lookup(pageContext, name, scope); if (ignore) { if (bean == null) return (SKIP_BODY); // Nothing to output } MBeanAttributeInfo info = (MBeanAttributeInfo) RequestUtils.lookup(pageContext, property, scope); PropertyEditor propertyeditor = null; Class c = ClassTools.getClass(info.getType()); if (c == null) { addUnsupportedProperty(info); } else { if (c.isArray()) { Class componentType = c.getComponentType(); propertyeditor = PropertyEditorManager.findEditor(componentType); if (propertyeditor == null) { propertyeditor = PropertyEditorManager.findEditor(String.class); } addArrayProperty(bean, propertyeditor, info); } else { propertyeditor = PropertyEditorManager.findEditor(c); if (propertyeditor == null) { propertyeditor = PropertyEditorManager.findEditor(String.class); } addProperty(bean, propertyeditor, info); } } // Continue processing this page return (SKIP_BODY); } /** Release all allocated resources. */ public void release() { super.release(); filter = true; ignore = false; name = null; scope = null; } /** * Adds a feature to the ArrayProperty attribute of the MBeanAttributeEditorTag object * * @param propertyeditor The feature to be added to the ArrayProperty attribute * @param attributeInfo The feature to be added to the ArrayProperty attribute * @param object The feature to be added to the ArrayProperty attribute * @exception JspException Description of Exception */ protected void addArrayProperty(MBeanAccessor object, PropertyEditor propertyeditor, MBeanAttributeInfo attributeInfo) throws JspException { System.out.println("addProperty " + propertyeditor + " " + attributeInfo.getName()); String output = ""; Object obj = null; Object[] array = null; try { if (attributeInfo.isReadable()) { obj = object.getAttribute(object.getObjectName(), attributeInfo.getName()); } if (obj != null) { array = (Object[]) obj; } } catch (Throwable _ex) { } for (int i = 0; i < array.length; i++) { try { PropertyEditor propertyeditor1 = (PropertyEditor) propertyeditor.getClass().newInstance(); propertyeditor1.setValue(array[i]); output = propertyeditor1.getAsText(); output = output + "<br/>"; if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); } catch (Exception _ex) { } } } /** * Adds a feature to the UnsupportedProperty attribute of the MBeanAttributeEditorTag object * * @param propertyeditor The feature to be added to the Property attribute * @param attributeInfo The feature to be added to the Property attribute * @param object The feature to be added to the Property attribute * @exception JspException Description of Exception */ protected void addProperty(MBeanAccessor object, PropertyEditor propertyeditor, MBeanAttributeInfo attributeInfo) throws JspException { System.out.println("addProperty " + propertyeditor + " " + attributeInfo.getName()); String output = ""; try { if (attributeInfo.isReadable()) { propertyeditor.setValue(object.getAttribute(object.getObjectName(), attributeInfo.getName())); } } catch (Throwable _ex) { } if (attributeInfo.isWritable()) { output = propertyeditor.getAsText(); } else { output = propertyeditor.getAsText(); } if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); } /** * Adds a feature to the UnsupportedProperty attribute of the MBeanAttributeEditorTag object * * @param attributeInfo The feature to be added to the UnsupportedProperty attribute * @exception JspException Description of Exception */ protected void addUnsupportedProperty(MBeanAttributeInfo attributeInfo) throws JspException { System.out.println("Getting value for attribute " + attributeInfo.getName()); String output = "<i>Unsupported Class : " + attributeInfo.getType() + "</i>"; if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); } static { PropertyEditorManager.setEditorSearchPath(new String[]{"sun.beans.editors", "net.sourceforge.ejtools.awt.editors"}); } } --- NEW FILE: MBeanAttributeValueTag.java --- package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.management.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; import net.sourceforge.ejtools.jmx.*; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiembl * @created 25 avril 2002 */ public class MBeanAttributeValueTag extends TagSupport { /** Name of the bean that contains the data we will be rendering. */ protected String name = null; /** Should we ignore missing beans and simply output nothing? */ protected boolean ignore = false; /** Filter the rendered output for characters that are sensitive in HTML? */ protected boolean filter = true; /** The scope to be searched to retrieve the specified bean. */ protected String scope = null; /** Name of the property to be accessed on the specified bean. */ protected String property = null; /** * Setter for the name attribute * * @param name The new value for name attribute */ public void setName(String name) { this.name = name; } /** * Setter for the ignore attribute * * @param ignore The new value for ignore attribute */ public void setIgnore(boolean ignore) { this.ignore = ignore; } /** * Setter for the filter attribute * * @param filter The new value for filter attribute */ public void setFilter(boolean filter) { this.filter = filter; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } /** * Setter for the property attribute * * @param property The new value for property attribute */ public void setProperty(String property) { this.property = property; } /** * Getter for the name attribute * * @return The value of name attribute */ public String getName() { return (this.name); } /** * Getter for the ignore attribute * * @return The value of ignore attribute */ public boolean getIgnore() { return (this.ignore); } /** * Getter for the filter attribute * * @return The value of filter attribute */ public boolean getFilter() { return (this.filter); } /** * Getter for the scope attribute * * @return The value of scope attribute */ public String getScope() { return (this.scope); } /** * Getter for the property attribute * * @return The value of property attribute */ public String getProperty() { return (this.property); } /** * Description of the Method * * @return Description of the Returned Value * @exception JspException Description of Exception */ public int doStartTag() throws JspException { // Look up the requested bean (if necessary) MBeanAccessor bean = (MBeanAccessor) RequestUtils.lookup(pageContext, name, scope); if (ignore) { if (bean == null) return (SKIP_BODY); // Nothing to output } MBeanAttributeInfo info = (MBeanAttributeInfo) RequestUtils.lookup(pageContext, property, scope); String output = ""; if (info.isIs() || info.isReadable()) { System.out.println("Getting value for attribute " + info.getName()); output = "" + bean.getAttribute(bean.getObjectName(), info.getName()); } if (filter) ResponseUtils.write(pageContext, ResponseUtils.filter(output)); else ResponseUtils.write(pageContext, output); // Continue processing this page return (SKIP_BODY); } /** Release all allocated resources. */ public void release() { super.release(); filter = true; ignore = false; name = null; scope = null; } } --- NEW FILE: MBeanParameterClassTag.java --- package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.management.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; import net.sourceforge.ejtools.util.ClassTools; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiembl * @created 25 avril 2002 */ public class MBeanParameterClassTag extends TagSupport { /** Filter the rendered output for characters that are sensitive in HTML? */ protected boolean filter = true; /** Should we ignore missing beans and simply output nothing? */ protected boolean ignore = false; /** Name of the bean that contains the data we will be rendering. */ protected String name = null; /** The scope to be searched to retrieve the specified bean. */ protected String scope = null; /** * Description of the Method * * @return Description of the Returned Value * @exception JspException Description of Exception */ public int doStartTag() throws JspException { // Look up the requested bean (if necessary) MBeanParameterInfo info = (MBeanParameterInfo) RequestUtils.lookup(pageContext, name, scope); if (ignore) { if (info == null) { return (SKIP_BODY); } // Nothing to output } String output = ClassTools.classDisplay(info.getType()); if (filter) { ResponseUtils.write(pageContext, ResponseUtils.filter(output)); } else { ResponseUtils.write(pageContext, output); } // Continue processing this page return (SKIP_BODY); } /** * Getter for the filter attribute * * @return The value of filter attribute */ public boolean getFilter() { return (this.filter); } /** * Getter for the ignore attribute * * @return The value of ignore attribute */ public boolean getIgnore() { return (this.ignore); } /** * Getter for the name attribute * * @return The value of name attribute */ public String getName() { return (this.name); } /** * Getter for the scope attribute * * @return The value of scope attribute */ public String getScope() { return (this.scope); } /** Release all allocated resources. */ public void release() { super.release(); filter = true; ignore = false; name = null; scope = null; } /** * Setter for the filter attribute * * @param filter The new value for filter attribute */ public void setFilter(boolean filter) { this.filter = filter; } /** * Setter for the ignore attribute * * @param ignore The new value for ignore attribute */ public void setIgnore(boolean ignore) { this.ignore = ignore; } /** * Setter for the name attribute * * @param name The new value for name attribute */ public void setName(String name) { this.name = name; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } } |