Package org.fusesource.jansi.internal
Class JansiLoader
- java.lang.Object
-
- org.fusesource.jansi.internal.JansiLoader
-
public class JansiLoader extends java.lang.ObjectSet the system properties, org.jansi.lib.path, org.jansi.lib.name, appropriately so that jansi can find *.dll, *.jnilib and *.so files, according to the current OS (win, linux, mac).The library files are automatically extracted from this project's package (JAR).
usage: call
initialize()before using Jansi.
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanextractedprivate static java.lang.StringnativeLibraryPathprivate static java.lang.StringnativeLibrarySourceUrl
-
Constructor Summary
Constructors Constructor Description JansiLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidcleanup()Deleted old native libraries e.g.private static java.lang.StringcontentsEquals(java.io.InputStream in1, java.io.InputStream in2)private static voidcopy(java.io.InputStream in, java.io.OutputStream out)private static booleanextractAndLoadLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)Extracts and loads the specified library file to the target folderstatic intgetMajorVersion()static intgetMinorVersion()static java.lang.StringgetNativeLibraryPath()static java.lang.StringgetNativeLibrarySourceUrl()private static java.io.FilegetTempDir()static java.lang.StringgetVersion()private static booleanhasResource(java.lang.String path)static booleaninitialize()Loads Jansi native library.private static java.lang.Stringjoin(java.util.List<java.lang.String> list, java.lang.String separator)private static voidloadJansiNativeLibrary()Loads jansi library using given path and name of the library.private static booleanloadNativeLibrary(java.io.File libPath)Loads native library using the given path and name of the library.private static java.lang.StringrandomUUID()private static intreadNBytes(java.io.InputStream in, byte[] b)
-
-
-
Method Detail
-
initialize
public static boolean initialize()
Loads Jansi native library.- Returns:
- True if jansi native library is successfully loaded; false otherwise.
-
getNativeLibraryPath
public static java.lang.String getNativeLibraryPath()
-
getNativeLibrarySourceUrl
public static java.lang.String getNativeLibrarySourceUrl()
-
getTempDir
private static java.io.File getTempDir()
-
cleanup
static void cleanup()
Deleted old native libraries e.g. on Windows the DLL file is not removed on VM-Exit (bug #80)
-
readNBytes
private static int readNBytes(java.io.InputStream in, byte[] b) throws java.io.IOException- Throws:
java.io.IOException
-
contentsEquals
private static java.lang.String contentsEquals(java.io.InputStream in1, java.io.InputStream in2) throws java.io.IOException- Throws:
java.io.IOException
-
extractAndLoadLibraryFile
private static boolean extractAndLoadLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)Extracts and loads the specified library file to the target folder- Parameters:
libFolderForCurrentOS- Library path.libraryFileName- Library name.targetFolder- Target folder.- Returns:
-
randomUUID
private static java.lang.String randomUUID()
-
copy
private static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
loadNativeLibrary
private static boolean loadNativeLibrary(java.io.File libPath)
Loads native library using the given path and name of the library.- Parameters:
libPath- Path of the native library.- Returns:
- True for successfully loading; false otherwise.
-
loadJansiNativeLibrary
private static void loadJansiNativeLibrary() throws java.lang.ExceptionLoads jansi library using given path and name of the library.- Throws:
java.lang.Exception
-
hasResource
private static boolean hasResource(java.lang.String path)
-
getMajorVersion
public static int getMajorVersion()
- Returns:
- The major version of the jansi library.
-
getMinorVersion
public static int getMinorVersion()
- Returns:
- The minor version of the jansi library.
-
getVersion
public static java.lang.String getVersion()
- Returns:
- The version of the jansi library.
-
join
private static java.lang.String join(java.util.List<java.lang.String> list, java.lang.String separator)
-
-