com.jniwrapper
Class Library

java.lang.Object
  |
  +--com.jniwrapper.Library

public class Library
extends java.lang.Object

This class provides operations with a native code library. The Library class is responsible for providing Function class instances that are used for calling functions from the native code libraries. Unlike standard functionality provides, a library can be dynamically loaded and unloaded.


Field Summary
static java.lang.String NATIVE_CODE
           
 
Constructor Summary
Library(java.lang.String name)
          Constructs library using its name.
 
Method Summary
static LibraryLoader getDefaultLibraryLoader()
          Returns library loader that is used in methods that do not take a library loader as an argument.
 Function getFunction(java.lang.String name)
          Convenience method for getting a function when parameter types do affect loaded function.
 Function getFunction(java.lang.String name, java.lang.Class[] paramTypes)
          This returns a Function object that reflects the exporeted native function from the library.
 java.lang.String getName()
          Returns library name.
 boolean isLoaded()
          Returns loaded status of this library.
 void load()
          Loads library by its name using default mechanism
 void load(java.io.File directory)
          Loads library from the passed directory.
 void load(LibraryLoader loader)
          Loads library using a given library loader.
static void loadNativeCode()
          Initializes the native support library using standard library search behaviour and pre-defined native library name.
static void loadNativeCode(LibraryLoader loader)
          Loads native support library using a specified library loader.
static void loadNativeCode(java.lang.String nativeSupportPath)
          Loads native support library from the passed full file name.
static void setDefaultLibraryLoader(LibraryLoader libraryLoader)
          Sets library loader that is used in methods that do not take a library loader as an argument.
protected  void unload()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NATIVE_CODE

public static final java.lang.String NATIVE_CODE
See Also:
Constant Field Values
Constructor Detail

Library

public Library(java.lang.String name)
Constructs library using its name. This name does not contain the full path to the libarary file.

Method Detail

loadNativeCode

public static void loadNativeCode(LibraryLoader loader)
                           throws java.lang.SecurityException,
                                  java.lang.UnsatisfiedLinkError
Loads native support library using a specified library loader.

java.lang.SecurityException
java.lang.UnsatisfiedLinkError

loadNativeCode

public static void loadNativeCode(java.lang.String nativeSupportPath)
                           throws java.lang.SecurityException,
                                  java.lang.UnsatisfiedLinkError
Loads native support library from the passed full file name.

java.lang.SecurityException
java.lang.UnsatisfiedLinkError

loadNativeCode

public static void loadNativeCode()
                           throws java.lang.SecurityException,
                                  java.lang.UnsatisfiedLinkError
Initializes the native support library using standard library search behaviour and pre-defined native library name.

java.lang.SecurityException
java.lang.UnsatisfiedLinkError

load

public void load()
          throws LibraryNotFoundException
Loads library by its name using default mechanism

LibraryNotFoundException

load

public void load(java.io.File directory)
          throws LibraryNotFoundException
Loads library from the passed directory.

LibraryNotFoundException

load

public void load(LibraryLoader loader)
          throws LibraryNotFoundException
Loads library using a given library loader.

LibraryNotFoundException

unload

protected void unload()

isLoaded

public boolean isLoaded()
Returns loaded status of this library.


getName

public java.lang.String getName()
Returns library name.


getFunction

public Function getFunction(java.lang.String name,
                            java.lang.Class[] paramTypes)
                     throws NoSuchFunctionException,
                            LibraryNotFoundException
This returns a Function object that reflects the exporeted native function from the library.

NoSuchFunctionException
LibraryNotFoundException

getFunction

public Function getFunction(java.lang.String name)
                     throws NoSuchFunctionException,
                            LibraryNotFoundException
Convenience method for getting a function when parameter types do affect loaded function. Use this method on Win32.

NoSuchFunctionException
LibraryNotFoundException

getDefaultLibraryLoader

public static LibraryLoader getDefaultLibraryLoader()
Returns library loader that is used in methods that do not take a library loader as an argument.


setDefaultLibraryLoader

public static void setDefaultLibraryLoader(LibraryLoader libraryLoader)
Sets library loader that is used in methods that do not take a library loader as an argument.