[Mc4j-cvs] mc4j/src/org/mc4j/console/bean/attribute AttributeChildNode.java,1.1,1.2 AttributeChildre
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:14:30
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20162/src/org/mc4j/console/bean/attribute Modified Files: AttributeSetNode.java AttributeNode.java GraphAttributesAction.java AttributePropertyFactory.java AttributeSetChildren.java BrowseToAction.java Added Files: AttributeChildNode.java AttributeChildren.java Removed Files: AttributeGraphPanel.java AttributeNameComparator.java Log Message: Merging EMS into head for the 2.0 release work Index: AttributeSetChildren.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/AttributeSetChildren.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AttributeSetChildren.java 5 Oct 2004 05:15:56 -0000 1.7 --- AttributeSetChildren.java 12 Apr 2006 19:13:54 -0000 1.8 *************** *** 17,23 **** package org.mc4j.console.bean.attribute; import org.openide.nodes.Children; ! import org.mc4j.console.bean.MBeanNode; /** --- 17,26 ---- package org.mc4j.console.bean.attribute; + import org.mc4j.ems.connection.bean.EmsBean; + import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.openide.nodes.Children; + import org.openide.nodes.Node; ! import java.util.SortedSet; /** *************** *** 29,36 **** public class AttributeSetChildren extends Children.SortedArray { ! protected MBeanNode mbeanNode; ! public AttributeSetChildren(MBeanNode mbeanNode) { ! this.mbeanNode = mbeanNode; } --- 32,39 ---- public class AttributeSetChildren extends Children.SortedArray { ! protected EmsBean emsBean; ! public AttributeSetChildren(EmsBean emsBean) { ! this.emsBean = emsBean; } *************** *** 38,51 **** super.addNotify(); - Thread thread = - new Thread( - new Runnable() { - public void run() { - mbeanNode.refresh(); - } - }, - "mc4j AttributeSetChildren Loader"); ! thread.start(); } } --- 41,54 ---- super.addNotify(); ! SortedSet<EmsAttribute> attributes = emsBean.getAttributes(); ! Node[] newNodes = new Node[attributes.size()]; ! int i = 0; ! for (EmsAttribute attribute : attributes) { ! ! AttributeNode node = new AttributeNode(attribute); ! newNodes[i++] = node; ! } ! add(newNodes); } } Index: AttributePropertyFactory.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/AttributePropertyFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AttributePropertyFactory.java 5 Oct 2004 05:15:56 -0000 1.8 --- AttributePropertyFactory.java 12 Apr 2006 19:13:54 -0000 1.9 *************** *** 20,29 **** import org.mc4j.console.swing.editor.ArrayEditor; import org.mc4j.console.swing.editor.jmx.CompositeDataEditor; - import org.mc4j.console.swing.editor.jmx.ObjectNameEditor; import org.mc4j.console.swing.editor.jmx.TabularDataEditor; import org.openide.nodes.Node; - import javax.management.MBeanAttributeInfo; - import javax.management.ObjectName; import java.beans.PropertyEditorManager; import java.lang.reflect.InvocationTargetException; --- 20,27 ---- import org.mc4j.console.swing.editor.ArrayEditor; import org.mc4j.console.swing.editor.jmx.CompositeDataEditor; import org.mc4j.console.swing.editor.jmx.TabularDataEditor; + import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.openide.nodes.Node; import java.beans.PropertyEditorManager; import java.lang.reflect.InvocationTargetException; *************** *** 38,42 **** private AttributePropertyFactory() { ! PropertyEditorManager.registerEditor(ObjectName.class, ObjectNameEditor.class); try { --- 36,40 ---- private AttributePropertyFactory() { ! // PropertyEditorManager.registerEditor(ObjectName.class, ObjectNameEditor.class); try { *************** *** 61,82 **** } ! public Node.Property buildProperty(AttributeNode node) { ! ! MBeanAttributeInfo attributeInfo = node.getAttributeInfo(); Node.Property property = null; ! if (node.isCanDisplay()) { ! ! try { ! Class type = MBeanNode.findType(attributeInfo.getType()); ! property = new AttributeProperty(type, node); ! } catch (ClassNotFoundException cnfe) { ! //ErrorManager.getDefault().notify(cnfe); ! property = new AttributeProperty(node); ! } ! } else { ! property = new AttributeProperty(node); } --- 59,73 ---- } ! public Node.Property buildProperty(EmsAttribute emsAttribute) { Node.Property property = null; ! try { ! Class type = MBeanNode.findType(emsAttribute.getType()); ! property = new AttributeProperty(type, emsAttribute); ! } catch (ClassNotFoundException cnfe) { ! //ErrorManager.getDefault().notify(cnfe); ! property = new AttributeProperty(emsAttribute); } *************** *** 87,106 **** public static class AttributeProperty extends Node.Property { ! protected AttributeNode attributeNode; protected boolean unknownType = false; ! public AttributeProperty(Class type, AttributeNode attributeNode) { super(type); ! this.attributeNode = attributeNode; ! setName(this.attributeNode.getDisplayName()); ! setShortDescription(attributeNode.getAttributeInfo().getDescription() + ! " (" + attributeNode.getAttributeInfo().getType() + ")"); } ! public AttributeProperty(AttributeNode attributeNode) { ! this(String.class, attributeNode); unknownType = true; } --- 78,97 ---- public static class AttributeProperty extends Node.Property { ! protected EmsAttribute emsAttribute; protected boolean unknownType = false; ! public AttributeProperty(Class type, EmsAttribute emsAttribute) { super(type); ! this.emsAttribute = emsAttribute; ! setName(this.emsAttribute.getName()); ! setShortDescription(this.emsAttribute.getDescription() + ! " (" + this.emsAttribute.getType() + ")"); } ! public AttributeProperty(EmsAttribute emsAttribute) { ! this(String.class, emsAttribute); unknownType = true; } *************** *** 112,116 **** */ public boolean canRead() { ! return this.attributeNode.getAttributeInfo().isReadable(); } --- 103,107 ---- */ public boolean canRead() { ! return this.emsAttribute.isReadable(); } *************** *** 124,136 **** return false; ! return this.attributeNode.getAttributeInfo().isWritable(); } public Object getValue() throws IllegalAccessException, InvocationTargetException { ! if (this.attributeNode.isCanDisplay()) { ! return this.attributeNode.getValue(); ! } else { ! return "<cannot display>"; ! } } --- 115,123 ---- return false; ! return this.emsAttribute.isWritable(); } public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return this.emsAttribute.getValue(); } *************** *** 139,143 **** try { ! this.attributeNode.setValue(val); } catch(Exception e) { throw new InvocationTargetException(e); --- 126,130 ---- try { ! this.emsAttribute.setValue(val); } catch(Exception e) { throw new InvocationTargetException(e); Index: GraphAttributesAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/GraphAttributesAction.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GraphAttributesAction.java 5 Oct 2004 05:15:56 -0000 1.6 --- GraphAttributesAction.java 12 Apr 2006 19:13:54 -0000 1.7 *************** *** 17,40 **** package org.mc4j.console.bean.attribute; ! import java.awt.Color; ! import java.math.BigDecimal; ! import java.math.BigInteger; ! import java.util.HashSet; ! import java.util.Set; ! ! import javax.management.MBeanAttributeInfo; ! import javax.management.ObjectName; ! import javax.swing.SwingUtilities; ! import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.actions.NodeAction; ! import org.mc4j.console.bean.MBeanNode; /** ! * Action sensitive to the node selection that does something useful. ! * Consider using a cookie action instead if you can define what the ! * action is applicable to in terms of cookies. * * @author Greg Hinkle (gh...@us...), January 2002 --- 17,38 ---- package org.mc4j.console.bean.attribute; ! import org.mc4j.console.bean.MBeanNode; ! import org.mc4j.console.swing.graph.AttributeGraphPanel; ! import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.actions.NodeAction; ! import javax.swing.*; ! import java.awt.*; ! import java.math.BigDecimal; ! import java.math.BigInteger; ! import java.util.ArrayList; ! import java.util.HashSet; ! import java.util.List; ! import java.util.Set; /** ! * * * @author Greg Hinkle (gh...@us...), January 2002 *************** *** 44,67 **** protected void performAction(Node[] nodes) { ! // do work based on the current node selection, e.g.: ! AttributeNode node = (AttributeNode)nodes[0]; ! // ... ! // Note that casting to a type of node is often not the right ! // solution; try using a CookieAction, unless it is really the ! // node itself and not the underlying data that needs to be ! // considered. Also remember that some tests on nodes (casts ! // as well as reorderability of children etc.) will not work ! // when applied to filter nodes, whereas cookies will. ! ! MBeanAttributeInfo[] infos = new MBeanAttributeInfo[nodes.length]; ! ! for (int i = 0; i < nodes.length; i++) { ! infos[i] = ((AttributeNode)nodes[i]).getAttributeInfo(); } ! ObjectName objectName = ((MBeanNode)nodes[0].getParentNode().getParentNode()).getObjectName(); ! ! final AttributeGraphPanel graphPanel = new AttributeGraphPanel( ! objectName, infos,((AttributeNode)nodes[0]).getServer()); graphPanel.setBackground(Color.WHITE); --- 42,51 ---- protected void performAction(Node[] nodes) { ! List<EmsAttribute> attributes = new ArrayList<EmsAttribute>(); ! for (Node node : nodes) { ! attributes.add(((AttributeNode)node).getEmsAttribute()); } ! final AttributeGraphPanel graphPanel = new AttributeGraphPanel(attributes); graphPanel.setBackground(Color.WHITE); *************** *** 82,86 **** } AttributeNode node = (AttributeNode) nodes[i]; ! String typeName = node.getAttributeInfo().getType(); Class type = null; try { --- 66,70 ---- } AttributeNode node = (AttributeNode) nodes[i]; ! String typeName = node.getEmsAttribute().getType(); Class type = null; try { *************** *** 124,138 **** public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; - // If you will provide context help then use: - // return new HelpCtx(GraphAttributesAction.class); } - /** Perform extra initialization of this action's singleton. - * PLEASE do not use constructors for this purpose! - * protected void initialize() { - * super.initialize(); - * putProperty(Action.SHORT_DESCRIPTION, NbBundle.getMessage(GraphAttributesAction.class, "HINT_Action")); - * } - */ - } --- 108,112 ---- --- AttributeNameComparator.java DELETED --- --- AttributeGraphPanel.java DELETED --- --- NEW FILE: AttributeChildren.java --- /* * Copyright 2002-2004 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.console.bean.attribute; import org.openide.nodes.Children; import org.mc4j.console.bean.MBeanNode; /** * Children set for attributes on an MBeanNode. * * @author Greg Hinkle (gh...@us...), January 2002 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:13:54 $) */ public class AttributeChildren extends Children.SortedArray { protected MBeanNode mbeanNode; public AttributeChildren(MBeanNode mbeanNode) { this.mbeanNode = mbeanNode; } protected void addNotify() { super.addNotify(); // TODO GH: Implement child collection entry loading // Thread thread = // new Thread( // new Runnable() { // public void run() { // mbeanNode.refresh(); // } // }, // "mc4j AttributeSetChildren Loader"); // // thread.start(); } } Index: BrowseToAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/BrowseToAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BrowseToAction.java 5 Oct 2004 05:15:56 -0000 1.3 --- BrowseToAction.java 12 Apr 2006 19:13:54 -0000 1.4 *************** *** 17,22 **** package org.mc4j.console.bean.attribute; - import javax.management.MBeanAttributeInfo; - import javax.management.ObjectName; import org.openide.nodes.Node; --- 17,20 ---- *************** *** 27,30 **** --- 25,30 ---- import org.mc4j.console.connection.ConnectionNode; + import javax.management.ObjectName; + /** * This action will browse the explorer tree to a managed object for a attribute *************** *** 39,50 **** AttributeNode node = (AttributeNode)nodes[0]; - MBeanAttributeInfo[] infos = new MBeanAttributeInfo[nodes.length]; - - for (int i = 0; i < nodes.length; i++) { - infos[i] = ((AttributeNode)nodes[i]).getAttributeInfo(); - } - ObjectName objectName = (ObjectName) node.getValue(); ! if (objectName != null) { Node curNode = node; while (! (curNode instanceof ConnectionNode)) { --- 39,44 ---- AttributeNode node = (AttributeNode)nodes[0]; ObjectName objectName = (ObjectName) node.getValue(); ! if (objectName != null) { Node curNode = node; while (! (curNode instanceof ConnectionNode)) { *************** *** 53,57 **** ConnectionNode connectionNode = (ConnectionNode) curNode; ! connectionNode.browseToMBean(objectName); } } --- 47,52 ---- ConnectionNode connectionNode = (ConnectionNode) curNode; ! // TODO! ! // connectionNode.browseToMBean(objectName); } } *************** *** 65,69 **** AttributeNode node = (AttributeNode) nodes[0]; ! String typeName = node.getAttributeInfo().getType(); Class type = null; try { --- 60,64 ---- AttributeNode node = (AttributeNode) nodes[0]; ! String typeName = node.getEmsAttribute().getType(); Class type = null; try { --- NEW FILE: AttributeChildNode.java --- /* * Copyright 2002-2004 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.console.bean.attribute; /** * @author Greg Hinkle (gh...@us...), Jan 6, 2005 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:13:54 $) */ public class AttributeChildNode { public void refresh() { // do nothing } } Index: AttributeNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/AttributeNode.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AttributeNode.java 7 Jan 2005 05:10:53 -0000 1.16 --- AttributeNode.java 12 Apr 2006 19:13:54 -0000 1.17 *************** *** 19,37 **** import org.mc4j.console.Refreshable; import org.mc4j.console.bean.attribute.watch.CreateMonitorAction; import org.openide.actions.PropertiesAction; import org.openide.actions.ToolsAction; ! import org.openide.nodes.AbstractNode; ! import org.openide.nodes.Children; ! import org.openide.nodes.Node; ! import org.openide.nodes.PropertySupport; ! import org.openide.nodes.Sheet; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; - import javax.management.Attribute; - import javax.management.MBeanAttributeInfo; - import javax.management.MBeanServer; - import javax.management.ObjectInstance; - import javax.management.ObjectName; import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; --- 19,29 ---- import org.mc4j.console.Refreshable; import org.mc4j.console.bean.attribute.watch.CreateMonitorAction; + import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.openide.actions.PropertiesAction; import org.openide.actions.ToolsAction; ! import org.openide.nodes.*; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; *************** *** 45,52 **** public class AttributeNode extends AbstractNode implements Refreshable, Comparable { ! protected MBeanServer server; ! protected ObjectInstance objectInstance; ! protected ObjectName objectName; ! protected MBeanAttributeInfo attributeInfo; protected Node.Property valuePropertyNode; --- 37,41 ---- public class AttributeNode extends AbstractNode implements Refreshable, Comparable { ! protected EmsAttribute emsAttribute; protected Node.Property valuePropertyNode; *************** *** 60,103 **** // TODO GH: Create sub-nodes for array and collection values ! /** ! * @deprecated ! * @param server ! * @param objectInstance ! * @param attributeInfo ! */ ! public AttributeNode( ! MBeanServer server, ! ObjectInstance objectInstance, ! MBeanAttributeInfo attributeInfo) { ! this(server, objectInstance.getObjectName(), attributeInfo); ! } ! ! public AttributeNode(Children children) { ! super(children); ! } ! ! public AttributeNode( ! MBeanServer server, ! ObjectName objectName, ! MBeanAttributeInfo attributeInfo) { ! super(Children.LEAF); ! this.server = server; ! this.attributeInfo = attributeInfo; ! this.objectName = objectName; ! setIconBase("org/mc4j/console/bean/attribute/AttributeNodeIcon"); ! setName(this.attributeInfo.getName()); // or, super.setName if needed refresh(); ! setDisplayName(this.attributeInfo.getName()); ! setShortDescription(this.attributeInfo.getDescription()); } public boolean isCanDisplay() { return canDisplay; --- 49,72 ---- // TODO GH: Create sub-nodes for array and collection values ! public AttributeNode(EmsAttribute emsAttribute) { super(Children.LEAF); ! this.emsAttribute = emsAttribute; setIconBase("org/mc4j/console/bean/attribute/AttributeNodeIcon"); ! setName(this.emsAttribute.getName()); // or, super.setName if needed refresh(); ! setDisplayName(this.emsAttribute.getName()); ! setShortDescription(this.emsAttribute.getDescription()); } + public EmsAttribute getEmsAttribute() { + return emsAttribute; + } + public boolean isCanDisplay() { return canDisplay; *************** *** 120,125 **** try { ! server.setAttribute(objectName, ! new Attribute(attributeInfo.getName(), newValue)); } catch (Exception e) { throw new InvocationTargetException(e); --- 89,93 ---- try { ! emsAttribute.setValue(newValue); } catch (Exception e) { throw new InvocationTargetException(e); *************** *** 138,142 **** Object newValue = null; try { ! newValue = server.getAttribute(this.objectName, this.attributeInfo.getName()); } catch (Exception e) { e.printStackTrace(); --- 106,111 ---- Object newValue = null; try { ! this.emsAttribute.refresh(); ! newValue = this.emsAttribute.getValue(); } catch (Exception e) { e.printStackTrace(); *************** *** 182,196 **** } - /** Getter for property attributeInfo. - * @return Value of property attributeInfo. - * - */ - public javax.management.MBeanAttributeInfo getAttributeInfo() { - return attributeInfo; - } - - public MBeanServer getServer() { - return this.server; - } public int compareTo(Object o) { --- 151,154 ---- *************** *** 225,229 **** public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return attributeInfo.getName(); } }); --- 183,187 ---- public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return AttributeNode.this.emsAttribute.getName(); } }); *************** *** 234,238 **** public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return attributeInfo.getDescription(); } }); --- 192,196 ---- public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return AttributeNode.this.emsAttribute.getDescription(); } }); *************** *** 243,247 **** public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return attributeInfo.getType(); } }); --- 201,205 ---- public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return AttributeNode.this.emsAttribute.getType(); } }); *************** *** 252,256 **** public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return new Boolean(attributeInfo.isWritable()); } }); --- 210,214 ---- public Object getValue() throws IllegalAccessException, InvocationTargetException { ! return new Boolean(AttributeNode.this.emsAttribute.isWritable()); } }); *************** *** 313,317 **** * * @since MC4J 1.2b5 - * @return */ public synchronized Node.Property getValueProperty() { --- 271,274 ---- *************** *** 323,327 **** private Node.Property buildAttributeValueProperty() { ! return AttributePropertyFactory.getInstance().buildProperty(this); } --- 280,284 ---- private Node.Property buildAttributeValueProperty() { ! return AttributePropertyFactory.getInstance().buildProperty(this.emsAttribute); } *************** *** 381,389 **** } - - public ObjectName getObjectName() { - return objectName; - } - - } --- 338,340 ---- Index: AttributeSetNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/attribute/AttributeSetNode.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AttributeSetNode.java 5 Oct 2004 05:15:56 -0000 1.11 --- AttributeSetNode.java 12 Apr 2006 19:13:54 -0000 1.12 *************** *** 17,41 **** package org.mc4j.console.bean.attribute; import org.openide.nodes.AbstractNode; - import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; - import org.mc4j.console.Refreshable; - import org.mc4j.console.bean.MBeanNode; - import org.mc4j.console.bean.RefreshAction; - import org.mc4j.console.install.ExplorerUtil; - - import java.util.ArrayList; - import java.util.HashMap; - import java.util.Iterator; - import java.util.List; - import java.util.Map; - - import javax.management.Attribute; - import javax.management.AttributeList; - import javax.management.MBeanAttributeInfo; - /** * The MBeanNode child that holds the attributes. --- 17,29 ---- package org.mc4j.console.bean.attribute; + import org.mc4j.console.Refreshable; + import org.mc4j.console.bean.RefreshAction; + import org.mc4j.console.install.ExplorerUtil; + import org.mc4j.ems.connection.bean.EmsBean; import org.openide.nodes.AbstractNode; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; /** * The MBeanNode child that holds the attributes. *************** *** 48,60 **** public static final String NAME = "Attributes"; - private MBeanNode mbeanNode; private boolean hasUnsupportedType = false; ! private Map unsupportedAttributeMap = new HashMap(); ! public AttributeSetNode(MBeanNode mbeanNode) { ! super(new AttributeSetChildren(mbeanNode)); ! this.mbeanNode = mbeanNode; setIconBase("org/mc4j/console/bean/attribute/AttributeSetNodeIcon"); --- 36,47 ---- public static final String NAME = "Attributes"; private boolean hasUnsupportedType = false; ! private EmsBean emsBean; ! public AttributeSetNode(EmsBean emsBean) { ! super(new AttributeSetChildren(emsBean)); ! this.emsBean = emsBean; setIconBase("org/mc4j/console/bean/attribute/AttributeSetNodeIcon"); *************** *** 67,71 **** } ! public void refresh() { if (ExplorerUtil.isExpanded(this)) { --- 54,61 ---- } ! ! ! ! public void refresh() { if (ExplorerUtil.isExpanded(this)) { *************** *** 75,150 **** public void retrieveData() { ! Node[] children = getChildren().getNodes(); ! ! if (!hasUnsupportedType) { ! MBeanAttributeInfo[] infos = ! this.mbeanNode.getMBeanInfo().getAttributes(); ! ! // MUST be careful to only ask for types that we know we have ! // otherwise the RMI call will fail and we will get no data. ! List nameList = new ArrayList(); ! for (int i = 0; i < infos.length; i++) { ! try { ! MBeanNode.findType(infos[i].getType()); ! // If we know the type, add it to the list ! nameList.add(infos[i].getName()); ! } catch (ClassNotFoundException cnfe) { } ! } ! ! String[] names = ! (String[]) ! nameList.toArray(new String[nameList.size()]); ! ! try { ! AttributeList attributeList = ! this.mbeanNode.getMBeanServer().getAttributes( ! this.mbeanNode.getObjectName(), ! names); ! if (attributeList.size() == names.length) { ! Map values = new HashMap(); ! Iterator iter = attributeList.iterator(); ! while (iter.hasNext()) { ! Attribute attr = (Attribute)iter.next(); ! values.put(attr.getName(),attr.getValue()); ! } ! for (int i = 0; i < children.length; i++) { ! AttributeNode node = (AttributeNode)children[i]; ! Object value = values.get(node.getName()); ! if (value != null) { ! node.updateValue(value); ! } else { ! if (values.containsKey(node.getName())) { ! node.updateValue(null); ! } else { ! node.setCanDisplay(false); ! node.setShortDescription("Value could not be displayed"); ! } ! } ! } ! } else { ! // If we still we're unable to load all the attributes at once ! // lets load as many as we can, one at a time. ! for (int i = 0; i < children.length; i++ ) { ! ((Refreshable)children[i]).refresh(); ! } ! } ! } catch (Exception e) { ! // Don't load them as a set anymore... ! this.hasUnsupportedType = true; ! //System.out.println(ExceptionUtility.printStackTracesToString(e)); ! ! // If we still we're unable to load all the attributes at once ! // lets load as many as we can, one at a time. ! for (int i = 0; i < children.length; i++ ) { ! ((Refreshable)children[i]).refresh(); ! } ! ! } ! } else { ! // lets load as many as we can, one at a time. ! for (int i = 0; i < children.length; i++ ) { ! ((Refreshable)children[i]).refresh(); ! } ! } } --- 65,69 ---- public void retrieveData() { ! emsBean.refreshAttributes(); } |