/** * Extracts the native bindings for sigar and tells sigar where to find them. * * @param nativeLibDir the directory the native libs should be stored to * @return the folder that contains the extracted nativeLibs * @throws Exception */ private static void loadNativeSigarBindings(File nativeLibDir) throws Exception { extractFromJarToTemp(SIGAR_RESOURCE_DIR + new SigarLoader(Sigar.class).getLibraryName(), nativeLibDir); System.setProperty(SIGAR_PATH, nativeLibDir.getAbsolutePath()); nativeLibDir.getAbsolutePath(); }
final SigarLoader archLoader = new SigarLoader(getClass()); archLoader.setName("sigar"); final String name = archLoader.getLibraryName(); File fl = new File(nativeDirectory, name); addNativeDirectoryToLibPath(nativeDirectory);
private static List<String> getSigarLibFiles() { try { String libName = new SigarLoader(SigarProxy.class).getLibraryName(); if (SIGAR_X86_WINNT_DLL.equals(libName)) { return Arrays.asList(SIGAR_X86_WINNT_DLL, SIGAR_X86_WINNT_LIB); } else { return Collections.singletonList(libName); } } catch (ArchNotSupportedException e) { throw new RuntimeException(e); } } }
/** * Check silently if sigar was loaded in order to avoid the SigarException: no libsigar-*. * * @return true, if Sigar native library is present in the ClassLoader otherwise false. * @throws IllegalAccessException * @throws NoSuchFieldException */ private static boolean isSigarAlreadyLoaded() throws Exception { final String libraryName = new SigarLoader(Sigar.class).getLibraryName(); final Field loadedLibraryNames = ClassLoader.class.getDeclaredField("loadedLibraryNames"); loadedLibraryNames.setAccessible(true); final Vector<String> libraries = (Vector<String>) loadedLibraryNames.get(SigarProvisioner.class.getClassLoader()); for (String library: libraries) { if(library.contains(libraryName)) return true; } return false; }
/** * Extracts the native bindings for sigar and tells sigar where to find them. * * @param nativeLibDir the directory the native libs should be stored to * @return the folder that contains the extracted nativeLibs * @throws Exception */ private static void loadNativeSigarBindings(File nativeLibDir) throws Exception { extractFromJarToTemp(SIGAR_RESOURCE_DIR + new SigarLoader(Sigar.class).getLibraryName(), nativeLibDir); System.setProperty(SIGAR_PATH, nativeLibDir.getAbsolutePath()); nativeLibDir.getAbsolutePath(); }
final String libraryName = sigarLoader.getLibraryName();
final String path = System.getProperty(systemProp); if (path == null) { final String libraryName = loader.getLibraryName(); final File output = new File(tempDir, "sigar/" + libraryName); if (!output.exists()) {