X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FInstance.java;h=96d5d6f9a3031124cce38f8d59f81ea53138df2e;hb=6a211e41dfcf8f187caf29a307fc9ae983ad4d57;hp=24d67afb88cf0c98c551b8f1c6cdd82f3252f6ab;hpb=12443642377be74159578c99af7a9883571e38bf;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index 24d67af..96d5d6f 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -42,7 +42,42 @@ public class Instance { private static TraceHandler tracer; private static TempFiles tempFiles; - static { + private static boolean init; + + /** + * Initialise the instance -- if already initialised, nothing will happen. + *

+ * Before calling this method, you may call + * {@link Bundles#setDirectory(String)} if wanted. + */ + static public void init() { + init(false); + } + + /** + * Initialise the instance -- if already initialised, nothing will happen + * unless you pass TRUE to force. + *

+ * Before calling this method, you may call + * {@link Bundles#setDirectory(String)} if wanted. + *

+ * Note: forcing the initialisation can be dangerous, so make sure to only + * make it under controlled circumstances -- for instance, at the start of + * the program, you could call {@link Instance#init()}, change some settings + * because you want to force those settings (it will also forbid users to + * change them!) and then call {@link Instance#init(boolean)} with + * force set to TRUE. + * + * @param force + * force the initialisation even if already initialised + */ + static public void init(boolean force) { + if (init && !force) { + return; + } + + init = true; + // Before we can configure it: Boolean debug = checkEnv("DEBUG"); boolean trace = debug != null && debug; @@ -441,6 +476,7 @@ public class Instance { + getFile(libDir), e)); } } else { + Exception ex = null; int pos = remoteLib.lastIndexOf(":"); if (pos >= 0) { String port = remoteLib.substring(pos + 1).trim(); @@ -459,13 +495,14 @@ public class Instance { lib); } catch (Exception e) { + ex = e; } } } if (lib == null) { tracer.error(new IOException( - "Cannot create remote library for: " + remoteLib)); + "Cannot create remote library for: " + remoteLib, ex)); } } @@ -549,7 +586,7 @@ public class Instance { private static String getLang() { String lang = config.getString(Config.LANG); - if (lang == null | lang.isEmpty()) { + if (lang == null || lang.isEmpty()) { if (System.getenv("LANG") != null && !System.getenv("LANG").isEmpty()) { lang = System.getenv("LANG");