From 530f6b9f2bf49734a93a246651de1ae5f7418078 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 23 Jul 2004 01:04:40 +0000 Subject: [PATCH] add getLocation method --- .../src/net/hyperic/sigar/SigarLoader.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bindings/java/src/net/hyperic/sigar/SigarLoader.java b/bindings/java/src/net/hyperic/sigar/SigarLoader.java index 2cce020e..9f9c8d0e 100644 --- a/bindings/java/src/net/hyperic/sigar/SigarLoader.java +++ b/bindings/java/src/net/hyperic/sigar/SigarLoader.java @@ -1,11 +1,14 @@ package net.hyperic.sigar; import net.hyperic.jni.ArchLoader; +import net.hyperic.jni.ArchLoaderException; import net.hyperic.jni.ArchName; import net.hyperic.jni.ArchNotSupportedException; public class SigarLoader extends ArchLoader { + private static String location = null; + public SigarLoader(Class loaderClass) { super(loaderClass); } @@ -34,4 +37,19 @@ public class SigarLoader extends ArchLoader { protected void systemLoad(String name) { System.load(name); } + + /** + * Returns the path where sigar.jar is located. + */ + public synchronized static String getLocation() { + if (location == null) { + SigarLoader loader = new SigarLoader(Sigar.class); + try { + location = loader.findJarPath("sigar.jar"); + } catch (ArchLoaderException e) { + location = "."; + } + } + return location; + } }