/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.bin;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.StructureSelectionManagerProvider;
import jalview.ext.ensembl.EnsemblInfo;
import jalview.fts.service.pdb.PDBFTSRestClient;
import jalview.fts.service.uniprot.UniProtFTSRestClient;
import jalview.gui.Desktop;
import jalview.httpserver.HttpServer;
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.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.util.IdentityHashMap;
/**
* 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
{
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._jalviewInstance;
*/
{
i = instance;
}
if (i == null)
{
i = instance = new Instance();
/**
* @j2sNative g._jalviewInstance = i;
*/
}
return i;
}
public Jalview jalview;
public Desktop 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 ColourSchemes colourSchemes;
public Discoverer discoverer;
public HttpServer httpServer;
public RestClient restClient;
public RestHandler restHandler;
public ScoreModels scoreModels;
public jalview.ws.SequenceFetcher sequenceFetcher;
public SiftsSettings siftsSettings;
// 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 AlignmentSorter alignmentSorter;
public Cache cache;
public EnsemblInfo ensemblInfo;
public IdOrgSettings idOrgSettings;
public Jws2Discoverer j2s2discoverer;
public Jws2InstanceFactory jws2InstanceFactory;
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 structureSelections;
}