import jalview.fts.service.uniprot.UniProtFTSRestClient;
import jalview.gui.Desktop;
import jalview.httpserver.HttpServer;
-import jalview.io.gff.SequenceOntologyI;
+import jalview.io.gff.SequenceOntologyFactory;
import jalview.rest.RestHandler;
+import jalview.schemes.ColourSchemes;
import jalview.structure.StructureImportSettings;
import jalview.structure.StructureSelectionManager;
import jalview.urls.IdOrgSettings;
-import jalview.ws.SequenceFetcher;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
import jalview.ws.rest.RestClient;
import jalview.ws.sifts.SiftsSettings;
-import java.awt.Color;
import java.util.IdentityHashMap;
/**
- * a class to hold singleton instances so that they are not shared
+ * A class to hold singleton instances so that they are not shared among
+ * multiple JavaScript apps on a page. Fields are all formerly static class or
+ * object references are preserved in this singleton as "pseudo" static
+ * references that will be unique for each JavaScript applet or Java
+ * application.
+ *
+ * There are three kinds of references:
+ *
+ * Class references for classes with public getInstance() calls and a private
+ * constructor.
+ *
+ * Class references for classes with private getInstance() calls and a private
+ * constructor.
+ *
+ * Object references held here for a class as "pseudo" static field and
+ * referenced by Instance.getInstance().fieldName. These classes
*
* @author hansonr
*
*/
-public class Instance {
+public class Instance
+{
+
+ private Instance()
+ {
+ // singleton -- use getInstance();
+ }
private static Instance instance;
+ /**
+ *
+ * Creates a static reference to this class, either as a static field (Java)
+ * or as an element in the applet's ThreadGroup object.
+ *
+ * @return new Instance()
+ */
public static Instance getInstance()
{
Instance i;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
/**
- * @j2sNative i = g._instance;
+ * @j2sNative i = g._jalviewInstance;
*/
{
i = instance;
{
i = instance = new Instance();
/**
- * @j2sNative g._instance = i;
+ * @j2sNative g._jalviewInstance = i;
*/
}
return i;
}
- /**
- * singleton instance of this class in Java only
- */
-
public Jalview jalview;
public Desktop desktop;
- public static Jalview getJalview()
- {
- Instance i = getInstance();
- if (i.jalview == null)
- {
- new Jalview();
- }
- return i.jalview;
- }
- public static void setJalview(Jalview j)
- {
- getInstance().jalview = j;
- }
- public static Desktop getDesktop()
- {
- Instance i = getInstance();
- return (i.desktop == null ? (i.desktop = new Desktop(true))
- : i.desktop);
- }
+ // The following are PUBLIC singletons; their class has a private constructor
+ // that is assigned by the class as part of a public static getInstance()
+ // call.
- public static void setDesktop(Desktop d)
- {
- getInstance().desktop = d;
- }
+ public ColourSchemes colourSchemes;
- public Cache cache;
+ public Discoverer discoverer;
- public AlignmentSorter alignmentSorter;
+ public HttpServer httpServer;
- public Color[] rnaHelices = null;
+ public RestClient restClient;
- public Discoverer discoverer;
+ public RestHandler restHandler;
- public EnsemblInfo ensemblInfo;
+ public ScoreModels scoreModels;
- public HttpServer httpServer;
+ public jalview.ws.SequenceFetcher sequenceFetcher;
- public IdOrgSettings idOrgSettings;
+ public SiftsSettings siftsSettings;
- public Jws2Discoverer j2s2discoverer;
- public Jws2InstanceFactory jws2InstanceFactory;
+ // The following are PRIVATE singletons; their class has only static public
+ // methods and a private constructor that is assigned by the class as part of
+ // a private static getInstance() call.
- public PDBFTSRestClient pdbFTSRestClient;
+ public AlignmentSorter alignmentSorter;
- public RestClient restClient;
+ public Cache cache;
- public RestHandler restHandler;
+ public EnsemblInfo ensemblInfo;
- public ScoreModels scoreModels;
+ public IdOrgSettings idOrgSettings;
- public SequenceFetcher sequenceFetcher;
+ public Jws2Discoverer j2s2discoverer;
- public SequenceOntologyI sequenceOntology;
+ public Jws2InstanceFactory jws2InstanceFactory;
- public SiftsSettings siftsSettings;
+ public PDBFTSRestClient pdbFTSRestClient;
+
+ public SequenceOntologyFactory sequenceOntologyFactory;
public StructureImportSettings structureImportSettings;
public UniProtFTSRestClient uniprotFTSRestClient;
+ // The following formerly static Object references are
+ // preserved in this singleton as "pseudo" static references
+ // that will be unique for each JavaScript applet or Java application.
+
+ /**
+ * StructureSelectionManager "static"
+ */
public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
}