* store the new singleton; note that a
* null value is saved if construction failed
*/
- getContextMap().put(c, o);
-
+ setInstance(c, o);
return o;
}
+ public static void setInstance(Class<? extends ApplicationSingletonI> c,
+ ApplicationSingletonI o)
+ {
+ getContextMap().put(c, o);
+ }
/**
* Removes the current singleton instance of the given class from the current
* application context. This has the effect of ensuring that a new instance is
* JInternalFrame objects when in that mode.
*
*/
- private boolean instanceOnly;
+ boolean instanceOnly;
class MyDesktopManager implements DesktopManager
{
}
/**
- * For testing purposes, this constructor can be utilized to allow the creation
- * of a singleton Desktop instance without the formation of frames. The Cache is
- * initialized, but that is all.
- *
- * It is not currently used.
+ * For TestNG, this constructor can be utilized to allow the creation of a
+ * singleton Desktop instance without the formation of frames and, especially,
+ * not involving dialogs. Cache.log is also initialized for some tests that
+ * require it despite there being no Desktop.
*
* @param forInstance
*/
public Desktop(boolean forInstance)
{
-
+ ApplicationSingletonProvider.setInstance(Desktop.class, this);
Cache.initLogger();
instanceOnly = true;
}
{
}
}
- if (instanceOnly)
+ System.out.println("Desktop headless or instanceonly" + instanceOnly
+ + " " + Jalview.isHeadlessMode());
+ if (instanceOnly || Jalview.isHeadlessMode())
{
return;
}