add getLocation method
This commit is contained in:
		
							parent
							
								
									e3e5ce3eb7
								
							
						
					
					
						commit
						530f6b9f2b
					
				@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user