From 82ee3e71043e30b97932312e6b1fec25400d2358 Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Thu, 20 Mar 2014 09:38:07 -0500 Subject: [PATCH] Issue #2919 fix windows error due to gempak library missing Former-commit-id: 5a2ba132d9e32ce8a018f35ba2524881e5276120 --- .../ThinClientPluginBlacklist.txt | 1 + .../viz/gempak/nativelib/LibraryLoader.java | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/ThinClientPluginBlacklist.txt b/cave/com.raytheon.uf.viz.thinclient.cave/ThinClientPluginBlacklist.txt index 22c6b9395c..0927149bfb 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/ThinClientPluginBlacklist.txt +++ b/cave/com.raytheon.uf.viz.thinclient.cave/ThinClientPluginBlacklist.txt @@ -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 diff --git a/ncep/gov.noaa.nws.ncep.viz.gempak.nativelib/src/gov/noaa/nws/ncep/viz/gempak/nativelib/LibraryLoader.java b/ncep/gov.noaa.nws.ncep.viz.gempak.nativelib/src/gov/noaa/nws/ncep/viz/gempak/nativelib/LibraryLoader.java index 3f68c6dcad..bf57595dd7 100644 --- a/ncep/gov.noaa.nws.ncep.viz.gempak.nativelib/src/gov/noaa/nws/ncep/viz/gempak/nativelib/LibraryLoader.java +++ b/ncep/gov.noaa.nws.ncep.viz.gempak.nativelib/src/gov/noaa/nws/ncep/viz/gempak/nativelib/LibraryLoader.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- -----------------------------------------
+ * --/--/----                         Initial Creation
+ * Mar 20, 2014  2919     njensen     Safety checks, better error messages
+ * 
+ * 
+ * + */ + 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); } }