SF1493647 support alternate dll loading directories

This commit is contained in:
clay_shooter
2006-09-30 16:39:32 +00:00
parent 23f64b600c
commit a50685d412
7 changed files with 70 additions and 16 deletions

View File

@@ -107,15 +107,15 @@
<echo>Building java classes in ${java.bin}...</echo> <echo>Building java classes in ${java.bin}...</echo>
<javac srcdir="${java.src}" <javac srcdir="${java.src}"
destdir="${java.bin}" destdir="${java.bin}"
listfiles="true" debug="on" fork="yes" /> listfiles="true" debug="on" source="1.4" />
<echo>Building java sample classes ...</echo> <echo>Building java sample classes ...</echo>
<javac srcdir="${java.samples}" <javac srcdir="${java.samples}"
destdir="${java.bin}" destdir="${java.bin}"
listfiles="true" debug="on" fork="yes" /> listfiles="true" debug="on" source="1.4" />
<echo>Building java test classes...</echo> <echo>Building java test classes...</echo>
<javac srcdir="${java.unittest}" <javac srcdir="${java.unittest}"
destdir="${java.bin}" destdir="${java.bin}"
listfiles="true" debug="on" fork="yes" /> listfiles="true" debug="on" source="1.4" />
</target> </target>
<!-- ====================================================================== <!-- ======================================================================
Package the classes into a JAR. Package the classes into a JAR.

View File

@@ -31,6 +31,13 @@
<tr> <tr>
<td width="100%" colspan="2"><b>Patches</b></td> <td width="100%" colspan="2"><b>Patches</b></td>
</tr> </tr>
<tr>
<td width="13%">SF1493647</td>
<td width="87%">Support command line parameter dll location specification.
Applets and other tools can now specificy the dll location that
is fed to a System.load() rather than System.loadLibrary for the
situation where the app can't write the dll to a library path directory.</td>
</tr>
<tr> <tr>
<td width="13%">&nbsp;</td> <td width="13%">&nbsp;</td>
<td width="87%">&nbsp;</td> <td width="87%">&nbsp;</td>

View File

@@ -149,6 +149,6 @@ public abstract class ComThread {
* any other reference to one of the JacboObject subclasses is made. * any other reference to one of the JacboObject subclasses is made.
*/ */
static { static {
JacobObject.loadJacobLibrary(); LibraryLoader.loadJacobLibrary();
} }
} }

View File

@@ -62,15 +62,6 @@ public class JacobObject {
} }
/**
*
* loads the jacob library dll
*
*/
protected static void loadJacobLibrary(){
System.loadLibrary("jacob");
}
/** /**
* Loads version information from version.properties that was * Loads version information from version.properties that was
* built as part of this release. * built as part of this release.
@@ -156,7 +147,7 @@ public class JacobObject {
* force the jacob DLL to be loaded whenever this class is referenced * force the jacob DLL to be loaded whenever this class is referenced
*/ */
static { static {
JacobObject.loadJacobLibrary(); LibraryLoader.loadJacobLibrary();
} }

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at http://sourceforge.net/projects/jacob-project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.jacob.com;
/**
* Utility class to centralize the way in which the jacob JNI library is loaded.
*
* <p>If system property {@link #JACOB_DLL_PATH} is defined, the file located there
* will be loaded as the jacob dll. If the system property is not defined, normal
* library paths will be used to load the jacob dll. This means it defaults to the
* previous behavior for existing applications.
* <p>
* Submitted sourceforge ticket 1493647
* @author Scott Dickerson (sjd78)
*/
public final class LibraryLoader {
/**
* Name of system property (currently <tt>jacob.dll.path</tt>) that may contain
* an absolute path to the JNI library.
*/
public static final String JACOB_DLL_PATH = "jacob.dll.path";
/**
* Load the jacob dll either from an absolute path defined in system property
* {@link #JACOB_DLL_PATH} or as a general library called "<tt>jacob</tt>".
*/
public static void loadJacobLibrary() {
String path = System.getProperty(JACOB_DLL_PATH);
if (path != null) {
System.load(path);
}
else {
System.loadLibrary("jacob");
}
}
} // LibraryLoader

View File

@@ -222,7 +222,7 @@ public abstract class ROT {
* so we force a DLL load here by referncing JacobObject * so we force a DLL load here by referncing JacobObject
*/ */
static { static {
JacobObject.loadJacobLibrary(); LibraryLoader.loadJacobLibrary();
} }
} }

View File

@@ -93,6 +93,6 @@ public class STA extends Thread {
* the DLL without this * the DLL without this
*/ */
static { static {
JacobObject.loadJacobLibrary(); LibraryLoader.loadJacobLibrary();
} }
} }