-Dsigar.ptql.native=true to enable testing native port

This commit is contained in:
Doug MacEachern 2007-03-07 05:08:19 +00:00
parent fe2125d9af
commit 537863b3c3
1 changed files with 17 additions and 0 deletions

View File

@ -23,10 +23,16 @@ import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.util.ReferenceMap;
public class ProcessQueryFactory implements Comparator {
//for testing until native port is completed
private static final boolean useNative =
"true".equals(System.getProperty("sigar.ptql.native"));
private static Map cache =
ReferenceMap.synchronizedMap();
@ -152,6 +158,17 @@ public class ProcessQueryFactory implements Comparator {
return pQuery;
}
if (useNative) {
pQuery = new SigarProcessQuery();
try {
((SigarProcessQuery)pQuery).create(query);
} catch (SigarException e) {
throw new MalformedQueryException(e.getMessage());
}
cache.put(query, pQuery);
return pQuery;
}
if (query.startsWith("Pid.PidFile.") ||
query.startsWith("Pid.Service."))
{