0 Replies Latest reply on Dec 21, 2009 4:03 AM by thomas.diesler

    Initial support for Bundle-NativeCode

    thomas.diesler

      Initial support for navtive code is provided by the OSGiBundleNativeCodeDeployer

       

      http://fisheye.jboss.org/browse/JBossOSGi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java?r=98041

       

      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