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.ws.jws1.Discoverer;
42 import jalview.ws.jws2.Jws2Discoverer;
43 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
44 import jalview.ws.rest.RestClient;
45 import jalview.ws.sifts.SiftsSettings;
47 import java.util.IdentityHashMap;
50 * A class to hold singleton instances so that they are not shared among
51 * multiple JavaScript apps on a page. Fields are all formerly static class or
52 * object references are preserved in this singleton as "pseudo" static
53 * references that will be unique for each JavaScript applet or Java
56 * There are three kinds of references:
58 * Class references for classes with public getInstance() calls and a private
61 * Class references for classes with private getInstance() calls and a private
64 * Object references held here for a class as "pseudo" static field and
65 * referenced by Instance.getInstance().fieldName. These classes
75 // singleton -- use getInstance();
78 private static Instance instance;
82 * Creates a static reference to this class, either as a static field (Java)
83 * or as an element in the applet's ThreadGroup object.
85 * @return new Instance()
87 public static Instance getInstance()
90 @SuppressWarnings("unused")
91 ThreadGroup g = Thread.currentThread().getThreadGroup();
93 * @j2sNative i = g._jalviewInstance;
100 i = instance = new Instance();
102 * @j2sNative g._jalviewInstance = i;
108 public Jalview jalview;
110 public Desktop desktop;
114 // The following are PUBLIC singletons; their class has a private constructor
115 // that is assigned by the class as part of a public static getInstance()
118 public AppCache appCache;
120 public ColourSchemes colourSchemes;
122 public Discoverer discoverer;
124 public FileFormats fileFormats;
126 public HttpServer httpServer;
128 public RestClient restClient;
130 public RestHandler restHandler;
132 public ScoreModels scoreModels;
134 public jalview.ws.SequenceFetcher sequenceFetcher;
136 public SiftsSettings siftsSettings;
139 // The following are PRIVATE singletons; their class has only static public
140 // methods and a private constructor that is assigned by the class as part of
141 // a private static getInstance() call.
143 public AlignmentSorter alignmentSorter;
147 public EnsemblInfo ensemblInfo;
149 public FeatureAttributes featureAttributes;
151 public FeatureSources featureSources;
153 public IdOrgSettings idOrgSettings;
155 public Jws2Discoverer j2s2discoverer;
157 public Jws2InstanceFactory jws2InstanceFactory;
159 public PDBFTSRestClient pdbFTSRestClient;
161 public SequenceOntologyFactory sequenceOntologyFactory;
163 public StructureImportSettings structureImportSettings;
165 public UniProtFTSRestClient uniprotFTSRestClient;
167 // The following formerly static Object references are
168 // preserved in this singleton as "pseudo" static references
169 // that will be unique for each JavaScript applet or Java application.
172 * StructureSelectionManager "static"
174 public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;