jdk/src/share/classes/sun/tools/jconsole/inspector/XMBeanAttributes.java
changeset 697 fb86c99b92a2
parent 2 90ce3da70b43
child 715 f16baef3a20e
equal deleted inserted replaced
696:4790b8660847 697:fb86c99b92a2
   347             new HashMap<String, Object>(attributesInfo.length);
   347             new HashMap<String, Object>(attributesInfo.length);
   348         AttributeList list = null;
   348         AttributeList list = null;
   349 
   349 
   350         try {
   350         try {
   351             list = mbean.getAttributes(attributesInfo);
   351             list = mbean.getAttributes(attributesInfo);
   352         }catch(Exception e) {
   352         } catch (Exception e) {
       
   353             if (JConsole.isDebug()) {
       
   354                 System.err.println("Error calling getAttributes() on MBean \"" +
       
   355                                    mbean.getObjectName() + "\". JConsole will " +
       
   356                                    "try to get them individually calling " +
       
   357                                    "getAttribute() instead. Exception:");
       
   358                 e.printStackTrace(System.err);
       
   359             }
   353             list = new AttributeList();
   360             list = new AttributeList();
   354             //Can't load all attributes, do it one after each other.
   361             //Can't load all attributes, do it one after each other.
   355             for(int i = 0; i < attributesInfo.length; i++) {
   362             for(int i = 0; i < attributesInfo.length; i++) {
   356                 String name = null;
   363                 String name = null;
   357                 try {
   364                 try {
   358                     name = attributesInfo[i].getName();
   365                     name = attributesInfo[i].getName();
   359                     Object value =
   366                     Object value =
   360                         mbean.getAttribute(name);
   367                         mbean.getMBeanServerConnection().getAttribute(mbean.getObjectName(), name);
   361                     list.add(new Attribute(name, value));
   368                     list.add(new Attribute(name, value));
   362                 }catch(Exception ex) {
   369                 }catch(Exception ex) {
   363                     if(attributesInfo[i].isReadable()) {
   370                     if(attributesInfo[i].isReadable()) {
   364                         unavailableAttributes.put(name,
   371                         unavailableAttributes.put(name,
   365                                                   Utils.getActualException(ex).
   372                                                   Utils.getActualException(ex).
   395                             // exception.
   402                             // exception.
   396                             // We must call it again to understand what
   403                             // We must call it again to understand what
   397                             // went wrong.
   404                             // went wrong.
   398                             try {
   405                             try {
   399                                 Object v =
   406                                 Object v =
   400                                     mbean.getAttribute(attributeInfo.
   407                                     mbean.getMBeanServerConnection().getAttribute(
   401                                                        getName());
   408                                     mbean.getObjectName(), attributeInfo.getName());
   402                                 //What happens if now it is ok?
   409                                 //What happens if now it is ok?
   403                                 // Be pragmatic, add it to readable...
   410                                 // Be pragmatic, add it to readable...
   404                                 attributes.put(attributeInfo.getName(),
   411                                 attributes.put(attributeInfo.getName(),
   405                                                v);
   412                                                v);
   406                             }catch(Exception e) {
   413                             }catch(Exception e) {
   526         }
   533         }
   527         return cell;
   534         return cell;
   528     }
   535     }
   529 
   536 
   530      public void refreshAttributes() {
   537      public void refreshAttributes() {
   531          MBeanServerConnection mbsc = mbeansTab.getMBeanServerConnection();
   538          SnapshotMBeanServerConnection mbsc = mbeansTab.getSnapshotMBeanServerConnection();
   532          if (mbsc instanceof SnapshotMBeanServerConnection) {
   539          mbsc.flush();
   533              ((SnapshotMBeanServerConnection) mbsc).flush();
       
   534          }
       
   535          stopCellEditing();
   540          stopCellEditing();
   536          loadAttributes(mbean, mbeanInfo);
   541          loadAttributes(mbean, mbeanInfo);
   537      }
   542      }
   538 
   543 
   539 
   544