Skip to content

Commit

Permalink
- clean up removing logs and removing javacpp from the build
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Jun 15, 2016
1 parent e484aac commit 66414ea
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 103 deletions.
Binary file modified bbb-screenshare/app/jws/lib/javacpp.jar
Binary file not shown.
Binary file modified bbb-screenshare/app/jws/lib/javacv-screenshare-0.0.1.jar
Binary file not shown.
Binary file modified bbb-screenshare/jws/native-libs/unsigned-jars/javacpp-1.2.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion bbb-screenshare/jws/webstart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

dependencies {
compile ":javacpp:@jar"
// compile ":javacpp:@jar"
compile ":ffmpeg:@jar"
// compile ":javacv:@jar"
}
Expand Down
4 changes: 4 additions & 0 deletions bbb-screenshare/jws/webstart/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
if [ -d "lib" ]; then
rm -rf lib
fi
mkdir lib
cp ../../app/jws/lib/*.jar lib
rm lib/javacv.jar
rm lib/javacpp.jar
gradle clean
gradle jar
ant sign-jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,6 @@ public static String load(Class cls, Properties properties, boolean pathsFirst)

for (String s : targetClasses) {
try {
if (logger.isDebugEnabled()) {
logger.debug("load: Target class [" + s + "]");
}
Class.forName(s, true, cls.getClassLoader());
} catch (ClassNotFoundException ex) {
if (logger.isDebugEnabled()) {
Expand All @@ -485,52 +482,33 @@ public static String load(Class cls, Properties properties, boolean pathsFirst)
// Preload native libraries desired by our class
List<String> preloads = new ArrayList<String>();
preloads.addAll(p.get("platform.preload"));
// for (String preload : preloads) {
// if (logger.isDebugEnabled()) {
// logger.debug("Platform Preload lib " + preload);
// }
// }
// preloads.addAll(p.get("platform.link"));

// Do not include the platform.link into our list of native libs.
// This will just add to the number of libs to search increasing
// delay on startup. (ralam - june 15, 2016).
//preloads.addAll(p.get("platform.link"));

UnsatisfiedLinkError preloadError = null;
// for (String preload : preloads) {
// if (logger.isDebugEnabled()) {
// logger.debug("Plaform link lib " + preload);
// }
// }

if (logger.isDebugEnabled()) {
logger.debug("*****aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*****");
}
for (String preload : preloads) {
try {
if (logger.isDebugEnabled()) {
logger.debug("Loading class " + cls + " from preload lib " + preload);
}
// Do not try searching for the library. Let the system find the
// native library. Searching for it manually prolongs startup time.
// (ralam - june 15, 2016)
URL[] urls = new URL[0]; //findLibrary(cls, p, preload, pathsFirst);
loadLibrary(urls, preload);
} catch (UnsatisfiedLinkError e) {
preloadError = e;
}
}
if (logger.isDebugEnabled()) {
logger.debug("*****bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb*****");
}
if (logger.isDebugEnabled()) {
logger.debug("*****xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*****");
}

try {
String library = p.getProperty("platform.library");
if (logger.isDebugEnabled()) {
logger.debug("Loading class " + cls + " from platform.library " + library);
}
// Do not try searching for the library. Let the system find the
// native library. Searching for it manually prolongs startup time.
// (ralam - june 15, 2016)
URL[] urls = new URL[0]; //findLibrary(cls, p, library, pathsFirst);
String loadedLibPath = loadLibrary(urls, library);
if (logger.isDebugEnabled()) {
logger.debug("Lib path for class " + cls + " " + loadedLibPath);
}
if (logger.isDebugEnabled()) {
logger.debug("*****yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy*****");
}
return loadedLibPath;
} catch (UnsatisfiedLinkError e) {
if (preloadError != null && e.getCause() == null) {
Expand Down Expand Up @@ -563,9 +541,6 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
String filename = loadedLibraries.get(libnameversion);
if (filename != null) {
try {
if (logger.isDebugEnabled()) {
logger.debug("findLibrary: Found class " + cls + " in library " + libnameversion + " in " + filename);
}
return new URL[] { new File(filename).toURI().toURL() };
} catch (IOException ex) {
if (logger.isDebugEnabled()) {
Expand All @@ -575,10 +550,6 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
}
}

if (logger.isDebugEnabled()) {
logger.debug("findLibrary: Library " + libnameversion + " not found. Setting up search paths");
}

String subdir = properties.getProperty("platform") + '/';
String prefix = properties.getProperty("platform.library.prefix", "") + libname;
String suffix = properties.getProperty("platform.library.suffix", "");
Expand Down Expand Up @@ -618,18 +589,11 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
paths.addAll(Arrays.asList(libpath.split(File.pathSeparator)));
}
ArrayList<URL> urls = new ArrayList<URL>(styles.length * (1 + paths.size()));
*/
if (logger.isDebugEnabled()) {
logger.debug("findLibrary: Before get resource");
}
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// // ... reset interrupt to be nice ...
// Thread.currentThread().interrupt();
// }

