edu.cs.ai.kreator.platformspecific
Class NativeLibraryProvider

java.lang.Object
  extended by edu.cs.ai.kreator.platformspecific.NativeLibraryProvider

public class NativeLibraryProvider
extends java.lang.Object

An instance of this class is used to ensure that a native library is aviable in the CWD. If this is not the case it tries to extract the native library from a jar. (using ClassLoader to access files in the jar). Problog Plugin use this class to ensure that the buddy lib (for Binary decision diagrams) is provided. You can look there for an example to use.

Author:
Tim Janus

Constructor Summary
NativeLibraryProvider()
           
 
Method Summary
static void provide(java.lang.String libName, boolean load, java.lang.ClassLoader loader)
          If the library given by libName does not exist in CWD: Provide the library, if the library cant be found in a jar file: throw an IOException.
static void provide(java.lang.String libName, java.lang.ClassLoader loader)
          provides the library given by libName, if the library cant be found it throws an IOException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeLibraryProvider

public NativeLibraryProvider()
Method Detail

provide

public static void provide(java.lang.String libName,
                           java.lang.ClassLoader loader)
                    throws java.io.IOException
provides the library given by libName, if the library cant be found it throws an IOException.

Parameters:
libName - os-independent name of the library.
loader - The correct class loader. This argument is very important when using from a plugin, otherwise the native library could be search in the wrong jar.
Throws:
java.io.IOException

provide

public static void provide(java.lang.String libName,
                           boolean load,
                           java.lang.ClassLoader loader)
                    throws java.io.IOException
If the library given by libName does not exist in CWD: Provide the library, if the library cant be found in a jar file: throw an IOException.

Parameters:
libName - os-independent name of the library.
load - if this parameter is true the method immediately loads the native lib.
loader - The correct class loader. This argument is very important when using from a plugin, otherwise the native library could be search in the wrong jar.
Throws:
java.io.IOException