mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-25 23:14:34 +02:00
Rename
This commit is contained in:
parent
c28787890f
commit
ba8a761010
@ -37,7 +37,7 @@ public class Snappy
|
|||||||
{
|
{
|
||||||
|
|
||||||
static {
|
static {
|
||||||
LoadSnappy.load();
|
SnappyLoader.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
// snappy-java Project
|
// snappy-java Project
|
||||||
//
|
//
|
||||||
// LoadSnappy.java
|
// SnappyLoader.java
|
||||||
// Since: 2011/03/29
|
// Since: 2011/03/29
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
@ -75,7 +75,7 @@ import java.util.Properties;
|
|||||||
* @author leo
|
* @author leo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LoadSnappy
|
public class SnappyLoader
|
||||||
{
|
{
|
||||||
private static boolean isLoaded = false;
|
private static boolean isLoaded = false;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class LoadSnappy
|
|||||||
try {
|
try {
|
||||||
if (extractedLibFile.exists()) {
|
if (extractedLibFile.exists()) {
|
||||||
// test md5sum value
|
// test md5sum value
|
||||||
String md5sum1 = md5sum(LoadSnappy.class.getResourceAsStream(nativeLibraryFilePath));
|
String md5sum1 = md5sum(SnappyLoader.class.getResourceAsStream(nativeLibraryFilePath));
|
||||||
String md5sum2 = md5sum(new FileInputStream(extractedLibFile));
|
String md5sum2 = md5sum(new FileInputStream(extractedLibFile));
|
||||||
|
|
||||||
if (md5sum1.equals(md5sum2)) {
|
if (md5sum1.equals(md5sum2)) {
|
||||||
@ -154,7 +154,7 @@ public class LoadSnappy
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extract a native library file into the target directory
|
// extract a native library file into the target directory
|
||||||
InputStream reader = LoadSnappy.class.getResourceAsStream(nativeLibraryFilePath);
|
InputStream reader = SnappyLoader.class.getResourceAsStream(nativeLibraryFilePath);
|
||||||
FileOutputStream writer = new FileOutputStream(extractedLibFile);
|
FileOutputStream writer = new FileOutputStream(extractedLibFile);
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
@ -222,7 +222,7 @@ public class LoadSnappy
|
|||||||
// Load an os-dependent native library inside a jar file
|
// Load an os-dependent native library inside a jar file
|
||||||
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
|
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
|
||||||
|
|
||||||
if (LoadSnappy.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
|
if (SnappyLoader.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
|
||||||
// Temporary library folder. Use the value of java.io.tmpdir
|
// Temporary library folder. Use the value of java.io.tmpdir
|
||||||
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR, System.getProperty("java.io.tmpdir")))
|
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR, System.getProperty("java.io.tmpdir")))
|
||||||
.getAbsolutePath();
|
.getAbsolutePath();
|
||||||
@ -261,9 +261,10 @@ public class LoadSnappy
|
|||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
|
|
||||||
URL versionFile = LoadSnappy.class.getResource("/META-INF/maven/org.xerial.snappy/snappy-java/pom.properties");
|
URL versionFile = SnappyLoader.class
|
||||||
|
.getResource("/META-INF/maven/org.xerial.snappy/snappy-java/pom.properties");
|
||||||
if (versionFile == null)
|
if (versionFile == null)
|
||||||
versionFile = LoadSnappy.class.getResource("/org/xerial/snappy/VERSION");
|
versionFile = SnappyLoader.class.getResource("/org/xerial/snappy/VERSION");
|
||||||
|
|
||||||
String version = "unknown";
|
String version = "unknown";
|
||||||
try {
|
try {
|
48
src/test/java/org/xerial/snappy/SnappyLoaderTest.java
Executable file
48
src/test/java/org/xerial/snappy/SnappyLoaderTest.java
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
/*--------------------------------------------------------------------------
|
||||||
|
* Copyright 2011 Taro L. Saito
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*--------------------------------------------------------------------------*/
|
||||||
|
//--------------------------------------
|
||||||
|
// XerialJ
|
||||||
|
//
|
||||||
|
// SnappyLoaderTest.java
|
||||||
|
// Since: 2011/06/22 23:59:47
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Author$
|
||||||
|
//--------------------------------------
|
||||||
|
package org.xerial.snappy;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||||
|
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.xerial.util.log.Logger;
|
||||||
|
|
||||||
|
public class SnappyLoaderTest
|
||||||
|
{
|
||||||
|
private static Logger _logger = Logger.getLogger(SnappyLoaderTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loadFromSytemClassLoader() throws Exception {
|
||||||
|
|
||||||
|
ClassLoader parent = this.getClass().getClassLoader().getParent();
|
||||||
|
ClassWorld cw = new ClassWorld();
|
||||||
|
ClassRealm L1 = cw.newRealm("l1", parent);
|
||||||
|
ClassRealm L2 = cw.newRealm("l2", parent);
|
||||||
|
|
||||||
|
Class< ? > snappyClass = L1.loadClass("org.xerial.snappy.Snappy");
|
||||||
|
_logger.info(snappyClass.getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user