From 4de6d480087445bc1e8ce7cd4a4edaaf7a6ff96f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 22 Apr 2007 00:21:00 +0000 Subject: [PATCH] remove process finder SigarProxy usage --- .../org/hyperic/sigar/ptql/ProcessFinder.java | 26 ++++++++----------- .../org/hyperic/sigar/ptql/ProcessQuery.java | 4 +-- .../hyperic/sigar/ptql/SigarProcessQuery.java | 8 +----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/ptql/ProcessFinder.java b/bindings/java/src/org/hyperic/sigar/ptql/ProcessFinder.java index 9ce76e14..3db15e8d 100644 --- a/bindings/java/src/org/hyperic/sigar/ptql/ProcessFinder.java +++ b/bindings/java/src/org/hyperic/sigar/ptql/ProcessFinder.java @@ -26,16 +26,17 @@ import org.hyperic.sigar.SigarProxyCache; public class ProcessFinder { - private SigarProxy proxy; + private Sigar sigar; + /** + * @deprecated + */ public ProcessFinder(SigarProxy proxy) { - this.proxy = proxy; - //getpid() cache to optimize queries on this process. - this.proxy.getPid(); + this(SigarProxyCache.getSigar(proxy)); } - private Sigar getSigar() { - return SigarProxyCache.getSigar(this.proxy); + public ProcessFinder(Sigar sigar) { + this.sigar = sigar; } public long findSingleProcess(String query) @@ -50,7 +51,7 @@ public class ProcessFinder { throws SigarException { if (query instanceof SigarProcessQuery) { - return ((SigarProcessQuery)query).findProcess(getSigar()); + return ((SigarProcessQuery)query).findProcess(this.sigar); } throw new SigarNotImplementedException(); @@ -59,18 +60,13 @@ public class ProcessFinder { public static long[] find(Sigar sigar, String query) throws SigarException { - SigarProxy proxy = - SigarProxyCache.newInstance(sigar); - - return find(proxy, query); + return new ProcessFinder(sigar).find(query); } public static long[] find(SigarProxy sigar, String query) throws SigarException { - ProcessFinder finder = new ProcessFinder(sigar); - - return finder.find(ProcessQueryFactory.getInstance(query)); + return new ProcessFinder(sigar).find(query); } public long[] find(String query) @@ -83,7 +79,7 @@ public class ProcessFinder { throws SigarException { if (query instanceof SigarProcessQuery) { - return ((SigarProcessQuery)query).findProcesses(getSigar()); + return ((SigarProcessQuery)query).findProcesses(this.sigar); } throw new SigarNotImplementedException(); diff --git a/bindings/java/src/org/hyperic/sigar/ptql/ProcessQuery.java b/bindings/java/src/org/hyperic/sigar/ptql/ProcessQuery.java index 2c15d0c4..f282ea2a 100644 --- a/bindings/java/src/org/hyperic/sigar/ptql/ProcessQuery.java +++ b/bindings/java/src/org/hyperic/sigar/ptql/ProcessQuery.java @@ -19,10 +19,10 @@ package org.hyperic.sigar.ptql; import org.hyperic.sigar.SigarException; -import org.hyperic.sigar.SigarProxy; +import org.hyperic.sigar.Sigar; public interface ProcessQuery { - public boolean match(SigarProxy sigar, long pid) + public boolean match(Sigar sigar, long pid) throws SigarException; } diff --git a/bindings/java/src/org/hyperic/sigar/ptql/SigarProcessQuery.java b/bindings/java/src/org/hyperic/sigar/ptql/SigarProcessQuery.java index 8be64733..14b61afb 100644 --- a/bindings/java/src/org/hyperic/sigar/ptql/SigarProcessQuery.java +++ b/bindings/java/src/org/hyperic/sigar/ptql/SigarProcessQuery.java @@ -37,15 +37,9 @@ public class SigarProcessQuery implements ProcessQuery { destroy(); } - private native boolean match(Sigar sigar, long pid) + public native boolean match(Sigar sigar, long pid) throws SigarException; - public boolean match(SigarProxy sigar, long pid) - throws SigarException { - - return match(SigarProxyCache.getSigar(sigar), pid); - } - public native long findProcess(Sigar sigar) throws SigarException;