SigarProcess.close only applies to SigarProcess(void) constructor
This commit is contained in:
parent
bf361a1732
commit
b3603f4489
|
@ -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) {
|
||||||
|
|
|
@ -40,17 +40,19 @@ 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() {
|
||||||
|
if (this.sigarImpl != null) {
|
||||||
this.sigarImpl.close();
|
this.sigarImpl.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private RuntimeException unexpectedError(String type,
|
private RuntimeException unexpectedError(String type,
|
||||||
SigarException e) {
|
SigarException e) {
|
||||||
|
|
Loading…
Reference in New Issue