SigarProcess.close only applies to SigarProcess(void) constructor

This commit is contained in:
Doug MacEachern 2009-04-29 14:34:40 -07:00
parent bf361a1732
commit b3603f4489
2 changed files with 9 additions and 7 deletions

View File

@ -71,7 +71,7 @@ public class Mx extends SigarCommandBase {
SigarRegistry registry = new SigarRegistry(this.proxy); SigarRegistry registry = new SigarRegistry(this.proxy);
try { try {
server.registerMBean(registry, null); server.registerMBean(registry, null);
SigarProcess proc = new SigarProcess(); SigarProcess proc = new SigarProcess(this.sigar);
server.registerMBean(proc, new ObjectName(proc.getObjectName())); server.registerMBean(proc, new ObjectName(proc.getObjectName()));
isRegistered = true; isRegistered = true;
} catch (Exception e) { } catch (Exception e) {

View File

@ -40,16 +40,18 @@ public class SigarProcess implements SigarProcessMBean {
private long pid = -1; private long pid = -1;
public SigarProcess() { public SigarProcess() {
this(new Sigar()); this.sigarImpl = new Sigar();
}
public SigarProcess(Sigar sigar) {
this.sigarImpl = sigar;
this.sigar = SigarProxyCache.newInstance(sigarImpl); this.sigar = SigarProxyCache.newInstance(sigarImpl);
} }
public SigarProcess(SigarProxy sigar) {
this.sigar = sigar;
}
public void close() { public void close() {
this.sigarImpl.close(); if (this.sigarImpl != null) {
this.sigarImpl.close();
}
} }
private RuntimeException unexpectedError(String type, private RuntimeException unexpectedError(String type,