String platform = Loader.getPlatform();
Set<URL> urls = new HashSet<URL>();
Expand All @@ -654,12 +618,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
if (logger.isDebugEnabled()) {
logger.debug("findLibrary: After get resource");
}
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// ... reset interrupt to be nice ...
// Thread.currentThread().interrupt();
// }

/*
// ... and in case of bad resources search the paths last, or first on user request.
int k = pathsFirst ? 0 : urls.size();
Expand Down Expand Up @@ -704,15 +663,6 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
* @throws UnsatisfiedLinkError on failure
*/
public static String loadLibrary(URL[] urls, String libnameversion) {
if (logger.isDebugEnabled()) {
logger.debug("Attempt to load " + libnameversion + " url[] length=" + urls.length);
}

for (URL url : urls) {
if (logger.isDebugEnabled()) {
logger.debug("URL for " + libnameversion + " " + url);
}
}
if (!isLoadLibraries()) {
if (logger.isDebugEnabled()) {
logger.debug("Not loading " + libnameversion );
Expand All @@ -724,9 +674,6 @@ public static String loadLibrary(URL[] urls, String libnameversion) {
// If we do not already have the native library file ...
String filename = loadedLibraries.get(libnameversion);
if (filename != null) {
if (logger.isDebugEnabled()) {
logger.debug("Not loading. " + libnameversion + " is already loaded in " + filename);
}
return filename;
}

Expand All @@ -736,20 +683,13 @@ public static String loadLibrary(URL[] urls, String libnameversion) {
for (URL url : urls) {
File file;

if (logger.isDebugEnabled()) {
logger.debug("Loading " + libnameversion + " from url " + url);
}

// ... then check if it has not already been extracted, and if not ...
if (!(file = new File(getCacheDir() != null ? getCacheDir() : getTempDir(), new File(url.getPath()).getName())).exists()) {
if (tempFile != null && tempFile.exists()) {
tempFile.deleteOnExit();
}

// ... then extract it from our resources ...
if (logger.isDebugEnabled()) {
logger.debug("Extracting " + url);
}
if (getCacheDir() != null) {
file = extractResource(url, getCacheDir(), null, null);
} else {
Expand All @@ -768,10 +708,6 @@ public static String loadLibrary(URL[] urls, String libnameversion) {
filename = file.getAbsolutePath();
try {
// ... and load it!
if (logger.isDebugEnabled()) {
logger.debug("Loading " + libnameversion + " from library " + filename);
logger.debug("Storing " + libnameversion + " with library " + filename);
}
loadedLibraries.put(libnameversion, filename);
System.load(filename);
return filename;
Expand All @@ -786,30 +722,14 @@ public static String loadLibrary(URL[] urls, String libnameversion) {
}
// ... or as last resort, try to load it via the system.
String libname = libnameversion.split("@")[0];
if (logger.isDebugEnabled()) {
logger.debug("Loading library " + libname);
logger.debug("Last resort: Storing " + libnameversion + " with library " + filename);
}
loadedLibraries.put(libnameversion, libname);
System.loadLibrary(libname);
if (logger.isDebugEnabled()) {
logger.debug("Loaded library " + libname);
logger.debug("Last resort: Stored " + libnameversion + " with library " + filename);
}
return libname;
} catch (UnsatisfiedLinkError e) {
if (loadedLibraries.containsKey(libnameversion)) {
if (logger.isDebugEnabled()) {
logger.debug("Removing entry for library " + libnameversion);
}
}
loadedLibraries.remove(libnameversion);
if (loadError != null && e.getCause() == null) {
e.initCause(loadError);
}
if (logger.isDebugEnabled()) {
logger.debug("Failed to load for " + libnameversion + ": " + e);
}
throw e;
} catch (IOException ex) {
loadedLibraries.remove(libnameversion);
Expand All @@ -818,9 +738,6 @@ public static String loadLibrary(URL[] urls, String libnameversion) {
}
Error e = new UnsatisfiedLinkError(ex.toString());
e.initCause(ex);
if (logger.isDebugEnabled()) {
logger.debug("Failed to extract for " + libnameversion + ": " + e);
}
throw e;
} finally {
if (tempFile != null && tempFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ public class Logger {
* returns new {@link Slf4jLogger#Slf4jLogger(Class)}, else returns new {@link #Logger()}. */
public static Logger create(Class cls) {
String s = System.getProperty("org.bytedeco.javacpp.logger", "").toLowerCase();
if (s.equals("slf4j") || s.equals("slf4jlogger")) {
return new Slf4jLogger(cls);
} else {
return new Logger();
}
return new Logger();
}

static boolean debug = false;
Expand Down

0 comments on commit 66414ea

Please sign in to comment.