Home about services products contact login
   com.smardec

J2Native

  j2native
com.smardec.j2native
Class Library

java.lang.Object
|
+--com.smardec.j2native.Library

public class Library
extends java.lang.Object

Library class is Java representation of the native library. This class is used to load native library and locate it's functions. There is two types of libraries: first - is part of the J2Native system, and must be loaded at the very begining, second - all other libraries.

See Also:
Function, LibraryLoader

Field Summary
static Library FAKE_LIBRARY
static java.lang.String LIBRARY_ENFORCE_KEY
This is a key to search through system properties.
Constructor Summary
Library(java.lang.String name)
Library constructor.
Method Summary
static void ensureNativeCodeLoaded()
Check if native part of J2Native is loaded, and loads it if needed.
Function getFunction(java.lang.String functionName)
Locate and returns Function with specified name.
static LibraryLoader getLibraryLoader()
Returns default LibraryLoader.
java.lang.String getName()
Returns library name.
boolean isLoaded()
Returns if library loaded.
void load()
Loads library.
void load(java.io.File directory)
Loads library from specified directory.
void load(LibraryLoader loader)
Loads library using specified LibraryLoader.
static void loadNativeCode()
Loads J2Native library, that is native part of the wrapper system.
static void loadNativeCode(LibraryLoader loader)
Loads J2Native library, that is native part of the wrapper system.
static void loadNativeCode(LibraryLoader loader, java.lang.String nativeCodePath)
Loads J2Native library, that is native part of the wrapper system.
static void loadNativeCode(java.lang.String nativeCodePath)
Loads J2Native library, that is native part of the wrapper system.
static void setLibraryLoader(LibraryLoader libraryLoader)
Sets default LibraryLoader.
void unload()
Unloads library and frees resources used by library.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
LIBRARY_ENFORCE_KEY
public static final java.lang.String LIBRARY_ENFORCE_KEY

This is a key to search through system properties. If System.getProperty(LIBRARY_ENFORCE_KEY) is null or something different than true then no library searching will be performed. Underlie system is responsible for library location.

See Also:
Constant Field Values

FAKE_LIBRARY
public static Library FAKE_LIBRARY
Constructor Detail
Library
public Library(java.lang.String name)
Library constructor.

Parameters:
name - filename of the library
Method Detail
loadNativeCode
public static void loadNativeCode(LibraryLoader loader, java.lang.String nativeCodePath) throws java.lang.SecurityException
Loads J2Native library, that is native part of the wrapper system.

Parameters:
loader - LibraryLoader that will load library
nativeCodePath - path to the library
Throws:
java.lang.SecurityException - if something goes wrong

loadNativeCode
public static void loadNativeCode(LibraryLoader loader) throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
Loads J2Native library, that is native part of the wrapper system.

Parameters:
loader - LibraryLoader that will load library
Throws:
java.lang.SecurityException
java.lang.UnsatisfiedLinkError

loadNativeCode
public static void loadNativeCode(java.lang.String nativeCodePath) throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
Loads J2Native library, that is native part of the wrapper system.

Parameters:
nativeCodePath - path to the library
Throws:
java.lang.SecurityException
java.lang.UnsatisfiedLinkError

loadNativeCode
public static void loadNativeCode() throws java.lang.SecurityException, java.lang.UnsatisfiedLinkError
Loads J2Native library, that is native part of the wrapper system.

Throws:
java.lang.SecurityException
java.lang.UnsatisfiedLinkError

ensureNativeCodeLoaded
public static void ensureNativeCodeLoaded()
Check if native part of J2Native is loaded, and loads it if needed.


load
public void load() throws LibraryNotFoundException
Loads library.

Throws:
LibraryNotFoundException - if no library found in path.

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

Parameters:
directory - directory from which library will be loaded
Throws:
LibraryNotFoundException - if no such library found in specified directory

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

Parameters:
loader - LibraryLoader used to load library
Throws:
LibraryNotFoundException - if no such library found in path

unload
public void unload()
Unloads library and frees resources used by library.


isLoaded
public boolean isLoaded()
Returns if library loaded.

Returns:
boolean

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

Returns:
library name

getFunction
public Function getFunction(java.lang.String functionName) throws FunctionNotFoundException
Locate and returns Function with specified name.

Parameters:
functionName - name of the function
Throws:
FunctionNotFoundException - if no such function found in this library

getLibraryLoader
public static LibraryLoader getLibraryLoader()
Returns default LibraryLoader.

Returns:
LibraryLoader

setLibraryLoader
public static void setLibraryLoader(LibraryLoader libraryLoader)
Sets default LibraryLoader.

Parameters:
libraryLoader - default loader
Home about services products contact login