Class LibraryLoader

java.lang.Object
com.codevasp.lazysodium.utils.LibraryLoader

public final class LibraryLoader extends Object
A simple library class which helps with loading dynamic sodium library stored in the JAR archive. Works with JNA.

This class is thread-safe.

See Also:
  • Constructor Details

    • LibraryLoader

      public LibraryLoader(List<Class> classesToRegister)
  • Method Details

    • getSodiumPathInResources

      public static 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.
    • loadLibrary

      public void loadLibrary(LibraryLoader.Mode mode, String systemFallBack)
      Loads the sodium library and registers the native methods of Sodium and SodiumJava using 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 order
      systemFallBack - 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(String library)
    • loadAbsolutePath

      public void loadAbsolutePath(String absPath)