Package com.goterl.lazysodium.utils
Class LibraryLoader
- java.lang.Object
-
- com.goterl.lazysodium.utils.LibraryLoader
-
public final class LibraryLoader extends java.lang.ObjectA simple library class which helps with loading dynamic sodium library stored in the JAR archive. Works with JNA.This class is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLibraryLoader.ModeLibrary loading mode controls which libraries are attempted to be loaded (installed in the system or bundled in the Lazysodium JAR) and in which order.
-
Constructor Summary
Constructors Constructor Description LibraryLoader(java.util.List<java.lang.Class> classesToRegister)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetSodiumPathInResources()Returns the absolute path to sodium library inside JAR (beginning with '/'), e.g.voidloadAbsolutePath(java.lang.String absPath)voidloadLibrary(LibraryLoader.Mode mode, java.lang.String systemFallBack)Loads the sodium library and registers the native methods ofSodiumandSodiumJavausing the specified loading mode.voidloadSystemLibrary(java.lang.String library)
-
-
-
Method Detail
-
loadLibrary
public void loadLibrary(LibraryLoader.Mode mode, java.lang.String systemFallBack)
Loads the sodium library and registers the native methods ofSodiumandSodiumJavausing the specified loading mode. The library will be loaded at most once.- Parameters:
mode- controls which sodium library (installed in the system or bundled in the JAR) is loaded, and in which ordersystemFallBack- If loading directly fails then it will fall to the system fallback specified here- Throws:
LibraryLoadingException- if fails to load the library- See Also:
Native.register(Class, String)
-
loadSystemLibrary
public void loadSystemLibrary(java.lang.String library)
-
loadAbsolutePath
public void loadAbsolutePath(java.lang.String absPath)
-
getSodiumPathInResources
public static java.lang.String getSodiumPathInResources()
Returns the absolute path to sodium library inside JAR (beginning with '/'), e.g. /linux/libsodium.so.- Returns:
- The path to the libsodium binary.
-
-