com-sun-tools-visualvm-tools

16:34:04.817 INFO  jd.cli.Main - Decompiling com-sun-tools-visualvm-tools.jar
package com.sun.tools.visualvm.tools.attach;

import com.sun.tools.visualvm.application.jvm.HeapHistogram;
import com.sun.tools.visualvm.core.model.Model;
import java.util.Properties;

public abstract class AttachModel
  extends Model
{
  public abstract Properties getSystemProperties();
  
  public abstract boolean takeHeapDump(String paramString);
  
  public abstract String takeThreadDump();
  
  public abstract HeapHistogram takeHeapHistogram();
  
  public abstract String printFlag(String paramString);
  
  public abstract void setFlag(String paramString1, String paramString2);
}

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

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.core.model.ModelFactory;

public final class AttachModelFactory
  extends ModelFactory<AttachModel, Application>
{
  private static AttachModelFactory attachFactory;
  
  public static synchronized AttachModelFactory getDefault()
  {
    if (attachFactory == null) {
      attachFactory = new AttachModelFactory();
    }
    return attachFactory;
  }
  
  public static AttachModel getAttachFor(Application app)
  {
    return (AttachModel)getDefault().getModel(app);
  }
}

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

interface package-info {}

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

import javax.management.MBeanServerConnection;

public abstract interface CachedMBeanServerConnection
  extends MBeanServerConnection, MBeanCacheOperations
{}

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

class CachedMBeanServerConnectionFactory$1 {}

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

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import javax.management.MBeanServerConnection;

class CachedMBeanServerConnectionFactory$Snapshot
{
  public static CachedMBeanServerConnection newSnapshot(MBeanServerConnection mbsc, int interval)
  {
    InvocationHandler ih = new CachedMBeanServerConnectionFactory.SnapshotInvocationHandler(mbsc, interval);
    return (CachedMBeanServerConnection)Proxy.newProxyInstance(Snapshot.class.getClassLoader(), new Class[] { CachedMBeanServerConnection.class }, ih);
  }
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class CachedMBeanServerConnectionFactory$SnapshotInvocationHandler$1
  implements ActionListener
{
  CachedMBeanServerConnectionFactory$SnapshotInvocationHandler$1(CachedMBeanServerConnectionFactory.SnapshotInvocationHandler paramSnapshotInvocationHandler) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.intervalElapsed();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.tools.jmx.CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.tools.jmx;

class CachedMBeanServerConnectionFactory$SnapshotInvocationHandler$2
  implements Runnable
{
  CachedMBeanServerConnectionFactory$SnapshotInvocationHandler$2(CachedMBeanServerConnectionFactory.SnapshotInvocationHandler paramSnapshotInvocationHandler) {}
  
  public void run()
  {
    this$0.flush();
    CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.access$000(this$0);
    this$0.notifyListeners();
    CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.access$102(this$0, false);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.tools.jmx.CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.tools.jmx;

import java.util.HashMap;

final class CachedMBeanServerConnectionFactory$SnapshotInvocationHandler$NameValueMap
  extends HashMap<String, Object>
{}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.tools.jmx.CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.NameValueMap
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.tools.jmx;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.swing.Timer;
import org.openide.util.RequestProcessor;

class CachedMBeanServerConnectionFactory$SnapshotInvocationHandler
  implements InvocationHandler
{
  private final MBeanServerConnection conn;
  private final int interval;
  private Timer timer = null;
  private Map<ObjectName, NameValueMap> cachedValues = newMap();
  private Map<ObjectName, Set<String>> cachedNames = newMap();
  private List<MBeanCacheListener> listenerList = new CopyOnWriteArrayList();
  private volatile boolean flushRunning;
  
  CachedMBeanServerConnectionFactory$SnapshotInvocationHandler(MBeanServerConnection conn, int interval)
  {
    this.conn = conn;
    this.interval = interval;
    if (interval > 0)
    {
      timer = new Timer(interval, new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          intervalElapsed();
        }
      });
      timer.setCoalesce(true);
      timer.start();
    }
  }
  
  void intervalElapsed()
  {
    if (flushRunning) {
      return;
    }
    flushRunning = true;
    RequestProcessor.getDefault().post(new Runnable()
    {
      public void run()
      {
        flush();
        CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.this.connectionPinger();
        notifyListeners();
        flushRunning = false;
      }
    });
  }
  
  void notifyListeners()
  {
    for (MBeanCacheListener listener : listenerList) {
      listener.flushed();
    }
  }
  
  private void connectionPinger()
  {
    try
    {
      conn.getDefaultDomain();
    }
    catch (Exception e)
    {
      timer.stop();
      listenerList.clear();
      cachedValues.clear();
      cachedNames.clear();
      Collection<Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>>> values = CachedMBeanServerConnectionFactory.access$200().values();
      for (Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>> value : values) {
        value.remove(conn);
      }
    }
  }
  
  synchronized void flush()
  {
    cachedValues = newMap();
  }
  
  int getInterval()
  {
    return interval;
  }
  
  void addMBeanCacheListener(MBeanCacheListener listener)
  {
    listenerList.add(listener);
  }
  
  void removeMBeanCacheListener(MBeanCacheListener listener)
  {
    listenerList.remove(listener);
  }
  
  public Object invoke(Object proxy, Method method, Object[] args)
    throws Throwable
  {
    String methodName = method.getName();
    if (methodName.equals("getAttribute")) {
      return getAttribute((ObjectName)args[0], (String)args[1]);
    }
    if (methodName.equals("getAttributes")) {
      return getAttributes((ObjectName)args[0], (String[])args[1]);
    }
    if (methodName.equals("flush"))
    {
      flush();
      return null;
    }
    if (methodName.equals("getInterval")) {
      return Integer.valueOf(getInterval());
    }
    if (methodName.equals("addMBeanCacheListener"))
    {
      addMBeanCacheListener((MBeanCacheListener)args[0]);
      return null;
    }
    if (methodName.equals("removeMBeanCacheListener"))
    {
      removeMBeanCacheListener((MBeanCacheListener)args[0]);
      return null;
    }
    try
    {
      return method.invoke(conn, args);
    }
    catch (InvocationTargetException e)
    {
      throw e.getCause();
    }
  }
  
  private Object getAttribute(ObjectName objName, String attrName)
    throws MBeanException, InstanceNotFoundException, AttributeNotFoundException, ReflectionException, IOException
  {
    NameValueMap values = getCachedAttributes(objName, Collections.singleton(attrName));
    
    Object value = values.get(attrName);
    if ((value != null) || (values.containsKey(attrName))) {
      return value;
    }
    return conn.getAttribute(objName, attrName);
  }
  
  private AttributeList getAttributes(ObjectName objName, String[] attrNames)
    throws InstanceNotFoundException, ReflectionException, IOException
  {
    NameValueMap values = getCachedAttributes(objName, new TreeSet(Arrays.asList(attrNames)));
    
    AttributeList list = new AttributeList();
    for (String attrName : attrNames)
    {
      Object value = values.get(attrName);
      if ((value != null) || (values.containsKey(attrName))) {
        list.add(new Attribute(attrName, value));
      }
    }
    return list;
  }
  
  private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames)
    throws InstanceNotFoundException, ReflectionException, IOException
  {
    NameValueMap values = (NameValueMap)cachedValues.get(objName);
    if ((values != null) && (values.keySet().containsAll(attrNames))) {
      return values;
    }
    attrNames = new TreeSet(attrNames);
    Set<String> oldNames = (Set)cachedNames.get(objName);
    if (oldNames != null) {
      attrNames.addAll(oldNames);
    }
    values = new NameValueMap(null);
    AttributeList attrs = conn.getAttributes(objName, (String[])attrNames.toArray(new String[attrNames.size()]));
    for (Attribute attr : attrs.asList()) {
      values.put(attr.getName(), attr.getValue());
    }
    cachedValues.put(objName, values);
    cachedNames.put(objName, attrNames);
    return values;
  }
  
  private static <K, V> Map<K, V> newMap()
  {
    return new HashMap();
  }
  
  private static final class NameValueMap
    extends HashMap<String, Object>
  {}
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.swing.Timer;
import org.openide.util.RequestProcessor;

public final class CachedMBeanServerConnectionFactory
{
  private static final Map<Integer, Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>>> snapshots = new HashMap();
  
  public static CachedMBeanServerConnection getCachedMBeanServerConnection(MBeanServerConnection mbsc)
  {
    return getCachedMBeanServerConnection(mbsc, 0);
  }
  
  public static CachedMBeanServerConnection getCachedMBeanServerConnection(MBeanServerConnection mbsc, int interval)
    throws IllegalArgumentException
  {
    if (interval < 0) {
      throw new IllegalArgumentException("interval cannot be negative");
    }
    return retrieveCachedMBeanServerConnection(mbsc, interval);
  }
  
  public static CachedMBeanServerConnection getCachedMBeanServerConnection(JmxModel jmx)
  {
    return getCachedMBeanServerConnection(jmx.getMBeanServerConnection(), 0);
  }
  
  public static CachedMBeanServerConnection getCachedMBeanServerConnection(JmxModel jmx, int interval)
    throws IllegalArgumentException
  {
    return getCachedMBeanServerConnection(jmx.getMBeanServerConnection(), interval);
  }
  
  private static synchronized CachedMBeanServerConnection retrieveCachedMBeanServerConnection(MBeanServerConnection mbsc, int interval)
  {
    Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>> mbscMap = (Map)snapshots.get(Integer.valueOf(interval));
    if (mbscMap == null)
    {
      CachedMBeanServerConnection cmbsc = Snapshot.newSnapshot(mbsc, interval);
      Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>> mbscMapNew = new WeakHashMap();
      
      mbscMapNew.put(mbsc, new WeakReference(cmbsc));
      snapshots.put(Integer.valueOf(interval), mbscMapNew);
      return cmbsc;
    }
    WeakReference<CachedMBeanServerConnection> cmbscRef = (WeakReference)mbscMap.get(mbsc);
    CachedMBeanServerConnection cmbsc = cmbscRef == null ? null : (CachedMBeanServerConnection)cmbscRef.get();
    if (cmbsc == null)
    {
      cmbsc = Snapshot.newSnapshot(mbsc, interval);
      mbscMap.put(mbsc, new WeakReference(cmbsc));
    }
    return cmbsc;
  }
  
  static class Snapshot
  {
    public static CachedMBeanServerConnection newSnapshot(MBeanServerConnection mbsc, int interval)
    {
      InvocationHandler ih = new CachedMBeanServerConnectionFactory.SnapshotInvocationHandler(mbsc, interval);
      return (CachedMBeanServerConnection)Proxy.newProxyInstance(Snapshot.class.getClassLoader(), new Class[] { CachedMBeanServerConnection.class }, ih);
    }
  }
  
  static class SnapshotInvocationHandler
    implements InvocationHandler
  {
    private final MBeanServerConnection conn;
    private final int interval;
    private Timer timer = null;
    private Map<ObjectName, NameValueMap> cachedValues = newMap();
    private Map<ObjectName, Set<String>> cachedNames = newMap();
    private List<MBeanCacheListener> listenerList = new CopyOnWriteArrayList();
    private volatile boolean flushRunning;
    
    SnapshotInvocationHandler(MBeanServerConnection conn, int interval)
    {
      this.conn = conn;
      this.interval = interval;
      if (interval > 0)
      {
        timer = new Timer(interval, new ActionListener()
        {
          public void actionPerformed(ActionEvent e)
          {
            intervalElapsed();
          }
        });
        timer.setCoalesce(true);
        timer.start();
      }
    }
    
    void intervalElapsed()
    {
      if (flushRunning) {
        return;
      }
      flushRunning = true;
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          flush();
          CachedMBeanServerConnectionFactory.SnapshotInvocationHandler.this.connectionPinger();
          notifyListeners();
          flushRunning = false;
        }
      });
    }
    
    void notifyListeners()
    {
      for (MBeanCacheListener listener : listenerList) {
        listener.flushed();
      }
    }
    
    private void connectionPinger()
    {
      try
      {
        conn.getDefaultDomain();
      }
      catch (Exception e)
      {
        timer.stop();
        listenerList.clear();
        cachedValues.clear();
        cachedNames.clear();
        Collection<Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>>> values = CachedMBeanServerConnectionFactory.snapshots.values();
        for (Map<MBeanServerConnection, WeakReference<CachedMBeanServerConnection>> value : values) {
          value.remove(conn);
        }
      }
    }
    
    synchronized void flush()
    {
      cachedValues = newMap();
    }
    
    int getInterval()
    {
      return interval;
    }
    
    void addMBeanCacheListener(MBeanCacheListener listener)
    {
      listenerList.add(listener);
    }
    
    void removeMBeanCacheListener(MBeanCacheListener listener)
    {
      listenerList.remove(listener);
    }
    
    public Object invoke(Object proxy, Method method, Object[] args)
      throws Throwable
    {
      String methodName = method.getName();
      if (methodName.equals("getAttribute")) {
        return getAttribute((ObjectName)args[0], (String)args[1]);
      }
      if (methodName.equals("getAttributes")) {
        return getAttributes((ObjectName)args[0], (String[])args[1]);
      }
      if (methodName.equals("flush"))
      {
        flush();
        return null;
      }
      if (methodName.equals("getInterval")) {
        return Integer.valueOf(getInterval());
      }
      if (methodName.equals("addMBeanCacheListener"))
      {
        addMBeanCacheListener((MBeanCacheListener)args[0]);
        return null;
      }
      if (methodName.equals("removeMBeanCacheListener"))
      {
        removeMBeanCacheListener((MBeanCacheListener)args[0]);
        return null;
      }
      try
      {
        return method.invoke(conn, args);
      }
      catch (InvocationTargetException e)
      {
        throw e.getCause();
      }
    }
    
