[ismrmrd] 130/281: adding JNILibLoader and Java XML header marshaller.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:05 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit df16c08b0d6a2da365d627f240f09f12fc0a7f36
Author: Joseph Naegele <joseph.naegele at gmail.com>
Date:   Thu Apr 4 16:18:10 2013 -0400

    adding JNILibLoader and Java XML header marshaller.
---
 bindings/java/CMakeLists.txt    |  2 ++
 bindings/java/JNILibLoader.java | 23 +++++++++++++++++++++--
 bindings/java/XMLString.java    | 25 +++++++++++++++++++++++++
 bindings/java/make_jar.sh       |  2 +-
 bindings/python/CMakeLists.txt  |  2 +-
 5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/bindings/java/CMakeLists.txt b/bindings/java/CMakeLists.txt
index 9f22864..4e0874e 100644
--- a/bindings/java/CMakeLists.txt
+++ b/bindings/java/CMakeLists.txt
@@ -24,6 +24,8 @@ add_custom_command(
     COMMENT "Compiling java files and creating jar" VERBATIM
     COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/JNILibLoader.java	
                ${CMAKE_CURRENT_BINARY_DIR}/org/ismrm/ismrmrd
+               COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/XMLString.java	
+               ${CMAKE_CURRENT_BINARY_DIR}/org/ismrm/ismrmrd/xmlhdr
     COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_jar.sh
 )
 
diff --git a/bindings/java/JNILibLoader.java b/bindings/java/JNILibLoader.java
index e7add9e..9810e01 100644
--- a/bindings/java/JNILibLoader.java
+++ b/bindings/java/JNILibLoader.java
@@ -1,9 +1,28 @@
 package org.ismrm.ismrmrd;
 
+import java.io.File;
+
+
 public class JNILibLoader {
     public static void load() throws java.net.URISyntaxException {
-        ClassLoader loader = JNILibLoader.class.getClassLoader();
-        System.out.println(loader.getResource("org/ismrm/ismrmrd/JNILibLoader.class").toURI().getPath());
+        File myjar = new File(JNILibLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
+        File windowsLibDir = new File(myjar.getParent(), "jismrmrd.dll");
+        File macLibDir = new File(myjar.getParent(), "libjismrmrd.jnilib");
+        File unixLibDir = new File(myjar.getParent(), "libjismrmrd.so");
+
+        // TODO: check OS name then load the correct library
+        if (unixLibDir.exists()) {
+            System.load(unixLibDir.getPath());
+        } else if (windowsLibDir.exists()) {
+            System.load(windowsLibDir.getPath());
+        } else if (macLibDir.exists()) {
+            System.load(macLibDir.getPath());
+        } else {
+            System.err.println("Failed to load ISMRMRD JNI library");
+        }
+
+        //ClassLoader loader = JNILibLoader.class.getClassLoader();
+        //System.out.println(loader.getResource("org/ismrm/ismrmrd/JNILibLoader.class").toURI().getPath());
 	//System.load(JNIFile);
 	//System.load("/usr/local/ismrmrd/lib/libjismrmrd.jnilib");
 	//System.loadLibrary("jismrmrd");
diff --git a/bindings/java/XMLString.java b/bindings/java/XMLString.java
new file mode 100644
index 0000000..ad0c640
--- /dev/null
+++ b/bindings/java/XMLString.java
@@ -0,0 +1,25 @@
+package org.ismrm.ismrmrd.xmlhdr;
+
+import javax.xml.bind.*;
+import java.io.StringReader;
+
+
+public class XMLString {
+    public static IsmrmrdHeader StringToIsmrmrdHeader(String xmlstring) throws javax.xml.bind.JAXBException
+    {
+        ObjectFactory factory = new ObjectFactory();
+        //JAXBContext jc = JAXBContext.newInstance("org.ismrm.ismrmrd.xmlhdr", factory.getClass().getClassLoader());
+        JAXBContext jc = JAXBContext.newInstance(IsmrmrdHeader.class);
+        Unmarshaller u  = jc.createUnmarshaller();
+        StringReader reader = new StringReader(xmlstring);
+        IsmrmrdHeader hdr = (IsmrmrdHeader) u.unmarshal(reader);
+        return hdr;
+    }
+
+    /*
+    public static String IsmrmrdHeaderToString(IsmrmrdHeader header)
+    {
+
+    }
+    */
+}
diff --git a/bindings/java/make_jar.sh b/bindings/java/make_jar.sh
index 2f5fe85..0ecb4e6 100755
--- a/bindings/java/make_jar.sh
+++ b/bindings/java/make_jar.sh
@@ -10,4 +10,4 @@ javac org/ismrm/ismrmrd/xmlhdr/*.java
 jar -cvf ismrmrd.jar org/ismrm/ismrmrd/*.class org/ismrm/ismrmrd/xmlhdr/*.class
 
 # Build the java docs
-javadoc -d ismrmrd.javadoc -subpackages org.ismrm.ismrmrd
\ No newline at end of file
+javadoc -quiet -d ismrmrd.javadoc -subpackages org.ismrm.ismrmrd
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index c9a5b56..48d08d0 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -10,4 +10,4 @@ include_directories(${HDF5_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}/cpp ${Boost_INCLUDE_
 set_source_files_properties(ismrmrd_python.i PROPERTIES CPLUSPLUS ON)
 
 SWIG_ADD_MODULE(ismrmrd python ismrmrd_python.i ../../ismrmrd_hdf5.cpp)
-SWIG_LINK_LIBRARIES(ismrmrd ${PYTHON_LIBRARIES} ${HDF5_LIBRARIES} ${Boost_LIBRARIES})
+SWIG_LINK_LIBRARIES(ismrmrd ${HDF5_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list