NIFI-39: Implemented loadLibrary

This commit is contained in:
Mark Payne 2014-12-10 12:17:55 -05:00
parent f63cd9a15e
commit f60a97b026
1 changed files with 22 additions and 0 deletions

View File

@ -198,6 +198,28 @@ public class NarClassLoader extends URLClassLoader {
} }
} }
@Override
protected String findLibrary(final String libname) {
File dependencies = new File(narWorkingDirectory, "META-INF/dependencies");
if (!dependencies.isDirectory()) {
LOGGER.warn(narWorkingDirectory + " does not contain META-INF/dependencies!");
}
final File nativeDir = new File(dependencies, "native");
final File soFile = new File(nativeDir, libname + ".so");
if ( soFile.exists() ) {
return soFile.getAbsolutePath();
} else {
final File dllFile = new File(nativeDir, libname + ".dll");
if ( dllFile.exists() ) {
return dllFile.getAbsolutePath();
}
}
// not found in the nar. try system native dir
return null;
}
@Override @Override
public String toString() { public String toString() {
return NarClassLoader.class.getName() + "[" + narWorkingDirectory.getPath() + "]"; return NarClassLoader.class.getName() + "[" + narWorkingDirectory.getPath() + "]";