Class Loader

java.lang.Object
ch.bailu.gtk.lib.jna.Loader

public class Loader extends Object
Configurable loader for loading JNA API instances
  • Method Details

    • load

      public static <T extends com.sun.jna.Library> T load(@Nonnull String libraryName, @Nonnull Class<T> interfaceClass)
      Load Interface from library. This also tries to load library from alternative library names
      Parameters:
      libraryName - default libraryName
      interfaceClass - JNA interface
      Returns:
      Instance of interface
    • getInstance

      public static Loader getInstance()
      Get Instance of Loader
      Returns:
      Loader instance
    • loadInterface

      public <T extends com.sun.jna.Library> T loadInterface(@Nonnull String libraryName, @Nonnull Class<T> interfaceClass)
      Load Interface from library. This also tries to load library from alternative library names
      Parameters:
      libraryName - default libraryName
      interfaceClass - JNA interface
      Returns:
      Instance of interface
    • addAlternative

      public void addAlternative(String libraryName, String lib)
      Add alternative library name to default library name
      Parameters:
      libraryName - default library name
      lib - alternative library name
    • loadAlternatives

      public void loadAlternatives(String resourcePath) throws IOException
      Load alternative library names from java property file Format of property file: Key: default library name Value: alt-name1,alt-name2,...
      Parameters:
      resourcePath - path to java property file (from resource root)
      Throws:
      IOException - if property file can't be loaded
    • loadAlternatives

      public void loadAlternatives(InputStream stream) throws IOException
      Load alternative library names from stream to java property file Format of property file: Key: default library name Value: alt-name1,alt-name2,...
      Parameters:
      stream - java property file as stream
      Throws:
      IOException - If property can't be loaded