2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AlignmentSorter;
24 import jalview.analysis.scoremodels.ScoreModels;
25 import jalview.api.StructureSelectionManagerProvider;
26 import jalview.ext.ensembl.EnsemblInfo;
27 import jalview.fts.service.pdb.PDBFTSRestClient;
28 import jalview.fts.service.uniprot.UniProtFTSRestClient;
29 import jalview.gui.Desktop;
30 import jalview.httpserver.HttpServer;
31 import jalview.io.gff.SequenceOntologyFactory;
32 import jalview.rest.RestHandler;
33 import jalview.schemes.ColourSchemes;
34 import jalview.structure.StructureImportSettings;
35 import jalview.structure.StructureSelectionManager;
36 import jalview.urls.IdOrgSettings;
37 import jalview.ws.jws1.Discoverer;
38 import jalview.ws.jws2.Jws2Discoverer;
39 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
40 import jalview.ws.rest.RestClient;
41 import jalview.ws.sifts.SiftsSettings;
43 import java.util.IdentityHashMap;
46 * A class to hold singleton instances so that they are not shared among
47 * multiple JavaScript apps on a page. Fields are all formerly static class or
48 * object references are preserved in this singleton as "pseudo" static
49 * references that will be unique for each JavaScript applet or Java
52 * There are three kinds of references:
54 * Class references for classes with public getInstance() calls and a private
57 * Class references for classes with private getInstance() calls and a private
60 * Object references held here for a class as "pseudo" static field and
61 * referenced by Instance.getInstance().fieldName. These classes
71 // singleton -- use getInstance();
74 private static Instance instance;
78 * Creates a static reference to this class, either as a static field (Java)
79 * or as an element in the applet's ThreadGroup object.
81 * @return new Instance()
83 public static Instance getInstance()
86 @SuppressWarnings("unused")
87 ThreadGroup g = Thread.currentThread().getThreadGroup();
89 * @j2sNative i = g._jalviewInstance;
96 i = instance = new Instance();
98 * @j2sNative g._jalviewInstance = i;
104 public Jalview jalview;
106 public Desktop desktop;
110 // The following are PUBLIC singletons; their class has a private constructor
111 // that is assigned by the class as part of a public static getInstance()
114 public ColourSchemes colourSchemes;
116 public Discoverer discoverer;
118 public HttpServer httpServer;
120 public RestClient restClient;
122 public RestHandler restHandler;
124 public ScoreModels scoreModels;
126 public jalview.ws.SequenceFetcher sequenceFetcher;
128 public SiftsSettings siftsSettings;
131 // The following are PRIVATE singletons; their class has only static public
132 // methods and a private constructor that is assigned by the class as part of
133 // a private static getInstance() call.
135 public AlignmentSorter alignmentSorter;
139 public EnsemblInfo ensemblInfo;
141 public IdOrgSettings idOrgSettings;
143 public Jws2Discoverer j2s2discoverer;
145 public Jws2InstanceFactory jws2InstanceFactory;
147 public PDBFTSRestClient pdbFTSRestClient;
149 public SequenceOntologyFactory sequenceOntologyFactory;
151 public StructureImportSettings structureImportSettings;
153 public UniProtFTSRestClient uniprotFTSRestClient;
155 // The following formerly static Object references are
156 // preserved in this singleton as "pseudo" static references
157 // that will be unique for each JavaScript applet or Java application.
160 * StructureSelectionManager "static"
162 public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;