com-sun-tools-visualvm-application-views

16:33:41.365 INFO  jd.cli.Main - Decompiling com-sun-tools-visualvm-application-views.jar
package com.sun.tools.visualvm.application.views;

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.application.snapshot.ApplicationSnapshot;
import com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorViewProvider;
import com.sun.tools.visualvm.application.views.monitor.ApplicationSnapshotMonitorViewProvider;
import com.sun.tools.visualvm.application.views.overview.ApplicationOverviewViewProvider;
import com.sun.tools.visualvm.application.views.overview.ApplicationSnapshotOverviewViewProvider;
import com.sun.tools.visualvm.application.views.threads.ApplicationSnapshotThreadsViewProvider;
import com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider;
import com.sun.tools.visualvm.core.ui.DataSourceViewsManager;
import com.sun.tools.visualvm.core.ui.PluggableDataSourceViewProvider;

public final class ApplicationViewsSupport
{
  private static ApplicationViewsSupport sharedInstance;
  private ApplicationSnapshotOverviewViewProvider applicationSnapshotOverviewView = new ApplicationSnapshotOverviewViewProvider();
  private ApplicationOverviewViewProvider overviewPluggableView = new ApplicationOverviewViewProvider();
  private ApplicationSnapshotMonitorViewProvider applicationSnapshotMonitorView = new ApplicationSnapshotMonitorViewProvider();
  private ApplicationMonitorViewProvider monitorPluggableView = new ApplicationMonitorViewProvider();
  private ApplicationSnapshotThreadsViewProvider applicationSnapshotThreadsView = new ApplicationSnapshotThreadsViewProvider();
  private ApplicationThreadsViewProvider threadsPluggableView = new ApplicationThreadsViewProvider();
  
  public static synchronized ApplicationViewsSupport sharedInstance()
  {
    if (sharedInstance == null) {
      sharedInstance = new ApplicationViewsSupport();
    }
    return sharedInstance;
  }
  
  public PluggableDataSourceViewProvider<Application> getOverviewView()
  {
    return overviewPluggableView;
  }
  
  public PluggableDataSourceViewProvider<ApplicationSnapshot> getSnapshotOverviewView()
  {
    return applicationSnapshotOverviewView;
  }
  
  public PluggableDataSourceViewProvider getMonitorView()
  {
    return monitorPluggableView;
  }
  
  public PluggableDataSourceViewProvider<ApplicationSnapshot> getSnapshotMonitorView()
  {
    return applicationSnapshotMonitorView;
  }
  
  public PluggableDataSourceViewProvider getThreadsView()
  {
    return threadsPluggableView;
  }
  
  public PluggableDataSourceViewProvider<ApplicationSnapshot> getSnapshotThreadsView()
  {
    return applicationSnapshotThreadsView;
  }
  
