Issue #2919 fix windows error due to gempak library missing

Former-commit-id: 6edec10edc [formerly 747ac58166] [formerly 82ee3e7104 [formerly 5a2ba132d9e32ce8a018f35ba2524881e5276120]]
Former-commit-id: 82ee3e7104
Former-commit-id: 24eadadffd
This commit is contained in:
Nate Jensen 2014-03-20 09:38:07 -05:00
parent 57f7e4b084
commit 07d2a4f40c
2 changed files with 32 additions and 3 deletions

View file

@ -26,6 +26,7 @@ gov.noaa.nws.ncep.viz.rsc.idft
gov.noaa.nws.ncep.viz.rsc.intlsig
gov.noaa.nws.ncep.viz.rsc.lightning
gov.noaa.nws.ncep.viz.rsc.mosaic
gov.noaa.nws.ncep.viz.rsc.ncgrid
gov.noaa.nws.ncep.viz.rsc.ncscat
gov.noaa.nws.ncep.viz.rsc.nonconvsigmet
gov.noaa.nws.ncep.viz.rsc.plotdata

View file

@ -1,5 +1,6 @@
package gov.noaa.nws.ncep.viz.gempak.nativelib;
import java.io.FileNotFoundException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
@ -10,20 +11,47 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Utility to load a specific native library
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- -----------------------------------------
* --/--/---- Initial Creation
* Mar 20, 2014 2919 njensen Safety checks, better error messages
*
* </pre>
*
*/
public class LibraryLoader {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LibraryLoader.class);
public static void load(String libName) {
URL url = null;
Path path = null;
try {
Bundle b = Activator.getDefault().getBundle();
url = FileLocator.find(b, new Path(System.mapLibraryName(libName)),
null);
path = new Path(System.mapLibraryName(libName));
url = FileLocator.find(b, path, null);
if (url == null) {
throw new FileNotFoundException("Unable to locate "
+ path.toString());
}
url = FileLocator.resolve(url);
System.load(url.getPath());
} catch (Exception e) {
String msg = "Could not Load native Library: " + url.getFile();
String msg = "Could not load native Library: ";
if (url != null) {
msg += url.getFile();
} else {
msg += path.toString();
}
statusHandler.handle(Priority.PROBLEM, msg, e);
}
}