From c9ef9f4bb62bed8223c619cd3840bdaf0cf7eb0b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 21 Apr 2010 13:47:06 -0700 Subject: [PATCH] add close() method --- bindings/java/src/org/hyperic/sigar/Humidor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/Humidor.java b/bindings/java/src/org/hyperic/sigar/Humidor.java index c039bded..542d687e 100644 --- a/bindings/java/src/org/hyperic/sigar/Humidor.java +++ b/bindings/java/src/org/hyperic/sigar/Humidor.java @@ -36,7 +36,7 @@ public class Humidor { private Object LOCK = new Object(); private InvocationHandler _handler; private SigarProxy _sigar; - private Sigar _impl; + private Sigar _impl, _inst; private Humidor() {} @@ -69,7 +69,7 @@ public class Humidor { synchronized(LOCK) { if (_sigar == null) { if (_impl == null) { - _impl = new Sigar(); + _inst = _impl = new Sigar(); } _handler = new MyHandler(_impl); _sigar = (SigarProxy) @@ -84,4 +84,13 @@ public class Humidor { public static Humidor getInstance() { return INSTANCE; } + + //close the Sigar instance if getSigar() created it + public void close() { + if (_inst != null) { + _inst.close(); + _impl = _inst = null; + } + _sigar = null; + } }