Package be.yildizgames.common.libloader
Class NativeResourceLoader
java.lang.Object
be.yildizgames.common.libloader.NativeResourceLoader
public final class NativeResourceLoader extends Object
Utility class to load the native library from the classpath or a jar.
- Author:
- Grégory Van den Borre
-
Field Summary
Fields Modifier and Type Field Description StringdirectoryDirectory containing the native libraries, win34, linux64 depending on the operating system and the underlying architecture.PathlibDirectoryWill contains the native libraries to be loaded.StringlibraryExtensionLibrary file extension, can be .dll on windows, .so on linux. -
Method Summary
Modifier and Type Method Description static NativeResourceLoaderexternal(be.yildizgames.common.os.OperatingSystem... systemToSupport)Use libraries from a given path and register them.StringgetLibPath(String lib)Give the full path of a registered native library.List<String>getLoadedLibraries()static NativeResourceLoaderinJar()Retrieve the libraries in the class pass, decompress them and register them, support all systems.static NativeResourceLoaderinJar(be.yildizgames.common.os.OperatingSystem... systemToSupport)Retrieve the libraries in the class pass, decompress them and register them.static NativeResourceLoaderinJar(String path)static NativeResourceLoaderinJar(String path, be.yildizgames.common.os.OperatingSystem... systemToSupport)Retrieve the libraries in the class pass, decompress them in the provided path and register them.static NativeResourceLoaderinPath(String path, be.yildizgames.common.os.OperatingSystem... systemToSupport)static NativeResourceLoaderinTestPath(be.yildizgames.common.os.OperatingSystem... systemToSupport)voidloadBaseLibrary(String... libs)To load the shared libraries, only used for windows, on linux, will not load anything.voidloadLibrary(String... libs)Load a native library, it will check if it is contained in a jar, if so, the library will be extracted in a temporary place and loaded from there.
-
Field Details
-
directory
Directory containing the native libraries, win34, linux64 depending on the operating system and the underlying architecture. -
libDirectory
Will contains the native libraries to be loaded. -
libraryExtension
Library file extension, can be .dll on windows, .so on linux.
-
-
Method Details
-
inJar
public static NativeResourceLoader inJar(be.yildizgames.common.os.OperatingSystem... systemToSupport)Retrieve the libraries in the class pass, decompress them and register them.- Parameters:
systemToSupport- The list of system to support, cannot be null.- Returns:
- The created loader, never null.
-
inJar
Retrieve the libraries in the class pass, decompress them and register them, support all systems.- Returns:
- The created loader, never null.
-
inJar
public static NativeResourceLoader inJar(String path, be.yildizgames.common.os.OperatingSystem... systemToSupport)Retrieve the libraries in the class pass, decompress them in the provided path and register them.- Parameters:
path- Directory where the libs will be copied, cannot be null.systemToSupport- The list of system to support, cannot be null.- Returns:
- The created loader, never null.
-
inJar
-
inPath
public static NativeResourceLoader inPath(String path, be.yildizgames.common.os.OperatingSystem... systemToSupport) -
inTestPath
public static NativeResourceLoader inTestPath(be.yildizgames.common.os.OperatingSystem... systemToSupport) -
external
public static NativeResourceLoader external(be.yildizgames.common.os.OperatingSystem... systemToSupport)Use libraries from a given path and register them.- Parameters:
systemToSupport- The list of system to support.- Returns:
- The created loader.
-
getLibPath
Give the full path of a registered native library.- Parameters:
lib- Library to check.- Returns:
- The absolute path of the given library.
-
loadLibrary
Load a native library, it will check if it is contained in a jar, if so, the library will be extracted in a temporary place and loaded from there.- Parameters:
libs- Native library name to load, cannot be null.
-
loadBaseLibrary
To load the shared libraries, only used for windows, on linux, will not load anything.- Parameters:
libs- Libraries to be loaded only on windows.
-
getLoadedLibraries
-