remove process finder SigarProxy usage

This commit is contained in:
Doug MacEachern 2007-04-22 00:21:00 +00:00
parent 439f1eab1c
commit 4de6d48008
3 changed files with 14 additions and 24 deletions

View File

@ -26,16 +26,17 @@ import org.hyperic.sigar.SigarProxyCache;
public class ProcessFinder { public class ProcessFinder {
private SigarProxy proxy; private Sigar sigar;
/**
* @deprecated
*/
public ProcessFinder(SigarProxy proxy) { public ProcessFinder(SigarProxy proxy) {
this.proxy = proxy; this(SigarProxyCache.getSigar(proxy));
//getpid() cache to optimize queries on this process.
this.proxy.getPid();
} }
private Sigar getSigar() { public ProcessFinder(Sigar sigar) {
return SigarProxyCache.getSigar(this.proxy); this.sigar = sigar;
} }
public long findSingleProcess(String query) public long findSingleProcess(String query)
@ -50,7 +51,7 @@ public class ProcessFinder {
throws SigarException { throws SigarException {
if (query instanceof SigarProcessQuery) { if (query instanceof SigarProcessQuery) {
return ((SigarProcessQuery)query).findProcess(getSigar()); return ((SigarProcessQuery)query).findProcess(this.sigar);
} }
throw new SigarNotImplementedException(); throw new SigarNotImplementedException();
@ -59,18 +60,13 @@ public class ProcessFinder {
public static long[] find(Sigar sigar, String query) public static long[] find(Sigar sigar, String query)
throws SigarException { throws SigarException {
SigarProxy proxy = return new ProcessFinder(sigar).find(query);
SigarProxyCache.newInstance(sigar);
return find(proxy, query);
} }
public static long[] find(SigarProxy sigar, String query) public static long[] find(SigarProxy sigar, String query)
throws SigarException { throws SigarException {
ProcessFinder finder = new ProcessFinder(sigar); return new ProcessFinder(sigar).find(query);
return finder.find(ProcessQueryFactory.getInstance(query));
} }
public long[] find(String query) public long[] find(String query)
@ -83,7 +79,7 @@ public class ProcessFinder {
throws SigarException { throws SigarException {
if (query instanceof SigarProcessQuery) { if (query instanceof SigarProcessQuery) {
return ((SigarProcessQuery)query).findProcesses(getSigar()); return ((SigarProcessQuery)query).findProcesses(this.sigar);
} }
throw new SigarNotImplementedException(); throw new SigarNotImplementedException();

View File

@ -19,10 +19,10 @@
package org.hyperic.sigar.ptql; package org.hyperic.sigar.ptql;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarProxy; import org.hyperic.sigar.Sigar;
public interface ProcessQuery { public interface ProcessQuery {
public boolean match(SigarProxy sigar, long pid) public boolean match(Sigar sigar, long pid)
throws SigarException; throws SigarException;
} }

View File

@ -37,15 +37,9 @@ public class SigarProcessQuery implements ProcessQuery {
destroy(); destroy();
} }
private native boolean match(Sigar sigar, long pid) public native boolean match(Sigar sigar, long pid)
throws SigarException; throws SigarException;
public boolean match(SigarProxy sigar, long pid)
throws SigarException {
return match(SigarProxyCache.getSigar(sigar), pid);
}
public native long findProcess(Sigar sigar) public native long findProcess(Sigar sigar)
throws SigarException; throws SigarException;