예제 #1
0
  /**
   * Validates the agent.
   *
   * @return The object name for SWT resource monitor MXBean
   * @throws JvmCoreException
   */
  private ObjectName validateAgent() throws JvmCoreException {
    if (!jvm.isRemote() && !JvmModel.getInstance().getAgentLoadHandler().isAgentLoaded()) {
      throw new JvmCoreException(IStatus.ERROR, Messages.agentNotLoadedMsg, new Exception());
    }

    return jvm.getMBeanServer().getObjectName(SWT_RESOURCE_MONITOR_MXBEAN_NAME);
  }
예제 #2
0
 /*
  * @see ISWTResourceMonitor#setTracking(boolean)
  */
 @Override
 public void setTracking(boolean tracking) throws JvmCoreException {
   ObjectName objectName = validateAgent();
   if (objectName != null) {
     jvm.getMBeanServer().setAttribute(objectName, new Attribute(TRACKING, tracking));
   }
 }
예제 #3
0
 /*
  * @see ISWTResourceMonitor#clear()
  */
 @Override
 public void clear() throws JvmCoreException {
   ObjectName objectName = validateAgent();
   if (objectName != null) {
     jvm.getMBeanServer().invoke(objectName, CLEAR, new Object[0], new String[0]);
   }
 }
예제 #4
0
 /*
  * @see ISWTResourceMonitor#isTracking()
  */
 @Override
 public boolean isTracking() throws JvmCoreException {
   ObjectName objectName = validateAgent();
   if (objectName != null) {
     Object attribute = jvm.getMBeanServer().getAttribute(objectName, TRACKING);
     if (attribute instanceof Boolean) {
       return ((Boolean) attribute).booleanValue();
     }
   }
   return false;
 }
예제 #5
0
 /*
  * @see ISWTResourceMonitor#refreshResourcesCache()
  */
 @Override
 public void refreshResourcesCache() throws JvmCoreException {
   resources.clear();
   ObjectName objectName = validateAgent();
   if (objectName != null) {
     Object attribute = jvm.getMBeanServer().getAttribute(objectName, RESOURCES);
     if (attribute instanceof CompositeData[]) {
       resources =
           new ArrayList<ISWTResourceElement>(getSWTResourceElements((CompositeData[]) attribute));
     }
   }
 }
예제 #6
0
 /*
  * @see ISWTResourceMonitor#isSupported()
  */
 @Override
 public boolean isSupported() {
   try {
     ObjectName objectName = validateAgent();
     if (objectName == null) {
       return false;
     }
     Object attribute = jvm.getMBeanServer().getAttribute(objectName, TRACKING);
     return attribute != null;
   } catch (JvmCoreException e) {
     return false;
   }
 }