diff options
author | Sven Gothel <[email protected]> | 2011-09-24 02:57:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-24 02:57:47 +0200 |
commit | 7d7b08a246a3173b204ecbb467f9d11d3f1c394f (patch) | |
tree | 72ee34e08d1c90d151152c526495b25a02baa912 /src | |
parent | b669435d277a10e6163034aba286ecccce013f69 (diff) |
JNILibLoaderBase: Add convenient method to addNativeJarLibs for 'all' and 'atomic' variants
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/jogamp/common/jvm/JNILibLoaderBase.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java index 348fb54..3164b82 100644 --- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java +++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java @@ -140,6 +140,12 @@ public class JNILibLoaderBase { loaderAction = action; } + /** + * + * @param classFromJavaJar GLProfile + * @param nativeJarBaseName jogl-all + * @return + */ public static final boolean addNativeJarLibs(Class<?> classFromJavaJar, String nativeJarBaseName) { if(TempJarCache.isInitialized()) { final String nativeJarName = nativeJarBaseName+"-natives-"+Platform.getOSAndArch()+".jar"; @@ -164,7 +170,38 @@ public class JNILibLoaderBase { } return false; } - + + /** + * @param classFromJavaJar GLProfile + * @param allJavaJarPrefix "jogl.all" + * @param allNativeJarBaseName "jogl-all" + * @param atomicNativeJarBaseNames [ "nativewindow", "jogl", "newt" ] + */ + public static void addNativeJarLibs(Class<?> classFromJavaJar, String allJavaJarPrefix, String allNativeJarBaseName, String[] atomicNativeJarBaseNames) { + if(TempJarCache.isInitialized()) { + final ClassLoader cl = classFromJavaJar.getClassLoader(); + try { + final String jarName = JarUtil.getJarName(classFromJavaJar.getName(), cl); + if(jarName!=null) { + if( null != allJavaJarPrefix && jarName.startsWith(allJavaJarPrefix) ) { + // all-in-one variant + JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, allNativeJarBaseName); + } else if(null != atomicNativeJarBaseNames) { + // atomic variant + for(int i=0; i<atomicNativeJarBaseNames.length; i++) { + final String atomicNativeJarBaseName = atomicNativeJarBaseNames[i]; + if(null != atomicNativeJarBaseName && atomicNativeJarBaseName.length()>0) { + JNILibLoaderBase.addNativeJarLibs(classFromJavaJar, atomicNativeJarBaseName); + } + } + } + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + } + protected static synchronized boolean loadLibrary(String libname, boolean ignoreError) { if (loaderAction != null) { return loaderAction.loadLibrary(libname, ignoreError); |