mirror of
https://github.com/xerial/snappy-java.git
synced 2025-04-08 19:35:08 +02:00
Merge branch 'release/1.0.5-M4'
This commit is contained in:
commit
2e2261210c
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,6 +7,8 @@
|
|||||||
.idea_modules
|
.idea_modules
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# sbt specific
|
# sbt specific
|
||||||
bin/.lib
|
bin/.lib
|
||||||
dist/*
|
dist/*
|
||||||
|
3
Makefile
3
Makefile
@ -94,6 +94,9 @@ mac32:
|
|||||||
linux32:
|
linux32:
|
||||||
$(MAKE) native OS_NAME=Linux OS_ARCH=i386
|
$(MAKE) native OS_NAME=Linux OS_ARCH=i386
|
||||||
|
|
||||||
|
freebsd64:
|
||||||
|
$(MAKE) native OS_NAME=FreeBSD OS_ARCH=amd64
|
||||||
|
|
||||||
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
|
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
|
||||||
linux-arm:
|
linux-arm:
|
||||||
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
|
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
|
||||||
|
@ -41,7 +41,7 @@ endif
|
|||||||
|
|
||||||
# os=Default is meant to be generic unix/linux
|
# os=Default is meant to be generic unix/linux
|
||||||
|
|
||||||
known_os_archs := Linux-i386 Linux-amd64 Linux-arm Linux-armhf Mac-i386 Mac-x86_64 Windows-x86 Windows-amd64
|
known_os_archs := Linux-i386 Linux-amd64 Linux-arm Linux-armhf Mac-i386 Mac-x86_64 FreeBSD-amd64 Windows-x86 Windows-amd64
|
||||||
os_arch := $(OS_NAME)-$(OS_ARCH)
|
os_arch := $(OS_NAME)-$(OS_ARCH)
|
||||||
|
|
||||||
ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs)))
|
ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs)))
|
||||||
@ -68,7 +68,7 @@ Linux-i386_SNAPPY_FLAGS:=
|
|||||||
Linux-amd64_CXX := $(CROSS_PREFIX)g++
|
Linux-amd64_CXX := $(CROSS_PREFIX)g++
|
||||||
Linux-amd64_STRIP := $(CROSS_PREFIX)strip
|
Linux-amd64_STRIP := $(CROSS_PREFIX)strip
|
||||||
Linux-amd64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64
|
Linux-amd64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64
|
||||||
Linux-amd64_LINKFLAGS := -shared -static-libgcc
|
Linux-amd64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
|
||||||
Linux-amd64_LIBNAME := libsnappyjava.so
|
Linux-amd64_LIBNAME := libsnappyjava.so
|
||||||
Linux-amd64_SNAPPY_FLAGS :=
|
Linux-amd64_SNAPPY_FLAGS :=
|
||||||
|
|
||||||
@ -105,6 +105,13 @@ Mac-x86_64_LINKFLAGS := -dynamiclib -static-libgcc
|
|||||||
Mac-x86_64_LIBNAME := libsnappyjava.jnilib
|
Mac-x86_64_LIBNAME := libsnappyjava.jnilib
|
||||||
Mac-x86_64_SNAPPY_FLAGS :=
|
Mac-x86_64_SNAPPY_FLAGS :=
|
||||||
|
|
||||||
|
FreeBSD-amd64_CXX := $(CROSS_PREFIX)g++
|
||||||
|
FreeBSD-amd64_STRIP := $(CROSS_PREFIX)strip
|
||||||
|
FreeBSD-amd64_CXXFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
|
||||||
|
FreeBSD-amd64_LINKFLAGS := -shared -static-libgcc
|
||||||
|
FreeBSD-amd64_LIBNAME := libsnappyjava.so
|
||||||
|
FreeBSD-amd64_SNAPPY_FLAGS :=
|
||||||
|
|
||||||
Windows-x86_CXX := $(CROSS_PREFIX)g++
|
Windows-x86_CXX := $(CROSS_PREFIX)g++
|
||||||
Windows-x86_STRIP := $(CROSS_PREFIX)strip
|
Windows-x86_STRIP := $(CROSS_PREFIX)strip
|
||||||
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
|
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
|
||||||
|
62
pom.xml
62
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.xerial.snappy</groupId>
|
<groupId>org.xerial.snappy</groupId>
|
||||||
<artifactId>snappy-java</artifactId>
|
<artifactId>snappy-java</artifactId>
|
||||||
<version>1.0.5-M3</version>
|
<version>1.0.5-M4</version>
|
||||||
<name>Snappy for Java</name>
|
<name>Snappy for Java</name>
|
||||||
<description>snappy-java: A fast compression/decompression library</description>
|
<description>snappy-java: A fast compression/decompression library</description>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
@ -82,7 +82,6 @@
|
|||||||
</testResource>
|
</testResource>
|
||||||
</testResources>
|
</testResources>
|
||||||
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -146,7 +145,6 @@
|
|||||||
<charset>UTF-8</charset>
|
<charset>UTF-8</charset>
|
||||||
<locale>en_US</locale>
|
<locale>en_US</locale>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
<stylesheetfile>stylesheet.css</stylesheetfile>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
@ -171,18 +169,68 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.apache.felix</groupId>
|
||||||
<artifactId>maven-bundle-plugin</artifactId>
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
<version>2.3.4</version>
|
<version>2.3.7</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<manifestLocation>${project.build.directory}/META-INF</manifestLocation>
|
||||||
<instructions>
|
<instructions>
|
||||||
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
||||||
<Bundle-Name>${pproject.name}</Bundle-Name>
|
<Bundle-Name>${project.name}</Bundle-Name>
|
||||||
<Bundle-Version>${project.version}</Bundle-Version>
|
<Bundle-Version>${project.version}</Bundle-Version>
|
||||||
<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
|
<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
|
||||||
<Export-Package>org.xerial.snappy</Export-Package>
|
<Export-Package>org.xerial.snappy</Export-Package>
|
||||||
<Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package>
|
<Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package>
|
||||||
|
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
|
||||||
|
<Bundle-NativeCode>
|
||||||
|
org/xerial/snappy/native/Windows/amd64/snappyjava.dll;selection-filter="(&(osgi.arch=x86_64)(osgi.os=win32))",
|
||||||
|
org/xerial/snappy/native/Windows/x86/snappyjava.dll;selection-filter="(&(osgi.arch=x86)(osgi.os=win32))",
|
||||||
|
org/xerial/snappy/native/Mac/i386/libsnappyjava.jnilib;selection-filter="(&(osgi.arch=x86)(osgi.os=macosx))",
|
||||||
|
org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;selection-filter="(&(osgi.arch=x86_64)(osgi.os=macosx))",
|
||||||
|
org/xerial/snappy/native/Linux/amd64/libsnappyjava.so;selection-filter="(&(osgi.arch=x86_64)(osgi.os=linux))",
|
||||||
|
org/xerial/snappy/native/Linux/i386/libsnappyjava.so;selection-filter="(&(osgi.arch=x86)(osgi.os=linux))",
|
||||||
|
org/xerial/snappy/native/Linux/arm/libsnappyjava.so;selection-filter="(&(osgi.arch=arm)(osgi.os=linux))"
|
||||||
|
</Bundle-NativeCode>
|
||||||
|
<!-- TODO: unsure about ARMHF -->
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-manifest</id>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>manifest</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<index>true</index>
|
||||||
|
<manifestFile>${project.build.directory}/META-INF/MANIFEST.MF</manifestFile>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>2.4.1</version>
|
||||||
|
<configuration>
|
||||||
|
<followSymLinks>false</followSymLinks>
|
||||||
|
<filesets>
|
||||||
|
<fileset>
|
||||||
|
<directory>META-INF</directory>
|
||||||
|
<includes>
|
||||||
|
<include>MANIFEST.MF</include>
|
||||||
|
</includes>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -205,6 +253,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
<extensions>
|
<extensions>
|
||||||
@ -254,7 +303,6 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -285,5 +333,7 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
package org.xerial.snappy;
|
package org.xerial.snappy;
|
||||||
|
|
||||||
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
@ -35,12 +38,23 @@ import org.osgi.framework.BundleContext;
|
|||||||
*/
|
*/
|
||||||
public class SnappyBundleActivator implements BundleActivator
|
public class SnappyBundleActivator implements BundleActivator
|
||||||
{
|
{
|
||||||
public void start(BundleContext context) throws Exception {
|
/**
|
||||||
|
* Name of the Snappy native library
|
||||||
|
*/
|
||||||
|
public static final String LIBRARY_NAME = "snappyjava";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a call to {@link System#loadLibrary(String)} to load the native library which assumes
|
||||||
|
* that the library is available on the path based on this {@link Bundle}'s {@link Manifest}.
|
||||||
|
*/
|
||||||
|
public void start(BundleContext context) throws Exception
|
||||||
|
{
|
||||||
|
System.loadLibrary(System.mapLibraryName(LIBRARY_NAME));
|
||||||
|
SnappyLoader.setApi(new SnappyNative());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception
|
||||||
|
{
|
||||||
|
SnappyLoader.setApi(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,13 @@
|
|||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
package org.xerial.snappy;
|
package org.xerial.snappy;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -87,8 +93,18 @@ public class SnappyLoader
|
|||||||
public static final String KEY_SNAPPY_USE_SYSTEMLIB = "org.xerial.snappy.use.systemlib";
|
public static final String KEY_SNAPPY_USE_SYSTEMLIB = "org.xerial.snappy.use.systemlib";
|
||||||
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS = "org.xerial.snappy.disable.bundled.libs"; // Depreciated, but preserved for backward compatibility
|
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS = "org.xerial.snappy.disable.bundled.libs"; // Depreciated, but preserved for backward compatibility
|
||||||
|
|
||||||
private static boolean isLoaded = false;
|
private static volatile boolean isLoaded = false;
|
||||||
private static Object api = null;
|
private static volatile Object api = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the api instance.
|
||||||
|
*
|
||||||
|
* @param nativeCode
|
||||||
|
*/
|
||||||
|
static synchronized void setApi(Object nativeCode)
|
||||||
|
{
|
||||||
|
api = nativeCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load system properties when configuration file of the name
|
* load system properties when configuration file of the name
|
||||||
@ -200,8 +216,8 @@ public class SnappyLoader
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static synchronized Object load() {
|
static synchronized Object load()
|
||||||
|
{
|
||||||
if (api != null)
|
if (api != null)
|
||||||
return api;
|
return api;
|
||||||
|
|
||||||
@ -216,7 +232,7 @@ public class SnappyLoader
|
|||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
// Look up SnappyNative, injected to the root classloder, using reflection in order to avoid the initialization of SnappyNative class in this context class loader.
|
// Look up SnappyNative, injected to the root classloder, using reflection in order to avoid the initialization of SnappyNative class in this context class loader.
|
||||||
Object nativeCode = Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
Object nativeCode = Class.forName("org.xerial.snappy.SnappyNative").newInstance();
|
||||||
api = nativeCode;
|
setApi(nativeCode);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user