/** * Determine the right FreeBSD library depending on the architecture. * * @param library The library name. * @param osName The operating system name. * @param osArch The system architecture. * @return The library resource. * @throws UnsupportedOperationException Throw an exception if no native library for this platform * was found. */ private static String determineFreebsdLibrary( final String library, final String osName, final String osArch ) { String resourceName; String platform = null; String fileExtension = "so"; switch (osArch) { case ARCH_AMD64: case ARCH_X86_64: platform = "freebsd-x64"; break; default: unsupportedPlatform(osName, osArch); } resourceName = "/" + platform + "/" + library + "." + fileExtension; return resourceName; }
unsupportedPlatform(osName, osArch);
/** * Find the right shared library, depending on the operating system and architecture. * * @throws UnsupportedOperationException Throw an exception if no native library for this platform * was found. */ private static URL findLibraryResource(final String libraryFileName) { String osName = System.getProperty("os.name").toLowerCase(); String osArch = System.getProperty("os.arch").toLowerCase(); String resourceName = null; if (osName.startsWith(OS_WIN)) { resourceName = determineWindowsLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_LINUX)) { resourceName = determineLinuxLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_FREEBSD)) { resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_MAC)) { resourceName = determineMacLibrary(libraryFileName); } else { unsupportedPlatform(osName, osArch); } URL resource = NativeLoader.class.getResource(resourceName); if (null == resource) { unsupportedPlatform(osName, osArch, resourceName); } return resource; }