  private ApplicationViewsSupport()
  {
    DataSourceViewsManager.sharedInstance().addViewProvider(overviewPluggableView, Application.class);
    DataSourceViewsManager.sharedInstance().addViewProvider(applicationSnapshotOverviewView, ApplicationSnapshot.class);
    DataSourceViewsManager.sharedInstance().addViewProvider(monitorPluggableView, Application.class);
    DataSourceViewsManager.sharedInstance().addViewProvider(applicationSnapshotMonitorView, ApplicationSnapshot.class);
    DataSourceViewsManager.sharedInstance().addViewProvider(threadsPluggableView, Application.class);
    DataSourceViewsManager.sharedInstance().addViewProvider(applicationSnapshotThreadsView, ApplicationSnapshot.class);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.ApplicationViewsSupport
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views;

import org.openide.modules.ModuleInstall;

final class Installer
  extends ModuleInstall
{
  public void restored()
  {
    ApplicationViewsSupport.sharedInstance();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.Installer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import java.io.File;

class ApplicationMonitorModel$1
  implements Runnable
{
  ApplicationMonitorModel$1(ApplicationMonitorModel paramApplicationMonitorModel, SimpleXYChartSupport paramSimpleXYChartSupport) {}
  
  public void run()
  {
    File file = new File(ApplicationMonitorModel.access$000(this$0).getStorage().getDirectory(), "monitor_cpu.dat");
    if (file.isFile()) {
      ApplicationMonitorModel.access$100(val$cpuChartSupport, file);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import java.io.File;

class ApplicationMonitorModel$2
  implements Runnable
{
  ApplicationMonitorModel$2(ApplicationMonitorModel paramApplicationMonitorModel, SimpleXYChartSupport paramSimpleXYChartSupport) {}
  
  public void run()
  {
    File file = new File(ApplicationMonitorModel.access$000(this$0).getStorage().getDirectory(), "monitor_heap.dat");
    if (file.isFile()) {
      ApplicationMonitorModel.access$100(val$heapChartSupport, file);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import java.io.File;

class ApplicationMonitorModel$3
  implements Runnable
{
  ApplicationMonitorModel$3(ApplicationMonitorModel paramApplicationMonitorModel) {}
  
  public void run()
  {
    File file = new File(ApplicationMonitorModel.access$000(this$0).getStorage().getDirectory(), "monitor_permgen.dat");
    if (file.isFile()) {
      ApplicationMonitorModel.access$100(ApplicationMonitorModel.access$200(this$0), file);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import java.io.File;

class ApplicationMonitorModel$4
  implements Runnable
{
  ApplicationMonitorModel$4(ApplicationMonitorModel paramApplicationMonitorModel, SimpleXYChartSupport paramSimpleXYChartSupport) {}
  
  public void run()
  {
    File file = new File(ApplicationMonitorModel.access$000(this$0).getStorage().getDirectory(), "monitor_classes.dat");
    if (file.isFile()) {
      ApplicationMonitorModel.access$100(val$classesChartSupport, file);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import java.io.File;

class ApplicationMonitorModel$5
  implements Runnable
{
  ApplicationMonitorModel$5(ApplicationMonitorModel paramApplicationMonitorModel, SimpleXYChartSupport paramSimpleXYChartSupport) {}
  
  public void run()
  {
    File file = new File(ApplicationMonitorModel.access$000(this$0).getStorage().getDirectory(), "monitor_threads.dat");
    if (file.isFile()) {
      ApplicationMonitorModel.access$100(val$threadsChartSupport, file);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.application.jvm.MonitoredData;

class ApplicationMonitorModel$6$1
  implements Runnable
{
  ApplicationMonitorModel$6$1(ApplicationMonitorModel.6 param6, long paramLong, MonitoredData paramMonitoredData) {}
  
  public void run()
  {
    ApplicationMonitorModel.access$300(this$1.this$0, val$timestampF, val$data);
    ApplicationMonitorModel.access$400(this$1.this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.6.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.application.jvm.MonitoredData;
import com.sun.tools.visualvm.application.jvm.MonitoredDataListener;
import javax.swing.SwingUtilities;

class ApplicationMonitorModel$6
  implements MonitoredDataListener
{
  long lastTimestamp = -1L;
  
  ApplicationMonitorModel$6(ApplicationMonitorModel paramApplicationMonitorModel) {}
  
  public void monitoredDataEvent(MonitoredData data)
  {
    long timestamp = System.currentTimeMillis();
    final long timestampF = ++lastTimestamp;
    
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        ApplicationMonitorModel.access$300(this$0, timestampF, val$data);
        ApplicationMonitorModel.access$400(this$0);
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.application.jvm.Jvm;
import com.sun.tools.visualvm.application.jvm.JvmFactory;
import com.sun.tools.visualvm.application.jvm.MonitoredData;
import com.sun.tools.visualvm.application.jvm.MonitoredDataListener;
import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.Storage;
import com.sun.tools.visualvm.core.options.GlobalPreferences;
import com.sun.tools.visualvm.core.snapshot.Snapshot;
import com.sun.tools.visualvm.heapdump.HeapDumpSupport;
import com.sun.tools.visualvm.tools.jmx.JmxModel;
import com.sun.tools.visualvm.tools.jmx.JmxModel.ConnectionState;
import com.sun.tools.visualvm.tools.jmx.JmxModelFactory;
import com.sun.tools.visualvm.tools.jmx.JvmMXBeans;
import com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.openide.util.RequestProcessor;

final class ApplicationMonitorModel
{
  private static final String PROP_PREFIX = "ApplicationMonitorModel_";
  static final String SNAPSHOT_VERSION = "ApplicationMonitorModel_version";
  private static final String SNAPSHOT_VERSION_DIVIDER = ".";
  private static final String CURRENT_SNAPSHOT_VERSION_MAJOR = "1";
  private static final String CURRENT_SNAPSHOT_VERSION_MINOR = "0";
  private static final String CURRENT_SNAPSHOT_VERSION = "1.0";
  private static final String PROP_NOT_DEFINED = "<not defined>";
  public static final String PROP_CHART_CACHE = "ApplicationMonitorModel_chart_cache";
  public static final String PROP_UPTIME = "ApplicationMonitorModel_uptime";
  public static final String PROP_PREV_UPTIME = "ApplicationMonitorModel_prev_uptime";
  public static final String PROP_INVOKE_GC_SUPPORTED = "ApplicationMonitorModel_invoke_gc_supported";
  public static final String PROP_HEAP_DUMP_SUPPORTED = "ApplicationMonitorModel_heap_dump_supported";
  public static final String PROP_CPU_MONITORING_SUPPORTED = "ApplicationMonitorModel_cpu_monitoring_supported";
  public static final String PROP_GC_MONITORING_SUPPORTED = "ApplicationMonitorModel_gc_monitoring_supported";
  public static final String PROP_MEMORY_MONITORING_SUPPORTED = "ApplicationMonitorModel_memory_monitoring_supported";
  public static final String PROP_CLASS_MONITORING_SUPPORTED = "ApplicationMonitorModel_class_monitoring_supported";
  public static final String PROP_THREADS_MONITORING_SUPPORTED = "ApplicationMonitorModel_threads_monitoring_supported";
  public static final String PROP_NUMBER_OF_PROCESSORS = "ApplicationMonitorModel_number_of_processors";
  public static final String PROP_PROCESS_CPU_TIME = "ApplicationMonitorModel_process_cpu_time";
  public static final String PROP_PROCESS_GC_TIME = "ApplicationMonitorModel_process_gc_time";
  public static final String PROP_PREV_PROCESS_CPU_TIME = "ApplicationMonitorModel_prev_process_cpu_time";
  public static final String PROP_PREV_PROCESS_GC_TIME = "ApplicationMonitorModel_prev_process_gc_time";
  public static final String PROP_HEAP_CAPACITY = "ApplicationMonitorModel_heap_capacity";
  public static final String PROP_HEAP_USED = "ApplicationMonitorModel_heap_used";
  public static final String PROP_MAX_HEAP = "ApplicationMonitorModel_max_heap";
  public static final String PROP_PERMGEN_CAPACITY = "ApplicationMonitorModel_permgen_capacity";
  public static final String PROP_PERMGEN_USED = "ApplicationMonitorModel_permgen_used";
  public static final String PROP_PERMGEN_MAX = "ApplicationMonitorModel_permgen_max";
  public static final String PROP_SHARED_UNLOADED = "ApplicationMonitorModel_shared_unloaded";
  public static final String PROP_TOTAL_UNLOADED = "ApplicationMonitorModel_total_unloaded";
  public static final String PROP_SHARED_LOADED = "ApplicationMonitorModel_shared_loaded";
  public static final String PROP_TOTAL_LOADED = "ApplicationMonitorModel_total_loaded";
  public static final String PROP_TOTAL_THREADS = "ApplicationMonitorModel_total_threads";
  public static final String PROP_DAEMON_THREADS = "ApplicationMonitorModel_daemon_threads";
  public static final String PROP_PEAK_THREADS = "ApplicationMonitorModel_peak_threads";
  public static final String PROP_STARTED_THREADS = "ApplicationMonitorModel_started_threads";
  private static final String CPU_CHART_STORAGE = "monitor_cpu.dat";
  private static final String HEAP_CHART_STORAGE = "monitor_heap.dat";
  private static final String PERMGEN_CHART_STORAGE = "monitor_permgen.dat";
  private static final String CLASSES_CHART_STORAGE = "monitor_classes.dat";
  private static final String THREADS_CHART_STORAGE = "monitor_threads.dat";
  private boolean initialized;
  private final DataSource source;
  private final boolean live;
  private final List<ChangeListener> listeners;
  private Jvm jvm;
  private MemoryMXBean memoryMXBean;
  private MonitoredDataListener monitoredDataListener;
  private int chartCache = -1;
  private long timestamp = -1L;
  private long uptime = -1L;
  private long prevUpTime = -1L;
  private boolean takeHeapDumpSupported = false;
  private boolean cpuMonitoringSupported = false;
  private boolean gcMonitoringSupported = false;
  private boolean memoryMonitoringSupported = false;
  private boolean classMonitoringSupported = false;
  private boolean threadsMonitoringSupported = false;
  private int processorsCount = -1;
  private long processCpuTime = -1L;
  private long processGcTime = -1L;
  private long prevProcessCpuTime = -1L;
  private long prevProcessGcTime = -1L;
  private long heapCapacity = -1L;
  private long heapUsed = -1L;
  private long maxHeap = -1L;
  private long permgenCapacity = -1L;
  private long permgenUsed = -1L;
  private long permgenMax = -1L;
  private long sharedUnloaded = -1L;
  private long totalUnloaded = -1L;
  private long sharedLoaded = -1L;
  private long totalLoaded = -1L;
  private long totalThreads = -1L;
  private long daemonThreads = -1L;
  private long peakThreads = -1L;
  private long startedThreads = -1L;
  private SimpleXYChartSupport cpuChartSupport;
  private SimpleXYChartSupport heapChartSupport;
  private SimpleXYChartSupport permGenChartSupport;
  private SimpleXYChartSupport classesChartSupport;
  private SimpleXYChartSupport threadsChartSupport;
  
  public static ApplicationMonitorModel create(Application application, boolean live)
  {
    return new ApplicationMonitorModel(application, live);
  }
  
  public static ApplicationMonitorModel create(Snapshot snapshot)
  {
    return new ApplicationMonitorModel(snapshot, false);
  }
  
  public DataSource getSource()
  {
    return source;
  }
  
  public boolean isLive()
  {
    return live;
  }
  
  public MemoryMXBean getMemoryMXBean()
  {
    return memoryMXBean;
  }
  
  public int getChartCache()
  {
    return chartCache;
  }
  
  public boolean isInvokeGCSupported()
  {
    return memoryMXBean != null;
  }
  
  public boolean isTakeHeapDumpSupported()
  {
    return takeHeapDumpSupported;
  }
  
  public boolean isCpuMonitoringSupported()
  {
    return cpuMonitoringSupported;
  }
  
  public boolean isGcMonitoringSupported()
  {
    return gcMonitoringSupported;
  }
  
  public boolean isMemoryMonitoringSupported()
  {
    return memoryMonitoringSupported;
  }
  
  public boolean isClassMonitoringSupported()
  {
    return classMonitoringSupported;
  }
  
  public boolean isThreadsMonitoringSupported()
  {
    return threadsMonitoringSupported;
  }
  
  public int getProcessorsCount()
  {
    return processorsCount;
  }
  
  public long getTimestamp()
  {
    return timestamp;
  }
  
  public long getUpTime()
  {
    return uptime;
  }
  
  public long getPrevUpTime()
  {
    return prevUpTime;
  }
  
  public long getProcessCpuTime()
  {
    return processCpuTime;
  }
  
  public long getProcessGcTime()
  {
    return processGcTime;
  }
  
  public long getPrevProcessCpuTime()
  {
    return prevProcessCpuTime;
  }
  
  public long getPrevProcessGcTime()
  {
    return prevProcessGcTime;
  }
  
  public long getHeapCapacity()
  {
    return heapCapacity;
  }
  
  public long getHeapUsed()
  {
    return heapUsed;
  }
  
  public long getMaxHeap()
  {
    return maxHeap;
  }
  
  public long getPermgenCapacity()
  {
    return permgenCapacity;
  }
  
  public long getPermgenUsed()
  {
    return permgenUsed;
  }
  
  public long getPermgenMax()
  {
    return permgenMax;
  }
  
  public long getSharedUnloaded()
  {
    return sharedUnloaded;
  }
  
  public long getTotalUnloaded()
  {
    return totalUnloaded;
  }
  
  public long getSharedLoaded()
  {
    return sharedLoaded;
  }
  
  public long getTotalLoaded()
  {
    return totalLoaded;
  }
  
  public long getTotalThreads()
  {
    return totalThreads;
  }
  
  public long getDeamonThreads()
  {
    return daemonThreads;
  }
  
  public long getPeakThreads()
  {
    return peakThreads;
  }
  
  public long getStartedThreads()
  {
    return startedThreads;
  }
  
  public synchronized void initialize()
  {
    if (initialized) {
      return;
    }
    initialized = true;
    if ((source instanceof Application)) {
      initialize((Application)source);
    } else {
      initialize((Snapshot)source);
    }
  }
  
  public void registerCpuChartSupport(final SimpleXYChartSupport cpuChartSupport)
  {
    this.cpuChartSupport = cpuChartSupport;
    if ((cpuChartSupport != null) && ((source instanceof Snapshot))) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          File file = new File(source.getStorage().getDirectory(), "monitor_cpu.dat");
          if (file.isFile()) {
            ApplicationMonitorModel.loadChartSupport(cpuChartSupport, file);
          }
        }
      });
    }
  }
  
  public void registerHeapChartSupport(final SimpleXYChartSupport heapChartSupport)
  {
    this.heapChartSupport = heapChartSupport;
    if ((heapChartSupport != null) && ((source instanceof Snapshot))) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          File file = new File(source.getStorage().getDirectory(), "monitor_heap.dat");
          if (file.isFile()) {
            ApplicationMonitorModel.loadChartSupport(heapChartSupport, file);
          }
        }
      });
    }
  }
  
  public void registerPermGenChartSupport(SimpleXYChartSupport permgenChartSupport)
  {
    permGenChartSupport = permgenChartSupport;
    if ((permGenChartSupport != null) && ((source instanceof Snapshot))) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          File file = new File(source.getStorage().getDirectory(), "monitor_permgen.dat");
          if (file.isFile()) {
            ApplicationMonitorModel.loadChartSupport(permGenChartSupport, file);
          }
        }
      });
    }
  }
  
  public void registerClassesChartSupport(final SimpleXYChartSupport classesChartSupport)
  {
    this.classesChartSupport = classesChartSupport;
    if ((classesChartSupport != null) && ((source instanceof Snapshot))) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          File file = new File(source.getStorage().getDirectory(), "monitor_classes.dat");
          if (file.isFile()) {
            ApplicationMonitorModel.loadChartSupport(classesChartSupport, file);
          }
        }
      });
    }
  }
  
  public void registerThreadsChartSupport(final SimpleXYChartSupport threadsChartSupport)
  {
    this.threadsChartSupport = threadsChartSupport;
    if ((threadsChartSupport != null) && ((source instanceof Snapshot))) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          File file = new File(source.getStorage().getDirectory(), "monitor_threads.dat");
          if (file.isFile()) {
            ApplicationMonitorModel.loadChartSupport(threadsChartSupport, file);
          }
        }
      });
    }
  }
  
  public synchronized void cleanup()
  {
    listeners.clear();
    if (!initialized) {
      return;
    }
    if ((jvm != null) && (monitoredDataListener != null)) {
      jvm.removeMonitoredDataListener(monitoredDataListener);
    }
  }
  
  public void addChangeListener(ChangeListener listener)
  {
    if (live) {
      listeners.add(listener);
    }
  }
  
  public void removeChangeListener(ChangeListener listener)
  {
    if (live) {
      listeners.remove(listener);
    }
  }
  
  public void save(Snapshot snapshot)
  {
    initialize();
    
    Storage storage = snapshot.getStorage();
    
    setProperty(storage, "ApplicationMonitorModel_version", "1.0");
    
    setProperty(storage, "ApplicationMonitorModel_chart_cache", Integer.toString(chartCache));
    setProperty(storage, "ApplicationMonitorModel_uptime", Long.toString(uptime));
    setProperty(storage, "ApplicationMonitorModel_prev_uptime", Long.toString(prevUpTime));
    setProperty(storage, "ApplicationMonitorModel_cpu_monitoring_supported", Boolean.toString(cpuMonitoringSupported));
    setProperty(storage, "ApplicationMonitorModel_gc_monitoring_supported", Boolean.toString(gcMonitoringSupported));
    setProperty(storage, "ApplicationMonitorModel_memory_monitoring_supported", Boolean.toString(memoryMonitoringSupported));
    setProperty(storage, "ApplicationMonitorModel_class_monitoring_supported", Boolean.toString(classMonitoringSupported));
    setProperty(storage, "ApplicationMonitorModel_threads_monitoring_supported", Boolean.toString(threadsMonitoringSupported));
    setProperty(storage, "ApplicationMonitorModel_number_of_processors", Integer.toString(processorsCount));
    
    setProperty(storage, "ApplicationMonitorModel_process_cpu_time", Long.toString(processCpuTime));
    setProperty(storage, "ApplicationMonitorModel_process_gc_time", Long.toString(processGcTime));
    setProperty(storage, "ApplicationMonitorModel_prev_process_cpu_time", Long.toString(prevProcessCpuTime));
    setProperty(storage, "ApplicationMonitorModel_prev_process_gc_time", Long.toString(prevProcessGcTime));
    setProperty(storage, "ApplicationMonitorModel_heap_capacity", Long.toString(heapCapacity));
    setProperty(storage, "ApplicationMonitorModel_heap_used", Long.toString(heapUsed));
    setProperty(storage, "ApplicationMonitorModel_max_heap", Long.toString(maxHeap));
    setProperty(storage, "ApplicationMonitorModel_permgen_capacity", Long.toString(permgenCapacity));
    setProperty(storage, "ApplicationMonitorModel_permgen_used", Long.toString(permgenUsed));
    setProperty(storage, "ApplicationMonitorModel_permgen_max", Long.toString(permgenMax));
    setProperty(storage, "ApplicationMonitorModel_shared_unloaded", Long.toString(sharedUnloaded));
    setProperty(storage, "ApplicationMonitorModel_total_unloaded", Long.toString(totalUnloaded));
    setProperty(storage, "ApplicationMonitorModel_shared_loaded", Long.toString(sharedLoaded));
    setProperty(storage, "ApplicationMonitorModel_total_loaded", Long.toString(totalLoaded));
    setProperty(storage, "ApplicationMonitorModel_total_threads", Long.toString(totalThreads));
    setProperty(storage, "ApplicationMonitorModel_daemon_threads", Long.toString(daemonThreads));
    setProperty(storage, "ApplicationMonitorModel_peak_threads", Long.toString(peakThreads));
    setProperty(storage, "ApplicationMonitorModel_started_threads", Long.toString(startedThreads));
    
    File dir = storage.getDirectory();
    if ((cpuMonitoringSupported) || (gcMonitoringSupported)) {
      saveChartSupport(cpuChartSupport, new File(dir, "monitor_cpu.dat"));
    }
    if (memoryMonitoringSupported) {
      saveChartSupport(heapChartSupport, new File(dir, "monitor_heap.dat"));
    }
    if (memoryMonitoringSupported) {
      saveChartSupport(permGenChartSupport, new File(dir, "monitor_permgen.dat"));
    }
    if (classMonitoringSupported) {
      saveChartSupport(classesChartSupport, new File(dir, "monitor_classes.dat"));
    }
    if (threadsMonitoringSupported) {
      saveChartSupport(threadsChartSupport, new File(dir, "monitor_threads.dat"));
    }
  }
  
  private static void saveChartSupport(SimpleXYChartSupport chartSupport, File file)
  {
    if (chartSupport == null) {
      return;
    }
    OutputStream os = null;
    try
    {
      os = new FileOutputStream(file);
      chartSupport.saveValues(os); return;
    }
    catch (Exception e) {}finally
    {
      try
      {
        if (os != null) {
          os.close();
        }
      }
      catch (Exception e) {}
    }
  }
  
  private static void loadChartSupport(SimpleXYChartSupport chartSupport, File file)
  {
    InputStream is = null;
    try
    {
      is = new FileInputStream(file);
      chartSupport.loadValues(is); return;
    }
    catch (Exception e) {}finally
    {
      try
      {
        if (is != null) {
          is.close();
        }
      }
      catch (Exception e) {}
    }
  }
  
  private void initialize(Snapshot snapshot)
  {
    Storage storage = snapshot.getStorage();
    
    chartCache = Integer.parseInt(getProperty(storage, "ApplicationMonitorModel_chart_cache"));
    uptime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_uptime"));
    prevUpTime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_prev_uptime"));
    takeHeapDumpSupported = false;
    cpuMonitoringSupported = Boolean.parseBoolean(getProperty(storage, "ApplicationMonitorModel_cpu_monitoring_supported"));
    gcMonitoringSupported = Boolean.parseBoolean(getProperty(storage, "ApplicationMonitorModel_gc_monitoring_supported"));
    memoryMonitoringSupported = Boolean.parseBoolean(getProperty(storage, "ApplicationMonitorModel_memory_monitoring_supported"));
    classMonitoringSupported = Boolean.parseBoolean(getProperty(storage, "ApplicationMonitorModel_class_monitoring_supported"));
    threadsMonitoringSupported = Boolean.parseBoolean(getProperty(storage, "ApplicationMonitorModel_threads_monitoring_supported"));
    processorsCount = Integer.parseInt(getProperty(storage, "ApplicationMonitorModel_number_of_processors"));
    
    processCpuTime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_process_cpu_time"));
    processGcTime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_process_gc_time"));
    prevProcessCpuTime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_prev_process_cpu_time"));
    prevProcessGcTime = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_prev_process_gc_time"));
    heapCapacity = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_heap_capacity"));
    heapUsed = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_heap_used"));
    maxHeap = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_max_heap"));
    permgenCapacity = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_permgen_capacity"));
    permgenUsed = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_permgen_used"));
    permgenMax = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_permgen_max"));
    sharedUnloaded = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_shared_unloaded"));
    totalUnloaded = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_total_unloaded"));
    sharedLoaded = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_shared_loaded"));
    totalLoaded = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_total_loaded"));
    totalThreads = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_total_threads"));
    daemonThreads = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_daemon_threads"));
    peakThreads = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_peak_threads"));
    startedThreads = Long.parseLong(getProperty(storage, "ApplicationMonitorModel_started_threads"));
  }
  
  private static void setProperty(Storage storage, String property, String value)
  {
    storage.setCustomProperty(property, value == null ? "<not defined>" : value);
  }
  
  private static String getProperty(Storage storage, String property)
  {
    String value = storage.getCustomProperty(property);
    return "<not defined>".equals(value) ? null : value;
  }
  
  private void initialize(Application application)
  {
    GlobalPreferences preferences = GlobalPreferences.sharedInstance();
    chartCache = (preferences.getMonitoredDataCache() * 60 / preferences.getMonitoredDataPoll());
    
    processorsCount = 1;
    
    jvm = JvmFactory.getJVMFor(application);
    if (jvm != null)
    {
      HeapDumpSupport hds = HeapDumpSupport.getInstance();
      if (application.isLocalApplication()) {
        takeHeapDumpSupported = hds.supportsHeapDump(application);
      } else {
        takeHeapDumpSupported = hds.supportsRemoteHeapDump(application);
      }
      cpuMonitoringSupported = jvm.isCpuMonitoringSupported();
      gcMonitoringSupported = jvm.isCollectionTimeSupported();
      memoryMonitoringSupported = jvm.isMemoryMonitoringSupported();
      classMonitoringSupported = jvm.isClassMonitoringSupported();
      threadsMonitoringSupported = jvm.isThreadMonitoringSupported();
    }
    memoryMXBean = null;
    JmxModel jmxModel = JmxModelFactory.getJmxModelFor(application);
    if ((jmxModel != null) && (jmxModel.getConnectionState() == JmxModel.ConnectionState.CONNECTED))
    {
      JvmMXBeans mxbeans = JvmMXBeansFactory.getJvmMXBeans(jmxModel);
      if (mxbeans != null)
      {
        memoryMXBean = mxbeans.getMemoryMXBean();
        OperatingSystemMXBean osbean = mxbeans.getOperatingSystemMXBean();
        if (osbean != null) {
          processorsCount = osbean.getAvailableProcessors();
        }
      }
    }
    if (jvm != null)
    {
      updateValues(System.currentTimeMillis(), jvm.getMonitoredData());
      if (live)
      {
        monitoredDataListener = new MonitoredDataListener()
        {
          long lastTimestamp = -1L;
          
          public void monitoredDataEvent(MonitoredData data)
          {
            long timestamp = System.currentTimeMillis();
            final long timestampF = ++lastTimestamp;
            
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                ApplicationMonitorModel.this.updateValues(timestampF, val$data);
                ApplicationMonitorModel.this.fireChange();
              }
            });
          }
        };
        jvm.addMonitoredDataListener(monitoredDataListener);
      }
    }
  }
  
  private void updateValues(long time, MonitoredData data)
  {
    timestamp = time;
    if (data != null)
    {
      prevUpTime = uptime;
      uptime = data.getUpTime();
      if (cpuMonitoringSupported)
      {
        prevProcessCpuTime = processCpuTime;
        processCpuTime = data.getProcessCpuTime();
      }
      if (gcMonitoringSupported)
      {
        prevProcessGcTime = processGcTime;
        processGcTime = data.getCollectionTime();
      }
      if (memoryMonitoringSupported)
      {
        heapCapacity = data.getGenCapacity()[0];
        heapUsed = data.getGenUsed()[0];
        maxHeap = data.getGenMaxCapacity()[0];
        permgenCapacity = data.getGenCapacity()[1];
        permgenUsed = data.getGenUsed()[1];
        permgenMax = data.getGenMaxCapacity()[1];
      }
      if (classMonitoringSupported)
      {
        sharedUnloaded = data.getSharedUnloadedClasses();
        totalUnloaded = data.getUnloadedClasses();
        sharedLoaded = data.getSharedLoadedClasses();
        totalLoaded = data.getLoadedClasses();
      }
      if (threadsMonitoringSupported)
      {
        totalThreads = data.getThreadsLive();
        daemonThreads = data.getThreadsDaemon();
        peakThreads = data.getThreadsLivePeak();
        startedThreads = data.getThreadsStarted();
      }
    }
  }
  
  private void fireChange()
  {
    List<ChangeListener> list = new ArrayList();
    synchronized (listeners)
    {
      list.addAll(listeners);
    }
    ChangeListener l;
    for (Iterator i$ = list.iterator(); i$.hasNext(); l.stateChanged(new ChangeEvent(this))) {
      l = (ChangeListener)i$.next();
    }
  }
  
  private ApplicationMonitorModel(DataSource source, boolean live)
  {
    initialized = false;
    
    this.source = source;
    this.live = live;
    
    listeners = Collections.synchronizedList(new ArrayList());
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorModel
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

class ApplicationMonitorView$1
  implements Runnable
{
  ApplicationMonitorView$1(ApplicationMonitorView paramApplicationMonitorView, ApplicationMonitorView.MasterViewSupport paramMasterViewSupport, ApplicationMonitorView.CpuViewSupport paramCpuViewSupport, ApplicationMonitorView.HeapViewSupport paramHeapViewSupport, ApplicationMonitorView.PermGenViewSupport paramPermGenViewSupport, ApplicationMonitorView.ClassesViewSupport paramClassesViewSupport, ApplicationMonitorView.ThreadsViewSupport paramThreadsViewSupport) {}
  
  public void run()
  {
    val$masterViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
    val$cpuViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
    val$heapViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
    val$permGenViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
    val$classesViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
    val$threadsViewSupport.refresh(ApplicationMonitorView.access$000(this$0));
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorView.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

class ApplicationMonitorView$2
  implements ChangeListener
{
  ApplicationMonitorView$2(ApplicationMonitorView paramApplicationMonitorView, Runnable paramRunnable) {}
  
  public void stateChanged(ChangeEvent e)
  {
    val$refresher.run();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.application.views.monitor.ApplicationMonitorView.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.application.views.monitor;

import com.sun.tools.visualvm.charts.ChartFactory;
import com.sun.tools.visualvm.charts.SimpleXYChartDescriptor;
import com.sun.tools.visualvm.charts.SimpleXYChartSupport;
import com.sun.tools.visualvm.core.ui.components.DataViewComponent.DetailsView;
import com.sun.tools.visualvm.core.ui.components.NotSupportedDisplayer;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import org.openide.util.NbBundle;

class ApplicationMonitorView$ClassesViewSupport
  extends JPanel
{
  private static final String TOTAL_LOADED = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Total_loaded_classes");
  private static final String TOTAL_LOADED_LEG = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Total_loaded_classes_leg");
  private static final String SHARED_LOADED = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Shared_loaded_classes");
  private static final String SHARED_LOADED_LEG = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Shared_loaded_classes_leg");
  private static final String TOTAL_UNLOADED = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Total_unloaded_classes");
  private static final String SHARED_UNLOADED = NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Shared_unloaded_classes");
  private boolean liveModel;
  private boolean classMonitoringSupported;
  private SimpleXYChartSupport chartSupport;
  
  public ApplicationMonitorView$ClassesViewSupport(ApplicationMonitorModel model)
  {
    initModels(model);
    initComponents(model);
  }
  
  public DataViewComponent.DetailsView getDetailsView()
  {
    return new DataViewComponent.DetailsView(NbBundle.getMessage(ApplicationMonitorView.class, "LBL_Classes"), null, 10, this, null);
  }
  
  public void refresh(ApplicationMonitorModel model)
  {
    if (classMonitoringSupported)
    {
      long sharedUnloaded = model.getSharedUnloaded();
      long totalUnloaded = model.getTotalUnloaded();
      long sharedClasses = model.getSharedLoaded() - sharedUnloaded;
      long totalClasses = model.getTotalLoaded() - totalUnloaded + sharedClasses;
      if (liveModel) {
        chartSupport.addValues(model.getTimestamp(), new long[] { totalClasses, sharedClasses });
      }
      chartSupport.updateDetails(new String[] { chartSupport.formatDecimal(totalClasses), chartSupport.formatDecimal(sharedClasses), chartSupport.formatDecimal(totalUnloaded), chartSupport.formatDecimal(sharedUnloaded) });
    }
  }
  
  private void initModels(ApplicationMonitorModel model)
  {
    liveModel = model.isLive();
    classMonitoringSupported = model.isClassMonitoringSupported();
    
    SimpleXYChartDescriptor chartDescriptor = SimpleXYChartDescriptor.decimal(100L, false, model.getChartCache());
    
    chartDescriptor.addLineItems(new String[] { TOTAL_LOADED_LEG, SHARED_LOADED_LEG });
    chartDescriptor.setDetailsItems(new String[] { TOTAL_LOADED, SHARED_LOADED, TOTAL_UNLOADED, SHARED_UNLOADED });
    
    chartSupport = ChartFactory.createSimpleXYChart(chartDescriptor);
    model.registerClassesChartSupport(chartSupport);
  }
  
  private void initComponents(Appl
1 2 3 4 5

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd