diff --git a/bindings/java/src/org/hyperic/sigar/jmx/AbstractMBean.java b/bindings/java/src/org/hyperic/sigar/jmx/AbstractMBean.java index 873f813e..7aab1e46 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/AbstractMBean.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/AbstractMBean.java @@ -46,8 +46,8 @@ import org.hyperic.sigar.SigarProxyCache; */ public abstract class AbstractMBean implements DynamicMBean, MBeanRegistration { - protected static final String MBEAN_DOMAIN = SigarInvokerJMX.DOMAIN_NAME; - protected static final String MBEAN_ATTR_TYPE = SigarInvokerJMX.PROP_TYPE; + public static final String MBEAN_DOMAIN = SigarInvokerJMX.DOMAIN_NAME; + public static final String MBEAN_ATTR_TYPE = SigarInvokerJMX.PROP_TYPE; protected static final short CACHED_30SEC = 0; diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java index 8c62fff2..7c766bf2 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java @@ -21,6 +21,7 @@ package org.hyperic.sigar.jmx; import org.hyperic.sigar.ProcCpu; import org.hyperic.sigar.ProcFd; import org.hyperic.sigar.ProcMem; +import org.hyperic.sigar.ProcUtil; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarProxy; @@ -82,6 +83,23 @@ public class SigarProcess implements SigarProcessMBean { } } + public String getObjectName() throws SigarException { + long pid = getPid(); + String name = this.sigar.getProcState(pid).getName(); + String cls = "unknown"; + if (name.startsWith("java")) { + try { + cls = ProcUtil.getJavaMainClass(this.sigar, pid); + } catch (SigarException e) {} + } //else XXX + return + AbstractMBean.MBEAN_DOMAIN + ":" + + AbstractMBean.MBEAN_ATTR_TYPE + "=" + "Process" + "," + + "Name" + "=" + name + "," + + "Class" + "=" + cls + "," + + "Pid" + "=" + pid; + } + public long getPid() { if (this.pid < 0) { return this.sigar.getPid();