|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.xoetrope.os.LibraryLoader
public class LibraryLoader
Loads a native library file. The class can load the library by attempting to have the Sytem class load the library from the library path. If this fails the class can attempt to load the file by extracting it from the classpath, including the Jar files on the classpath and then loading it with the full file path. A temporary directory is used to temporarily extract the file. If the file is loaded successfully the library name is placed in a hashtable so that subsequent calls to load the library to not actually attempt to load the library.
Java Webstart and JNLP can also fullfill a similar role to this utility class using the 'native' library element in the JNLP file.
Copyright (c) Xoetrope Ltd., 2002-2004
$Revision: 2.6 $
License: see License.txt
Field Summary | |
---|---|
protected static int |
BUF_LEN The internal buffer length |
protected static java.lang.String |
extractDir The directory to which files are extracted. |
Constructor Summary | |
---|---|
LibraryLoader() |
Method Summary | |
---|---|
static java.lang.String |
extractFile(java.lang.ClassLoader classLoader, java.lang.String resName) Extract a file from a jar file to the specified location |
java.lang.String |
extractFile(java.lang.ClassLoader classLoader, java.lang.String resName, boolean overwrite) Extract a file from a jar file to the specified location |
static java.lang.String |
getExtractDirectory() Get the directory name to which the library will be extracted. |
protected boolean |
isUpToDate(java.net.URL url, java.io.File targetFile) Check that the temporary file exists and is up-to-date |
static void |
load(java.lang.ClassLoader clazz, java.lang.String resName) Load a library resource (native library) |
void |
load(java.lang.ClassLoader classLoader, java.lang.String resName, boolean checkLibPath, boolean overwrite) Load a native library |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int BUF_LEN
protected static java.lang.String extractDir
Constructor Detail |
---|
public LibraryLoader()
Method Detail |
---|
public static void load(java.lang.ClassLoader clazz, java.lang.String resName)
clazz
- the class loaderresName
- the resource to loadpublic static java.lang.String extractFile(java.lang.ClassLoader classLoader, java.lang.String resName) throws java.io.IOException
classLoader
- the classloder to use to load the fileresName
- the resource/file namejava.io.IOException
- IO problems reading or extracting the file.public void load(java.lang.ClassLoader classLoader, java.lang.String resName, boolean checkLibPath, boolean overwrite)
classLoader
- the classLoader used to find the library/resourceresName
- the library/resource namecheckLibPath
- true to check the system library path first before checking the resource pathoverwrite
- true to overwrite any existing temporary file, if false the the timestamp is checked to see if the file needs to be extracted to the temporary directorypublic static java.lang.String getExtractDirectory()
protected boolean isUpToDate(java.net.URL url, java.io.File targetFile)
url
- the URL of the source filetargetFile
- the temporary filepublic java.lang.String extractFile(java.lang.ClassLoader classLoader, java.lang.String resName, boolean overwrite) throws java.io.IOException
classLoader
- the classloder to use to load the fileoverwrite
- true to overwrite any existing fileresName
- the resource to extractjava.io.IOException
- IO problems reding or extracting the file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |