1 23 24 package com.sun.enterprise.tools.admingui.tree; 25 26 import java.util.HashMap ; 27 import java.util.HashSet ; 28 import java.util.ArrayList ; 29 import java.util.List ; 30 import java.util.Iterator ; 31 import java.io.Serializable ; 32 33 import javax.management.ObjectName ; 34 35 import org.w3c.dom.Element ; 36 import org.w3c.dom.Node ; 37 38 import com.iplanet.jato.RequestContext; 39 import com.iplanet.jato.util.NonSyncStringBuffer; 40 41 import com.sun.enterprise.tools.admingui.util.Util; 42 import com.sun.enterprise.tools.admingui.util.MBeanUtil; 43 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 44 45 public class MonitorTreeNode extends IndexTreeNode implements Serializable { 46 47 public MonitorTreeNode(IndexTreeNode parent, String type, String name, IndexTreeModel model) { 48 super(parent, type, name, model); 49 } 50 51 protected void ensureChildren() { 52 if (getRefresh() == false) 53 return; 54 try { 55 updateKids(); 56 } catch (Exception ex) { 57 if (Util.isLoggableINFO()) { 58 Util.logINFO("ERROR in IndexTreeNode.ensureChildren.", ex); 59 } 60 } 61 setRefresh(false); 62 } 63 64 private void updateKids() { 65 String objectName = (String )getAttribute("objectName"); 66 if (objectName == null || objectName.length() == 0) 67 throw new RuntimeException ( 68 "Object name attribute is required for tree node: "+getName()); 69 70 objectName = replaceTokens(objectName); 71 int i; 73 74 for (i=0; i<children.size(); i++) { 76 if (reserveKids.contains(children.get(i)) == false) 77 reserveKids.add(children.get(i)); 78 } 79 children.clear(); 81 82 for (i=0; i<reserveKids.size(); i++) { 83 IndexTreeNode node = (IndexTreeNode)reserveKids.get(i); 84 Object monitorAttr = node.getAttribute("monitorAttr"); 85 if (monitorAttr == null) { 86 children.add(node); 88 } 89 else if (monitorAttr instanceof String ) { 90 String value = (String )MBeanUtil.getAttribute(objectName, (String )monitorAttr); 91 if (value != null && value.equalsIgnoreCase("off") == false) { 92 children.add(node); 93 } 94 } else if (monitorAttr instanceof ArrayList ) { 95 Iterator it = ((List )monitorAttr).iterator(); 97 while (it.hasNext()) { 98 String value = (String )MBeanUtil.getAttribute(objectName, (String )it.next()); 99 if (value != null && value.equalsIgnoreCase("off") == false) { 100 children.add(node); 101 break; 102 } 103 } 104 } 105 } 106 } 107 108 protected List reserveKids = new ArrayList (); 109 } 110 | Popular Tags |