Package ch.bailu.gtk.lib.jna
Class Loader
java.lang.Object
ch.bailu.gtk.lib.jna.Loader
Configurable loader for loading JNA API instances
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAlternative
(String libraryName, String lib) Add alternative library name to default library namestatic Loader
Get Instance of Loaderstatic <T extends com.sun.jna.Library>
TLoad Interface from library.void
loadAlternatives
(InputStream stream) Load alternative library names from stream to java property file Format of property file: Key: default library name Value: alt-name1,alt-name2,...void
loadAlternatives
(String resourcePath) Load alternative library names from java property file Format of property file: Key: default library name Value: alt-name1,alt-name2,...<T extends com.sun.jna.Library>
TloadInterface
(String libraryName, Class<T> interfaceClass) Load Interface from library.
-
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 libraryNameinterfaceClass
- JNA interface- Returns:
- Instance of interface
-
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 libraryNameinterfaceClass
- JNA interface- Returns:
- Instance of interface
-
addAlternative
Add alternative library name to default library name- Parameters:
libraryName
- default library namelib
- alternative library name
-
loadAlternatives
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
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
-