[Ejtools-cvs] CVS: applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib B
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-17 17:18:28
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib In directory usw-pr-cvs1:/tmp/cvs-serv13492/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib Modified Files: ConnectTag.java MBeanAttributeAccessTag.java Added Files: BeanContextTreeTag.java IndentedObject.java TreeLeafTag.java TreeRendererTag.java TreeSpacerTag.java Log Message: Add tree generation by taglib --- NEW FILE: BeanContextTreeTag.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jmxbrowser.web.taglib; import java.beans.beancontext.BeanContext; import java.util.Collection; import java.util.Iterator; import java.util.Vector; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; import org.apache.struts.util.RequestUtils; /** * Description of the Class * * @author letiemble * @created 25 avril 2002 * @todo Javadoc to complete */ public class BeanContextTreeTag extends TagSupport { /** Description of the Field */ protected String id = null; /** 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; /** Description of the Field */ protected String property = 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) BeanContext context = null; if (property != null) { context = (BeanContext) RequestUtils.lookup(pageContext, name, property, scope); } else { context = (BeanContext) RequestUtils.lookup(pageContext, name, scope); } if (ignore) { if (context == null) { return (SKIP_BODY); } // Nothing to output } // Create the beancontext collection Collection collection = populate(context, ""); pageContext.setAttribute(id, collection); // Continue processing this page return (SKIP_BODY); } /** * Gets the id attribute of the BeanContextTreeTag object * * @return The id value */ public String getId() { return (this.id); } /** * 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); } /** * Gets the property attribute of the BeanContextTreeTag object * * @return The property value */ public String getProperty() { return (this.property); } /** * 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(); ignore = false; name = null; scope = null; id = null; } /** * Sets the id attribute of the BeanContextTreeTag object * * @param id The new id value */ public void setId(String id) { this.id = id; } /** * 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; } /** * Sets the property attribute of the BeanContextTreeTag object * * @param property The new property value */ public void setProperty(String property) { this.property = property; } /** * Setter for the scope attribute * * @param scope The new value for scope attribute */ public void setScope(String scope) { this.scope = scope; } /** * Description of the Method * * @param context Description of the Parameter * @param depth Description of the Parameter * @return Description of the Return Value */ protected Collection populate(BeanContext context, String depth) { String newDepth = depth; Collection result = new Vector(); Iterator it = context.iterator(); while (it.hasNext()) { BeanContext bc = (BeanContext) it.next(); IndentedObject o = new IndentedObject(); o.setObject(bc); o.setDepth(depth); if (it.hasNext()) { newDepth = depth + "1"; } else { newDepth = depth + "0"; o.setLast(true); } result.add(o); Collection collection = populate(bc, newDepth); result.addAll(collection); } return result; } } --- NEW FILE: IndentedObject.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jmxbrowser.web.taglib; /** * Description of the Class * * @author letiembl * @created 17 mai 2002 */ public class IndentedObject { /** Description of the Field */ protected String depth = null; /** Description of the Field */ protected boolean last = false; /** Description of the Field */ protected Object o = null; /** Constructor for the IndentedObject object */ public IndentedObject() { } /** * Gets the depth attribute of the IndentedObject object * * @return The depth value */ public String getDepth() { return this.depth; } /** * Gets the object attribute of the IndentedObject object * * @return The object value */ public Object getObject() { return this.o; } /** * Gets the last attribute of the IndentedObject object * * @return The last value */ public boolean isLast() { return this.last; } /** * Sets the depth attribute of the IndentedObject object * * @param depth The new depth value */ public void setDepth(String depth) { this.depth = depth; } /** * Sets the last attribute of the IndentedObject object * * @param last The new last value */ public void setLast(boolean last) { this.last = last; } /** * Sets the object attribute of the IndentedObject object * * @param o The new object value */ public void setObject(Object o) { this.o = o; } /** * Description of the Method * * @return Description of the Return Value */ public String toString() { return "D=" + depth + " L=" + last + " O=" + o; } } --- NEW FILE: TreeLeafTag.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiemble * @created 25 avril 2002 * @todo Javadoc to complete */ public class TreeLeafTag extends TagSupport { /** Description of the Field */ protected String name = null; /** Description of the Field */ protected String property = null; /** Description of the Field */ protected String scope = null; /** Description of the Field */ protected boolean value = false; /** * Description of the Method * * @return Description of the Return Value * @exception JspException Description of the Exception */ public int doStartTag() throws JspException { String img = null; boolean leaf = getValue(); if (name != null) { if (property != null) { leaf = ((Boolean) RequestUtils.lookup(pageContext, name, property, scope)).booleanValue(); } else { leaf = ((Boolean) RequestUtils.lookup(pageContext, name, scope)).booleanValue(); } } if (leaf) { img = "<img src=\"images/tree/join.gif\"/>"; } else { img = "<img src=\"images/tree/joinbottom.gif\"/>"; } ResponseUtils.write(pageContext, img); // Continue processing this page return (SKIP_BODY); } /** * Gets the name attribute of the TreeSpacerTag object * * @return The name value */ public String getName() { return (this.name); } /** * Gets the property attribute of the TreeSpacerTag object * * @return The property value */ public String getProperty() { return (this.property); } /** * Gets the scope attribute of the TreeSpacerTag object * * @return The scope value */ public String getScope() { return (this.scope); } /** * Gets the follow attribute of the TreeSpacerTag object * * @return The follow value */ public boolean getValue() { return (this.value); } /** Release all allocated resources. */ public void release() { super.release(); value = false; } /** * Sets the name attribute of the TreeSpacerTag object * * @param name The new name value */ public void setName(String name) { this.name = name; } /** * Sets the property attribute of the TreeSpacerTag object * * @param property The new property value */ public void setProperty(String property) { this.property = property; } /** * Sets the scope attribute of the TreeSpacerTag object * * @param scope The new scope value */ public void setScope(String scope) { this.scope = scope; } /** * Sets the follow attribute of the TreeSpacerTag object * * @param value The new value value */ public void setValue(boolean value) { this.value = value; } } --- NEW FILE: TreeRendererTag.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiemble * @created 25 avril 2002 * @todo Javadoc to complete */ public class TreeRendererTag extends TagSupport { /** Description of the Field */ protected String name = null; /** Description of the Field */ protected String property = null; /** Description of the Field */ protected String scope = null; /** * Description of the Method * * @return Description of the Return Value * @exception JspException Description of the Exception */ public int doStartTag() throws JspException { Object o = null; if (property != null) { o = RequestUtils.lookup(pageContext, name, property, scope); } else { o = RequestUtils.lookup(pageContext, name, scope); } if (o == null) { return (SKIP_BODY); } String c = o.getClass().getName(); String img = ""; if ("net.sourceforge.ejtools.jmxbrowser.model.Domain".equals(c)) { img = "<img src=\"images/icons/J2EEDomain16.gif\">"; } if ("net.sourceforge.ejtools.jmxbrowser.model.Resource".equals(c)) { img = "<img src=\"images/icons/EJBModule16.gif\">"; } ResponseUtils.write(pageContext, img); // Continue processing this page return (SKIP_BODY); } /** * Gets the name attribute of the TreeSpacerTag object * * @return The name value */ public String getName() { return (this.name); } /** * Gets the property attribute of the TreeRendererTag object * * @return The property value */ public String getProperty() { return (this.property); } /** * Gets the scope attribute of the TreeSpacerTag object * * @return The scope value */ public String getScope() { return (this.scope); } /** Release all allocated resources. */ public void release() { super.release(); } /** * Sets the name attribute of the TreeSpacerTag object * * @param name The new name value */ public void setName(String name) { this.name = name; } /** * Sets the property attribute of the TreeRendererTag object * * @param property The new property value */ public void setProperty(String property) { this.property = property; } /** * Sets the scope attribute of the TreeSpacerTag object * * @param scope The new scope value */ public void setScope(String scope) { this.scope = scope; } } --- NEW FILE: TreeSpacerTag.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jmxbrowser.web.taglib; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; /** * Description of the Class * * @author letiemble * @created 25 avril 2002 * @todo Javadoc to complete */ public class TreeSpacerTag extends TagSupport { /** Description of the Field */ protected String name = null; /** Description of the Field */ protected String property = null; /** Description of the Field */ protected String scope = null; /** Description of the Field */ protected String value = null; /** * Description of the Method * * @return Description of the Return Value * @exception JspException Description of the Exception */ public int doStartTag() throws JspException { String img = null; String follow = getValue(); if (follow == null) { if (name == null) { return (SKIP_BODY); } if (property != null) { follow = (String) RequestUtils.lookup(pageContext, name, property, scope); } else { follow = (String) RequestUtils.lookup(pageContext, name, scope); } } if (follow.length() <= 0) { return (SKIP_BODY); } StringBuffer output = new StringBuffer(); for (int i = 0; i < follow.length(); i++) { if ("1".equals(follow.substring(i, 1))) { img = "<img src=\"images/tree/line.gif\"/>"; } else { img = "<img src=\"images/tree/empty.gif\"/>"; } output.append(img); } ResponseUtils.write(pageContext, output.toString()); // Continue processing this page return (SKIP_BODY); } /** * Gets the name attribute of the TreeSpacerTag object * * @return The name value */ public String getName() { return (this.name); } /** * Gets the property attribute of the TreeSpacerTag object * * @return The property value */ public String getProperty() { return (this.property); } /** * Gets the scope attribute of the TreeSpacerTag object * * @return The scope value */ public String getScope() { return (this.scope); } /** * Gets the follow attribute of the TreeSpacerTag object * * @return The follow value */ public String getValue() { return (this.value); } /** Release all allocated resources. */ public void release() { super.release(); value = null; } /** * Sets the name attribute of the TreeSpacerTag object * * @param name The new name value */ public void setName(String name) { this.name = name; } /** * Sets the property attribute of the TreeSpacerTag object * * @param property The new property value */ public void setProperty(String property) { this.property = property; } /** * Sets the scope attribute of the TreeSpacerTag object * * @param scope The new scope value */ public void setScope(String scope) { this.scope = scope; } /** * Sets the follow attribute of the TreeSpacerTag object * * @param value The new value value */ public void setValue(String value) { this.value = value; } } Index: ConnectTag.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib/ConnectTag.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConnectTag.java 17 May 2002 07:21:53 -0000 1.4 --- ConnectTag.java 17 May 2002 17:18:24 -0000 1.5 *************** *** 8,12 **** import javax.servlet.ServletContext; - import javax.servlet.http.HttpSession; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; --- 8,11 ---- *************** *** 39,43 **** boolean valid = false; ! ServletContext context = pageContext.getServletContext(); if (context.getAttribute(name) != null) --- 38,42 ---- boolean valid = false; ! ServletContext context = pageContext.getServletContext(); if (context.getAttribute(name) != null) Index: MBeanAttributeAccessTag.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/web/taglib/MBeanAttributeAccessTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MBeanAttributeAccessTag.java 15 May 2002 20:56:11 -0000 1.2 --- MBeanAttributeAccessTag.java 17 May 2002 17:18:24 -0000 1.3 *************** *** 44,48 **** public int doStartTag() throws JspException { - // Look up the requested bean (if necessary) MBeanAttributeInfo info = (MBeanAttributeInfo) RequestUtils.lookup(pageContext, name, scope); --- 44,47 ---- |