initialize local snappy loader

This commit is contained in:
Taro L. Saito 2011-08-01 16:56:40 +09:00
parent 94d5356ba9
commit 9c86835cc3

View File

@ -190,13 +190,14 @@ public class SnappyLoader
boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION, boolean useNativeCodeInjection = !Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_NATIVE_INJECTION,
"false")); "false"));
if (!useNativeCodeInjection) { try {
// Use the local loader if (!useNativeCodeInjection) {
return LocalSnappyNativeLoader.class; // Use the local loader
} return SnappyLoader.class.getClassLoader().loadClass(LocalSnappyNativeLoader.class.getName());
else { }
// Use parent class loader to load SnappyNative, since Tomcat, which uses different class loaders for each webapps, cannot load JNI interface twice else {
try { // Use parent class loader to load SnappyNative, since Tomcat, which uses different class loaders for each webapps, cannot load JNI interface twice
final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader"; final String nativeLoaderClassName = "org.xerial.snappy.SnappyNativeLoader";
ClassLoader rootClassLoader = getRootClassLoader(); ClassLoader rootClassLoader = getRootClassLoader();
// Load a byte code // Load a byte code
@ -235,10 +236,10 @@ public class SnappyLoader
// Load the SnappyNativeLoader class // Load the SnappyNativeLoader class
return rootClassLoader.loadClass(nativeLoaderClassName); return rootClassLoader.loadClass(nativeLoaderClassName);
} }
catch (Exception e) { }
e.printStackTrace(System.err); catch (Exception e) {
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage()); e.printStackTrace(System.err);
} throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, e.getMessage());
} }
} }