com.moesol.bindings
Class FindInSameDirectory

java.lang.Object
  extended by com.moesol.bindings.FindInSameDirectory
All Implemented Interfaces:
NativeLibraryFinderStrategy
Direct Known Subclasses:
FindInSameDirectoryUsingJarBaseName

public class FindInSameDirectory
extends Object
implements NativeLibraryFinderStrategy


Constructor Summary
FindInSameDirectory()
           
 
Method Summary
 File computeDirectoryForClass(Class classInJar)
          Computes the directory where NativeLibraryFinder will search for a native library.
protected  File computeJarFile(URL url)
           
 void findAndLoad(Class classInJar, String libraryName)
           
 String getClassAsResourcePath()
           
 void setClassAsResourcePath(String resourceToFind)
           
protected  String templateGetMappedName(Class classInJar, String libraryName)
          Override to change the mapped name this class uses to search for the native library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindInSameDirectory

public FindInSameDirectory()
Method Detail

findAndLoad

public void findAndLoad(Class classInJar,
                        String libraryName)
Specified by:
findAndLoad in interface NativeLibraryFinderStrategy

templateGetMappedName

protected String templateGetMappedName(Class classInJar,
                                       String libraryName)
Override to change the mapped name this class uses to search for the native library.

Parameters:
classInJar -
libraryName -
Returns:
mapped name of library

computeDirectoryForClass

public File computeDirectoryForClass(Class classInJar)
Computes the directory where NativeLibraryFinder will search for a native library. If classInJar is a class in a jar file then it will return the dirctory that contains the jar file. This is a common installation setup where foo.jar and foo.dll are installed into the same directory. If the jar file was downloaded via http then this method will return null.

If classInJar is a class that was not contained in a jar file, then this will return the directory that is the root of the class tree. This is the same location as a resource with the path of "/" would return. This is useful if the native library will eventually be packaged as a resource in a jar file, because finding the library directory here will allow the code to skip extracting the native library.

Parameters:
classInJar -
Returns:
the directory that will be searched for native libraries for classInJar or null if classInJar is downloaded.

computeJarFile

protected File computeJarFile(URL url)

setClassAsResourcePath

public void setClassAsResourcePath(String resourceToFind)

getClassAsResourcePath

public String getClassAsResourcePath()


Copyright © 2004 Moebius Solutions, Inc. All Rights Reserved.