[SIGAR-29] Add simple counter name map to support language conversion

This commit is contained in:
Doug MacEachern 2007-01-19 00:58:34 +00:00
parent 0d58f9f281
commit 3981cadde4
2 changed files with 11 additions and 1 deletions

View File

@ -20,11 +20,13 @@ package org.hyperic.sigar.win32;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class Pdh extends Win32 {
private long query = -1l; // Handle to the query
private String hostname = null;
private Properties names;
public Pdh() throws Win32Exception {
this.query = pdhOpenQuery();
@ -35,6 +37,11 @@ public class Pdh extends Win32 {
this.hostname = hostName;
}
public Pdh(Properties names) throws Win32Exception {
this();
this.names = names;
}
protected void finalize() throws Throwable {
try {
this.close();
@ -72,6 +79,9 @@ public class Pdh extends Win32 {
if (this.hostname != null) {
pdhConnectMachine(this.hostname);
}
if (this.names != null) {
path = this.names.getProperty(path, path);
}
long counter = pdhAddCounter(this.query, path);
try {

View File

@ -28,7 +28,7 @@ public class TestPdh extends SigarTestCase {
}
private void getValue(String key) throws Exception {
Pdh pdh = new Pdh();
Pdh pdh = new Pdh(System.getProperties());
assertGtEqZeroTrace("raw..." + key,
(long)pdh.getRawValue(key));