    private Object getAttribute(ObjectName objName, String attrName)
      throws MBeanException, InstanceNotFoundException, AttributeNotFoundException, ReflectionException, IOException
    {
      NameValueMap values = getCachedAttributes(objName, Collections.singleton(attrName));
      
      Object value = values.get(attrName);
      if ((value != null) || (values.containsKey(attrName))) {
        return value;
      }
      return conn.getAttribute(objName, attrName);
    }
    
    private AttributeList getAttributes(ObjectName objName, String[] attrNames)
      throws InstanceNotFoundException, ReflectionException, IOException
    {
      NameValueMap values = getCachedAttributes(objName, new TreeSet(Arrays.asList(attrNames)));
      
      AttributeList list = new AttributeList();
      for (String attrName : attrNames)
      {
        Object value = values.get(attrName);
        if ((value != null) || (values.containsKey(attrName))) {
          list.add(new Attribute(attrName, value));
        }
      }
      return list;
    }
    
    private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames)
      throws InstanceNotFoundException, ReflectionException, IOException
    {
      NameValueMap values = (NameValueMap)cachedValues.get(objName);
      if ((values != null) && (values.keySet().containsAll(attrNames))) {
        return values;
      }
      attrNames = new TreeSet(attrNames);
      Set<String> oldNames = (Set)cachedNames.get(objName);
      if (oldNames != null) {
        attrNames.addAll(oldNames);
      }
      values = new NameValueMap(null);
      AttributeList attrs = conn.getAttributes(objName, (String[])attrNames.toArray(new String[attrNames.size()]));
      for (Attribute attr : attrs.asList()) {
        values.put(attr.getName(), attr.getValue());
      }
      cachedValues.put(objName, values);
      cachedNames.put(objName, attrNames);
      return values;
    }
    
    private static <K, V> Map<K, V> newMap()
    {
      return new HashMap();
    }
    
    private static final class NameValueMap
      extends HashMap<String, Object>
    {}
  }
}

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

public enum JmxModel$ConnectionState
{
  CONNECTED,  DISCONNECTED,  CONNECTING;
  
  private JmxModel$ConnectionState() {}
}

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

import com.sun.tools.visualvm.core.datasupport.AsyncPropertyChangeSupport;
import com.sun.tools.visualvm.core.model.Model;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Properties;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXServiceURL;

