From 3857a631189eb7d5a73560ecd08c8e3c7d7af2b5 Mon Sep 17 00:00:00 2001 From: BobHanson Date: Wed, 3 Jun 2020 09:24:06 -0500 Subject: [PATCH] JAL-3446 from JAL-3253 ApplicationSingletonProvider missing for RestClient; others are just cosmetic --- .../datamodel/features/FeatureAttributes.java | 10 +++--- .../fts/service/uniprot/UniProtFTSRestClient.java | 2 +- src/jalview/httpserver/HttpServer.java | 34 +++++++++++--------- src/jalview/io/FileFormats.java | 14 ++++---- src/jalview/io/cache/AppCache.java | 9 +++--- src/jalview/io/gff/SequenceOntologyFactory.java | 11 ++++--- .../structure/StructureSelectionManager.java | 17 +++++----- src/jalview/urls/IdOrgSettings.java | 10 +++--- src/jalview/ws/rest/RestClient.java | 7 ++++ 9 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/jalview/datamodel/features/FeatureAttributes.java b/src/jalview/datamodel/features/FeatureAttributes.java index 01f04d5..1a125c2 100644 --- a/src/jalview/datamodel/features/FeatureAttributes.java +++ b/src/jalview/datamodel/features/FeatureAttributes.java @@ -48,6 +48,11 @@ public class FeatureAttributes implements ApplicationSingletonI .getInstance(FeatureAttributes.class); } + private FeatureAttributes() + { + attributes = new HashMap<>(); + } + /* * map, by feature type, of a map, by attribute name, of * attribute description and min-max range (if known) @@ -199,11 +204,6 @@ public class FeatureAttributes implements ApplicationSingletonI } } - private FeatureAttributes() - { - attributes = new HashMap<>(); - } - /** * Answers the attribute names known for the given feature type, in * alphabetical order (not case sensitive), or an empty set if no attributes diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index f227d58..0d860c4 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -64,7 +64,7 @@ return (FTSRestClientI) ApplicationSingletonProvider public final String uniprotSearchEndpoint; - public UniProtFTSRestClient() + private UniProtFTSRestClient() { super(); uniprotSearchEndpoint = Cache.getDefault("UNIPROT_DOMAIN", diff --git a/src/jalview/httpserver/HttpServer.java b/src/jalview/httpserver/HttpServer.java index 9a59bda..7021fae 100644 --- a/src/jalview/httpserver/HttpServer.java +++ b/src/jalview/httpserver/HttpServer.java @@ -66,6 +66,24 @@ public class HttpServer implements ApplicationSingletonI return (HttpServer) ApplicationSingletonProvider.getInstance(HttpServer.class); } } + + /** + * Private constructor to enforce use of singleton + * + * @throws BindException + * if no free port can be assigned + */ + private HttpServer() throws BindException + { + startServer(); + + /* + * Provides a REST server by default; add more programmatically as required + */ + registerHandler(RestHandler.getInstance()); + } + + /* * 'context root' - actually just prefixed to the path for each handler for * now - see registerHandler @@ -94,22 +112,6 @@ public class HttpServer implements ApplicationSingletonI /** - * Private constructor to enforce use of singleton - * - * @throws BindException - * if no free port can be assigned - */ - private HttpServer() throws BindException - { - startServer(); - - /* - * Provides a REST server by default; add more programmatically as required - */ - registerHandler(RestHandler.getInstance()); - } - - /** * Start the http server * * @throws BindException diff --git a/src/jalview/io/FileFormats.java b/src/jalview/io/FileFormats.java index 7743e17..fca29bd 100644 --- a/src/jalview/io/FileFormats.java +++ b/src/jalview/io/FileFormats.java @@ -46,6 +46,13 @@ public class FileFormats implements ApplicationSingletonI return (FileFormats) ApplicationSingletonProvider.getInstance(FileFormats.class); } + /** + * Private constructor registers Jalview's built-in file formats + */ + private FileFormats() + { + reset(); + } /* * A lookup map of file formats by upper-cased name @@ -57,13 +64,6 @@ public class FileFormats implements ApplicationSingletonI */ private Set identifiable; - /** - * Private constructor registers Jalview's built-in file formats - */ - private FileFormats() - { - reset(); - } /** * Reset to just the built-in file formats packaged with Jalview. These are diff --git a/src/jalview/io/cache/AppCache.java b/src/jalview/io/cache/AppCache.java index 76827f9..fdcad08 100644 --- a/src/jalview/io/cache/AppCache.java +++ b/src/jalview/io/cache/AppCache.java @@ -41,6 +41,11 @@ public class AppCache implements ApplicationSingletonI return (AppCache) ApplicationSingletonProvider.getInstance(AppCache.class); } + private AppCache() + { + cacheItems = new Hashtable>(); + } + public static final String DEFAULT_LIMIT = "99"; public static final String CACHE_DELIMITER = ";"; @@ -49,10 +54,6 @@ public class AppCache implements ApplicationSingletonI private Hashtable> cacheItems; - private AppCache() - { - cacheItems = new Hashtable>(); - } /** * Method to obtain all the cache items for a given cache key diff --git a/src/jalview/io/gff/SequenceOntologyFactory.java b/src/jalview/io/gff/SequenceOntologyFactory.java index ee362b4..08a2c6a 100644 --- a/src/jalview/io/gff/SequenceOntologyFactory.java +++ b/src/jalview/io/gff/SequenceOntologyFactory.java @@ -48,6 +48,12 @@ public class SequenceOntologyFactory implements ApplicationSingletonI .getInstance(SequenceOntologyFactory.class); } + private SequenceOntologyFactory() + { + // private singleton + } + + /** * Answers the configured model of the Sequence Ontology. * @@ -74,9 +80,4 @@ public class SequenceOntologyFactory implements ApplicationSingletonI private SequenceOntologyI sequenceOntology; - private SequenceOntologyFactory() - { - // private singleton - } - } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 5b432f5..bb1bb94 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -103,6 +103,15 @@ public class StructureSelectionManager implements ApplicationSingletonI } /** + * Private constructor as all 'singleton' instances are managed here or by + * ApplicationSingletonProvider + */ + private StructureSelectionManager() + { + selectionManagers = new IdentityHashMap<>(); + } + + /** * Answers an instance of this class for the current application (Java or JS * 'applet') scope, and scoped to the specified context * @@ -136,14 +145,6 @@ public class StructureSelectionManager implements ApplicationSingletonI return instance; } - /** - * Private constructor as all 'singleton' instances are managed here or by - * ApplicationSingletonProvider - */ - private StructureSelectionManager() - { - selectionManagers = new IdentityHashMap<>(); - } /** * @return true if will try to use external services for processing secondary diff --git a/src/jalview/urls/IdOrgSettings.java b/src/jalview/urls/IdOrgSettings.java index cd7e98e..7c38ab6 100644 --- a/src/jalview/urls/IdOrgSettings.java +++ b/src/jalview/urls/IdOrgSettings.java @@ -39,6 +39,11 @@ public class IdOrgSettings implements ApplicationSingletonI .getInstance(IdOrgSettings.class); } + private IdOrgSettings() + { + // private singleton + } + public static void setUrl(String seturl) { getInstance().url = seturl; @@ -58,9 +63,4 @@ public class IdOrgSettings implements ApplicationSingletonI { return getInstance().location; } - - private IdOrgSettings() - { - // private singleton - } } diff --git a/src/jalview/ws/rest/RestClient.java b/src/jalview/ws/rest/RestClient.java index eea6474..41c5716 100644 --- a/src/jalview/ws/rest/RestClient.java +++ b/src/jalview/ws/rest/RestClient.java @@ -54,6 +54,13 @@ public class RestClient extends WSClient implements WSClientI, WSMenuEntryProviderI, ApplicationSingletonI { + @SuppressWarnings("unused") + private RestClient() + { + // accessed by ApplicationSingletonProvider + } + + private static RestClient getInstance() { return (RestClient) ApplicationSingletonProvider.getInstance(RestClient.class); -- 1.7.10.2