Initial support for navtive code is provided by the OSGiBundleNativeCodeDeployer
This works such that the deployer adds the library mapping to the OSGiClassLoaderPolicy
// Add the native library mapping to the OSGiClassLoaderPolicy OSGiClassLoaderPolicy policy = unit.getAttachment(ClassLoaderPolicy.class); policy.addLibraryMapping(libname, nativeFileCopy);
Which is then used by the OSGiBundleClassLoader
public class OSGiBundleClassLoader extends BaseClassLoader { ... @Override protected String findLibrary(String libname) { String libraryPath = null; if (osgiPolicy != null) libraryPath = osgiPolicy.findLibrary(libname); if (libraryPath == null) libraryPath = super.findLibrary(libname); return libraryPath; } }
This solution currently relies on OSGiClassLoaderSystem that needs to create the OSGiBundleClassLoader
public class OSGiClassLoaderSystem extends ClassLoaderSystem { ... @Override protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy) { return new OSGiBundleClassLoader(policy); } }
A better solution would be to support the notion of native library mapping in ClassLoadingMetaData, ClassLoaderPolicy and BaseClassLoader directly.
Here is the CL issue: https://jira.jboss.org/jira/browse/JBCL-136