public abstract class JmxModel
  extends Model
{
  protected PropertyChangeSupport propertyChangeSupport;
  public static final String CONNECTION_STATE_PROPERTY = "connectionState";
  
  public JmxModel()
  {
    propertyChangeSupport = new AsyncPropertyChangeSupport(this);
  }
  
  public static enum ConnectionState
  {
    CONNECTED,  DISCONNECTED,  CONNECTING;
    
    private ConnectionState() {}
  }
  
  public void addPropertyChangeListener(PropertyChangeListener listener)
  {
    propertyChangeSupport.addPropertyChangeListener(listener);
  }
  
  public void removePropertyChangeListener(PropertyChangeListener listener)
  {
    propertyChangeSupport.removePropertyChangeListener(listener);
  }
  
  public abstract ConnectionState getConnectionState();
  
  public abstract MBeanServerConnection getMBeanServerConnection();
  
  public abstract JMXServiceURL getJMXServiceURL();
  
  public abstract Properties getSystemProperties();
  
  public abstract boolean isTakeHeapDumpSupported();
  
  public abstract boolean takeHeapDump(String paramString);
  
  public abstract boolean isTakeThreadDumpSupported();
  
  public abstract String takeThreadDump();
  
  public abstract String takeThreadDump(long[] paramArrayOfLong);
  
  public abstract String getFlagValue(String paramString);
  
  public abstract void setFlagValue(String paramString1, String paramString2);
}

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

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.core.model.ModelFactory;

public final class JmxModelFactory
  extends ModelFactory<JmxModel, Application>
{
  private static JmxModelFactory factory;
  
  public static synchronized JmxModelFactory getDefault()
  {
    if (factory == null) {
      factory = new JmxModelFactory();
    }
    return factory;
  }
  
  public static JmxModel getJmxModelFor(Application app)
  {
    return (JmxModel)getDefault().getModel(app);
  }
}

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

import java.lang.management.ClassLoadingMXBean;
import java.lang.management.CompilationMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryManagerMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean;
import java.util.Collection;
import java.util.logging.LoggingMXBean;
import javax.management.ObjectName;

public abstract interface JvmMXBeans
  extends MBeanCacheOperations
{
  public abstract ClassLoadingMXBean getClassLoadingMXBean();
  
  public abstract CompilationMXBean getCompilationMXBean();
  
  public abstract LoggingMXBean getLoggingMXBean();
  
  public abstract Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans();
  
  public abstract Collection<MemoryManagerMXBean> getMemoryManagerMXBeans();
  
  public abstract MemoryMXBean getMemoryMXBean();
  
  public abstract Collection<MemoryPoolMXBean> getMemoryPoolMXBeans();
  
  public abstract OperatingSystemMXBean getOperatingSystemMXBean();
  
  public abstract RuntimeMXBean getRuntimeMXBean();
  
  public abstract ThreadMXBean getThreadMXBean();
  
  public abstract <T> T getMXBean(ObjectName paramObjectName, Class<T> paramClass);
}

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

import java.io.IOException;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.CompilationMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryManagerMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LoggingMXBean;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

