working on getting TestNG working with singletons
- static Cache instance;
-
/**
* In Java, this will be a static field instance, which will be
* application-specific; in JavaScript it will be an applet-specific instance
/**
* In Java, this will be a static field instance, which will be
* application-specific; in JavaScript it will be an applet-specific instance
*/
public class Jalview
{
*/
public class Jalview
{
+
+ public Jalview()
+ {
+ setInstance(this);
+ }
+
static
{
Platform.getURLCommandArguments();
static
{
Platform.getURLCommandArguments();
public static Jalview getInstance()
{
public static Jalview getInstance()
{
+ if (instance == null)
+ {
+ instance = new Jalview();
+ }
Jalview j;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
Jalview j;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
public static void main(String[] args)
{
// setLogging(); // BH - for event debugging in JavaScript
public static void main(String[] args)
{
// setLogging(); // BH - for event debugging in JavaScript
- setInstance(new Jalview());
getInstance().doMain(args);
}
getInstance().doMain(args);
}
public static Desktop getInstance()
{
public static Desktop getInstance()
{
+ if (instance == null)
+ {
+ new Desktop(true);
+ }
Desktop d;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
Desktop d;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
public JInternalFrame conservationSlider, PIDSlider;
public JInternalFrame conservationSlider, PIDSlider;
+ private boolean instanceOnly;
+
class MyDesktopManager implements DesktopManager
{
class MyDesktopManager implements DesktopManager
{
+ public Desktop(boolean forInstance)
+ {
+ instanceOnly = true;
+ setInstance(this);
+ }
/**
* Creates a new Desktop object.
*/
public Desktop()
{
/**
* Creates a new Desktop object.
*/
public Desktop()
{
/**
* A note to implementors. It is ESSENTIAL that any activities that might
* block are spawned off as threads rather than waited for during this
/**
* A note to implementors. It is ESSENTIAL that any activities that might
* block are spawned off as threads rather than waited for during this
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
- if (getInstance() == null || Jalview.isHeadlessMode())
+ if (getInstance().instanceOnly || Jalview.isHeadlessMode())
- if (getInstance() == null)