Package org.xerial.snappy
Class SnappyLoader
- java.lang.Object
-
- org.xerial.snappy.SnappyLoader
-
public class SnappyLoader extends java.lang.ObjectInternal only - Do not use this class. This class loads a native library of snappy-java (snappyjava.dll, libsnappy.so, etc.) according to the user platform (os.name and os.arch). The natively compiled libraries bundled to snappy-java contain the codes of the original snappy and JNI programs to access Snappy. In default, no configuration is required to use snappy-java, but you can load your own native library created by 'make native' command. This SnappyLoader searches for native libraries (snappyjava.dll, libsnappy.so, etc.) in the following order:- If system property org.xerial.snappy.use.systemlib is set to true, lookup folders specified by java.lib.path system property (This is the default path that JVM searches for native libraries)
- (System property: org.xerial.snappy.lib.path)/(System property: org.xerial.lib.name)
- One of the libraries embedded in snappy-java-(version).jar extracted into (System property: java.io.tempdir). If org.xerial.snappy.tempdir is set, use this folder instead of java.io.tempdir.
If you do not want to use folder java.io.tempdir, set the System property org.xerial.snappy.tempdir. For example, to use /tmp/leo as a temporary folder to copy native libraries, use -D option of JVM:
java -Dorg.xerial.snappy.tempdir="/tmp/leo" ...
-
-
Field Summary
Fields Modifier and Type Field Description private static SnappyNativeapiprivate static booleanisLoadedstatic java.lang.StringKEY_SNAPPY_DISABLE_BUNDLED_LIBSstatic java.lang.StringKEY_SNAPPY_LIB_NAMEstatic java.lang.StringKEY_SNAPPY_LIB_PATHstatic java.lang.StringKEY_SNAPPY_TEMPDIRstatic java.lang.StringKEY_SNAPPY_USE_SYSTEMLIBprivate static java.io.FilenativeLibFilestatic java.lang.StringSNAPPY_SYSTEM_PROPERTIES_FILE
-
Constructor Summary
Constructors Constructor Description SnappyLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidcleanUpExtractedNativeLib()private static booleancontentsEquals(java.io.InputStream in1, java.io.InputStream in2)private static java.io.FileextractLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)Extract the specified library file to the target folder(package private) static java.io.FilefindNativeLibrary()static java.lang.StringgetVersion()Get the snappy-java version by reading pom.properties embedded in jar.private static booleanhasResource(java.lang.String path)(package private) static SnappyNativeload()private static voidloadNativeLibrary()Load a native library of snappy-javaprivate static voidloadSnappySystemProperties()load system properties when configuration file of the nameSNAPPY_SYSTEM_PROPERTIES_FILEis found(package private) static voidsetApi(SnappyNative nativeCode)Set the api instance.
-
-
-
Field Detail
-
SNAPPY_SYSTEM_PROPERTIES_FILE
public static final java.lang.String SNAPPY_SYSTEM_PROPERTIES_FILE
- See Also:
- Constant Field Values
-
KEY_SNAPPY_LIB_PATH
public static final java.lang.String KEY_SNAPPY_LIB_PATH
- See Also:
- Constant Field Values
-
KEY_SNAPPY_LIB_NAME
public static final java.lang.String KEY_SNAPPY_LIB_NAME
- See Also:
- Constant Field Values
-
KEY_SNAPPY_TEMPDIR
public static final java.lang.String KEY_SNAPPY_TEMPDIR
- See Also:
- Constant Field Values
-
KEY_SNAPPY_USE_SYSTEMLIB
public static final java.lang.String KEY_SNAPPY_USE_SYSTEMLIB
- See Also:
- Constant Field Values
-
KEY_SNAPPY_DISABLE_BUNDLED_LIBS
public static final java.lang.String KEY_SNAPPY_DISABLE_BUNDLED_LIBS
- See Also:
- Constant Field Values
-
isLoaded
private static volatile boolean isLoaded
-
api
private static volatile SnappyNative api
-
nativeLibFile
private static java.io.File nativeLibFile
-
-
Method Detail
-
cleanUpExtractedNativeLib
static void cleanUpExtractedNativeLib()
-
setApi
static void setApi(SnappyNative nativeCode)
Set the api instance.- Parameters:
nativeCode-
-
loadSnappySystemProperties
private static void loadSnappySystemProperties()
load system properties when configuration file of the nameSNAPPY_SYSTEM_PROPERTIES_FILEis found
-
load
static SnappyNative load()
-
loadNativeLibrary
private static void loadNativeLibrary()
Load a native library of snappy-java
-
contentsEquals
private static boolean contentsEquals(java.io.InputStream in1, java.io.InputStream in2) throws java.io.IOException- Throws:
java.io.IOException
-
extractLibraryFile
private static java.io.File extractLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)Extract the specified library file to the target folder- Parameters:
libFolderForCurrentOS-libraryFileName-targetFolder-- Returns:
-
findNativeLibrary
static java.io.File findNativeLibrary()
-
hasResource
private static boolean hasResource(java.lang.String path)
-
getVersion
public static java.lang.String getVersion()
Get the snappy-java version by reading pom.properties embedded in jar. This version data is used as a suffix of a dll file extracted from the jar.- Returns:
- the version string
-
-