class JvmMXBeansFactory$JvmMXBeansImpl
  implements JvmMXBeans
{
  protected MBeanServerConnection mbsc;
  private ClassLoadingMXBean classLoadingMXBean = null;
  private CompilationMXBean compilationMXBean = null;
  private LoggingMXBean loggingMXBean = null;
  private MemoryMXBean memoryMXBean = null;
  private OperatingSystemMXBean operatingSystemMXBean = null;
  private RuntimeMXBean runtimeMXBean = null;
  private ThreadMXBean threadMXBean = null;
  private List<GarbageCollectorMXBean> garbageCollectorMXBeans = null;
  private List<MemoryManagerMXBean> memoryManagerMXBeans = null;
  private List<MemoryPoolMXBean> memoryPoolMXBeans = null;
  private static final Logger LOGGER = Logger.getLogger(JvmMXBeansImpl.class.getName());
  
  public JvmMXBeansFactory$JvmMXBeansImpl(MBeanServerConnection mbsc)
  {
    this.mbsc = mbsc;
  }
  
  public synchronized ClassLoadingMXBean getClassLoadingMXBean()
  {
    if ((mbsc != null) && (classLoadingMXBean == null)) {
      classLoadingMXBean = ((ClassLoadingMXBean)getMXBean("java.lang:type=ClassLoading", ClassLoadingMXBean.class));
    }
    return classLoadingMXBean;
  }
  
  public synchronized CompilationMXBean getCompilationMXBean()
  {
    if ((mbsc != null) && (compilationMXBean == null)) {
      compilationMXBean = ((CompilationMXBean)getMXBean("java.lang:type=Compilation", CompilationMXBean.class));
    }
    return compilationMXBean;
  }
  
  public synchronized LoggingMXBean getLoggingMXBean()
  {
    if ((mbsc != null) && (loggingMXBean == null)) {
      loggingMXBean = ((LoggingMXBean)getMXBean("java.util.logging:type=Logging", LoggingMXBean.class));
    }
    return loggingMXBean;
  }
  
  public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans()
  {
    if ((mbsc != null) && (garbageCollectorMXBeans == null))
    {
      ObjectName gcName;
      try
      {
        gcName = new ObjectName("java.lang:type=GarbageCollector,*");
      }
      catch (MalformedObjectNameException e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
        return null;
      }
      Set<ObjectName> mbeans;
      try
      {
        mbeans = mbsc.queryNames(gcName, null);
      }
      catch (Exception e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
        return null;
      }
      if (mbeans != null)
      {
        garbageCollectorMXBeans = new ArrayList();
        for (ObjectName on : mbeans)
        {
          String name = "java.lang:type=GarbageCollector,name=" + on.getKeyProperty("name");
          try
          {
            GarbageCollectorMXBean mbean = (GarbageCollectorMXBean)ManagementFactory.newPlatformMXBeanProxy(mbsc, name, GarbageCollectorMXBean.class);
            garbageCollectorMXBeans.add(mbean);
          }
          catch (Exception e)
          {
            LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
          }
        }
      }
    }
    return garbageCollectorMXBeans;
  }
  
  public synchronized Collection<MemoryManagerMXBean> getMemoryManagerMXBeans()
  {
    if ((mbsc != null) && (memoryManagerMXBeans == null))
    {
      ObjectName managerName;
      try
      {
        managerName = new ObjectName("java.lang:type=MemoryManager,*");
      }
      catch (MalformedObjectNameException e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryManagerMXBeans", e);
        return null;
      }
      Set<ObjectName> mbeans;
      try
      {
        mbeans = mbsc.queryNames(managerName, null);
      }
      catch (Exception e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryManagerMXBeans", e);
        return null;
      }
      if (mbeans != null)
      {
        memoryManagerMXBeans = new ArrayList();
        for (ObjectName on : mbeans)
        {
          String name = "java.lang:type=MemoryManager,name=" + on.getKeyProperty("name");
          try
          {
            MemoryManagerMXBean mbean = (MemoryManagerMXBean)ManagementFactory.newPlatformMXBeanProxy(mbsc, name, MemoryManagerMXBean.class);
            memoryManagerMXBeans.add(mbean);
          }
          catch (Exception e)
          {
            LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryManagerMXBeans", e);
          }
        }
      }
    }
    return memoryManagerMXBeans;
  }
  
  public synchronized MemoryMXBean getMemoryMXBean()
  {
    if ((mbsc != null) && (memoryMXBean == null)) {
      memoryMXBean = ((MemoryMXBean)getMXBean("java.lang:type=Memory", MemoryMXBean.class));
    }
    return memoryMXBean;
  }
  
  public synchronized Collection<MemoryPoolMXBean> getMemoryPoolMXBeans()
  {
    if ((mbsc != null) && (memoryPoolMXBeans == null))
    {
      ObjectName poolName;
      try
      {
        poolName = new ObjectName("java.lang:type=MemoryPool,*");
      }
      catch (MalformedObjectNameException e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryPoolMXBeans", e);
        return null;
      }
      Set<ObjectName> mbeans;
      try
      {
        mbeans = mbsc.queryNames(poolName, null);
      }
      catch (Exception e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryPoolMXBeans", e);
        return null;
      }
      if (mbeans != null)
      {
        memoryPoolMXBeans = new ArrayList();
        for (ObjectName on : mbeans)
        {
          String name = "java.lang:type=MemoryPool,name=" + on.getKeyProperty("name");
          try
          {
            MemoryPoolMXBean mbean = (MemoryPoolMXBean)ManagementFactory.newPlatformMXBeanProxy(mbsc, name, MemoryPoolMXBean.class);
            memoryPoolMXBeans.add(mbean);
          }
          catch (Exception e)
          {
            LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMemoryPoolMXBeans", e);
          }
        }
      }
    }
    return memoryPoolMXBeans;
  }
  
  public synchronized OperatingSystemMXBean getOperatingSystemMXBean()
  {
    if ((mbsc != null) && (operatingSystemMXBean == null)) {
      operatingSystemMXBean = ((OperatingSystemMXBean)getMXBean("java.lang:type=OperatingSystem", OperatingSystemMXBean.class));
    }
    return operatingSystemMXBean;
  }
  
  public synchronized RuntimeMXBean getRuntimeMXBean()
  {
    if ((mbsc != null) && (runtimeMXBean == null)) {
      runtimeMXBean = ((RuntimeMXBean)getMXBean("java.lang:type=Runtime", RuntimeMXBean.class));
    }
    return runtimeMXBean;
  }
  
  public synchronized ThreadMXBean getThreadMXBean()
  {
    if ((mbsc != null) && (threadMXBean == null)) {
      threadMXBean = ((ThreadMXBean)getMXBean("java.lang:type=Threading", ThreadMXBean.class));
    }
    return threadMXBean;
  }
  
  public <T> T getMXBean(ObjectName objectName, Class<T> interfaceClass)
  {
    return (T)getMXBean(objectName.toString(), interfaceClass);
  }
  
  <T> T getMXBean(String objectNameStr, Class<T> interfaceClass)
  {
    if (mbsc != null) {
      try
      {
        return (T)ManagementFactory.newPlatformMXBeanProxy(mbsc, objectNameStr, interfaceClass);
      }
      catch (IOException e)
      {
        LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getMXBean", e);
      }
      catch (IllegalArgumentException iae)
      {
        LOGGER.log(Level.INFO, JvmMXBeansImpl.class.getName() + ".getMXBean()", iae);
      }
    }
    return null;
  }
  
  public void addMBeanCacheListener(MBeanCacheListener listener)
  {
    if ((mbsc instanceof CachedMBeanServerConnection)) {
      ((CachedMBeanServerConnection)mbsc).addMBeanCacheListener(listener);
    } else {
      throw new UnsupportedOperationException("The underlying MBeanServerConnection does not support caching.");
    }
  }
  
  public void removeMBeanCacheListener(MBeanCacheListener listener)
  {
    if ((mbsc instanceof CachedMBeanServerConnection)) {
      ((CachedMBeanServerConnection)mbsc).removeMBeanCacheListener(listener);
    } else {
      throw new UnsupportedOperationException("The underlying MBeanServerConnection does not support caching.");
    }
  }
  
  public void flush()
  {
    if ((mbsc instanceof CachedMBeanServerConnection)) {
      ((CachedMBeanServerConnection)mbsc).flush();
    } else {
      throw new UnsupportedOperationException("The underlying MBeanServerConnection does not support caching.");
    }
  }
  
  public int getInterval()
  {
    if ((mbsc instanceof CachedMBeanServerConnection)) {
      return ((CachedMBeanServerConnection)mbsc).getInterval();
    }
    throw new UnsupportedOperationException("The underlying MBeanServerConnection does not support caching.");
  }
}

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

