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.datamodel.features.FeatureAttributes;
27 import jalview.datamodel.features.FeatureSources;
28 import jalview.ext.ensembl.EnsemblInfo;
29 import jalview.fts.service.pdb.PDBFTSRestClient;
30 import jalview.fts.service.uniprot.UniProtFTSRestClient;
31 import jalview.gui.Desktop;
32 import jalview.httpserver.HttpServer;
33 import jalview.io.FileFormats;
34 import jalview.io.cache.AppCache;
35 import jalview.io.gff.SequenceOntologyFactory;
36 import jalview.rest.RestHandler;
37 import jalview.schemes.ColourSchemes;
38 import jalview.structure.StructureImportSettings;
39 import jalview.structure.StructureSelectionManager;
40 import jalview.urls.IdOrgSettings;
41 import jalview.util.Platform;
42 import jalview.ws.jws1.Discoverer;
43 import jalview.ws.jws2.Jws2Discoverer;
44 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
45 import jalview.ws.rest.RestClient;
46 import jalview.ws.sifts.SiftsSettings;
48 import java.util.IdentityHashMap;
51 * A class to hold singleton instances so that they are not shared among
52 * multiple JavaScript apps on a page. Fields are all formerly static class or
53 * object references are preserved in this singleton as "pseudo" static
54 * references that will be unique for each JavaScript applet or Java
57 * There are three kinds of references:
59 * Class references for classes with public getInstance() calls and a private
62 * Class references for classes with private getInstance() calls and a private
65 * Object references held here for a class as "pseudo" static field and
66 * referenced by Instance.getInstance().fieldName. These classes
76 // singleton -- use getInstance();
79 private static Instance instance;
83 * Creates a static reference to this class, either as a static field (Java)
84 * or as an element in the applet's ThreadGroup object.
86 * @return new Instance()
88 public static Instance getInstance()
91 // assign g only if JavaScript and instance only if Java
93 @SuppressWarnings("unused")
94 ThreadGroup g = (Platform.isJS()
95 ? Thread.currentThread().getThreadGroup()
97 Instance i = /** @j2sNative g._jalviewInstance || */
102 * @j2sNative g._jalviewInstance =
105 instance = /** @j2sNative null && */
111 public Jalview jalview;
113 public Desktop desktop;
117 // The following are PUBLIC singletons; their class has a private constructor
118 // that is assigned by the class as part of a public static getInstance()
121 public AppCache appCache;
123 public ColourSchemes colourSchemes;
125 public Discoverer discoverer;
127 public FileFormats fileFormats;
129 public HttpServer httpServer;
131 public RestClient restClient;
133 public RestHandler restHandler;
135 public ScoreModels scoreModels;
137 public jalview.ws.SequenceFetcher sequenceFetcher;
139 public SiftsSettings siftsSettings;
142 // The following are PRIVATE singletons; their class has only static public
143 // methods and a private constructor that is assigned by the class as part of
144 // a private static getInstance() call.
146 public AlignmentSorter alignmentSorter;
150 public EnsemblInfo ensemblInfo;
152 public FeatureAttributes featureAttributes;
154 public FeatureSources featureSources;
156 public IdOrgSettings idOrgSettings;
158 public Jws2Discoverer j2s2discoverer;
160 public Jws2InstanceFactory jws2InstanceFactory;
162 public PDBFTSRestClient pdbFTSRestClient;
164 public SequenceOntologyFactory sequenceOntologyFactory;
166 public StructureImportSettings structureImportSettings;
168 public UniProtFTSRestClient uniprotFTSRestClient;
170 // The following formerly static Object references are
171 // preserved in this singleton as "pseudo" static references
172 // that will be unique for each JavaScript applet or Java application.
175 * StructureSelectionManager "static"
177 public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;