import java.io.IOException;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.CompilationMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryManagerMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LoggingMXBean;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

public final class JvmMXBeansFactory
{
  public static JvmMXBeans getJvmMXBeans(MBeanServerConnection mbsc)
  {
    return new JvmMXBeansImpl(mbsc);
  }
  
  public static JvmMXBeans getJvmMXBeans(MBeanServerConnection mbsc, int interval)
    throws IllegalArgumentException
  {
    if (interval < 0) {
      throw new IllegalArgumentException("interval cannot be negative");
    }
    return new JvmMXBeansImpl(CachedMBeanServerConnectionFactory.getCachedMBeanServerConnection(mbsc, interval));
  }
  
  public static JvmMXBeans getJvmMXBeans(JmxModel jmx)
  {
    return new JvmMXBeansImpl(jmx.getMBeanServerConnection());
  }
  
  public static JvmMXBeans getJvmMXBeans(JmxModel jmx, int interval)
    throws IllegalArgumentException
  {
    if (interval < 0) {
      throw new IllegalArgumentException("interval cannot be negative");
    }
    return new JvmMXBeansImpl(CachedMBeanServerConnectionFactory.getCachedMBeanServerConnection(jmx.getMBeanServerConnection(), interval));
  }
  
  static class JvmMXBeansImpl
    implements JvmMXBeans
  {
    protected MBeanServerConnection mbsc;
    private ClassLoadingMXBean classLoadingMXBean = null;
    private CompilationMXBean compilationMXBean = null;
    private LoggingMXBean loggingMXBean = null;
    private MemoryMXBean memoryMXBean = null;
    private OperatingSystemMXBean operatingSystemMXBean = null;
    private RuntimeMXBean runtimeMXBean = null;
    private ThreadMXBean threadMXBean = null;
    private List<GarbageCollectorMXBean> garbageCollectorMXBeans = null;
    private List<MemoryManagerMXBean> memoryManagerMXBeans = null;
    private List<MemoryPoolMXBean> memoryPoolMXBeans = null;
    private static final Logger LOGGER = Logger.getLogger(JvmMXBeansImpl.class.getName());
    
    public JvmMXBeansImpl(MBeanServerConnection mbsc)
    {
      this.mbsc = mbsc;
    }
    
    public synchronized ClassLoadingMXBean getClassLoadingMXBean()
    {
      if ((mbsc != null) && (classLoadingMXBean == null)) {
        classLoadingMXBean = ((ClassLoadingMXBean)getMXBean("java.lang:type=ClassLoading", ClassLoadingMXBean.class));
      }
      return classLoadingMXBean;
    }
    
    public synchronized CompilationMXBean getCompilationMXBean()
    {
      if ((mbsc != null) && (compilationMXBean == null)) {
        compilationMXBean = ((CompilationMXBean)getMXBean("java.lang:type=Compilation", CompilationMXBean.class));
      }
      return compilationMXBean;
    }
    
    public synchronized LoggingMXBean getLoggingMXBean()
    {
      if ((mbsc != null) && (loggingMXBean == null)) {
        loggingMXBean = ((LoggingMXBean)getMXBean("java.util.logging:type=Logging", LoggingMXBean.class));
      }
      return loggingMXBean;
    }
    
    public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans()
    {
      if ((mbsc != null) && (garbageCollectorMXBeans == null))
      {
        ObjectName gcName;
        try
        {
          gcName = new ObjectName("java.lang:type=GarbageCollector,*");
        }
        catch (MalformedObjectNameException e)
        {
          LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
          return null;
        }
        Set<ObjectName> mbeans;
        try
        {
          mbeans = mbsc.queryNames(gcName, null);
        }
        catch (Exception e)
        {
          LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
          return null;
        }
        if (mbeans != null)
        {
          garbageCollectorMXBeans = new ArrayList();
          for (ObjectName on : mbeans)
          {
            String name = "java.lang:type=GarbageCollector,name=" + on.getKeyProperty("name");
            try
            {
              GarbageCollectorMXBean mbean = (GarbageCollectorMXBean)ManagementFactory.newPlatformMXBeanProxy(mbsc, name, GarbageCollectorMXBean.class);
              garbageCollectorMXBeans.add(mbean);
            }
            catch (Exception e)
            {
              LOGGER.throwing(JvmMXBeansImpl.class.getName(), "getGarbageCollectorMXBeans", e);
            }
          }
        }
      }
      return garbageCollectorMXBeans;
    }
    
1 2

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