git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ad1f430
)
JAL-3253 jalview.bin.Instance for AppCache and FeatureAttribute
author
hansonr
<hansonr@STO24954W.ad.stolaf.edu>
Fri, 10 May 2019 18:18:12 +0000
(13:18 -0500)
committer
hansonr
<hansonr@STO24954W.ad.stolaf.edu>
Fri, 10 May 2019 18:18:12 +0000
(13:18 -0500)
src/jalview/analysis/scoremodels/FeatureDistanceModel.java
patch
|
blob
|
history
src/jalview/bin/Instance.java
patch
|
blob
|
history
src/jalview/datamodel/features/FeatureAttributes.java
patch
|
blob
|
history
src/jalview/datamodel/features/FeatureSources.java
patch
|
blob
|
history
src/jalview/io/FileFormats.java
patch
|
blob
|
history
src/jalview/io/cache/AppCache.java
patch
|
blob
|
history
diff --git
a/src/jalview/analysis/scoremodels/FeatureDistanceModel.java
b/src/jalview/analysis/scoremodels/FeatureDistanceModel.java
index
e506be2
..
38217e9
100644
(file)
--- a/
src/jalview/analysis/scoremodels/FeatureDistanceModel.java
+++ b/
src/jalview/analysis/scoremodels/FeatureDistanceModel.java
@@
-55,12
+55,12
@@
public class FeatureDistanceModel extends DistanceScoreModel
@Override
public ScoreModelI getInstance(AlignmentViewPanel view)
{
@Override
public ScoreModelI getInstance(AlignmentViewPanel view)
{
- FeatureDistanceModel instance;
+ FeatureDistanceModel model;
try
{
try
{
- instance = this.getClass().newInstance();
- instance.configureFromAlignmentView(view);
- return instance;
+ model = this.getClass().newInstance();
+ model.configureFromAlignmentView(view);
+ return model;
} catch (InstantiationException | IllegalAccessException e)
{
System.err.println("Error in " + getClass().getName()
} catch (InstantiationException | IllegalAccessException e)
{
System.err.println("Error in " + getClass().getName()
diff --git
a/src/jalview/bin/Instance.java
b/src/jalview/bin/Instance.java
index
acb6c84
..
3bcd618
100644
(file)
--- a/
src/jalview/bin/Instance.java
+++ b/
src/jalview/bin/Instance.java
@@
-23,11
+23,15
@@
package jalview.bin;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.StructureSelectionManagerProvider;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.StructureSelectionManagerProvider;
+import jalview.datamodel.features.FeatureAttributes;
+import jalview.datamodel.features.FeatureSources;
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.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.FileFormats;
+import jalview.io.cache.AppCache;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.rest.RestHandler;
import jalview.schemes.ColourSchemes;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.rest.RestHandler;
import jalview.schemes.ColourSchemes;
@@
-111,10
+115,14
@@
public class Instance
// that is assigned by the class as part of a public static getInstance()
// call.
// that is assigned by the class as part of a public static getInstance()
// call.
+ public AppCache appCache;
+
public ColourSchemes colourSchemes;
public Discoverer discoverer;
public ColourSchemes colourSchemes;
public Discoverer discoverer;
+ public FileFormats fileFormats;
+
public HttpServer httpServer;
public RestClient restClient;
public HttpServer httpServer;
public RestClient restClient;
@@
-138,6
+146,10
@@
public class Instance
public EnsemblInfo ensemblInfo;
public EnsemblInfo ensemblInfo;
+ public FeatureAttributes featureAttributes;
+
+ public FeatureSources featureSources;
+
public IdOrgSettings idOrgSettings;
public Jws2Discoverer j2s2discoverer;
public IdOrgSettings idOrgSettings;
public Jws2Discoverer j2s2discoverer;
@@
-161,4
+173,5
@@
public class Instance
*/
public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
*/
public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
+
}
}
diff --git
a/src/jalview/datamodel/features/FeatureAttributes.java
b/src/jalview/datamodel/features/FeatureAttributes.java
index
7acebee
..
81c670b
100644
(file)
--- a/
src/jalview/datamodel/features/FeatureAttributes.java
+++ b/
src/jalview/datamodel/features/FeatureAttributes.java
@@
-1,5
+1,7
@@
package jalview.datamodel.features;
package jalview.datamodel.features;
+import jalview.bin.Instance;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@
-19,7
+21,18
@@
public class FeatureAttributes
Character, Number, Mixed
}
Character, Number, Mixed
}
- private static FeatureAttributes instance = new FeatureAttributes();
+ public static FeatureAttributes getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.featureAttributes == null
+ ? i.featureAttributes = new FeatureAttributes()
+ : i.featureAttributes);
+ }
+
+ private FeatureAttributes()
+ {
+ attributes = new HashMap<>();
+ }
/*
* map, by feature type, of a map, by attribute name, of
/*
* map, by feature type, of a map, by attribute name, of
@@
-173,21
+186,6
@@
public class FeatureAttributes
}
/**
}
/**
- * Answers the singleton instance of this class
- *
- * @return
- */
- public static FeatureAttributes getInstance()
- {
- return instance;
- }
-
- 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
* are known. An attribute name is typically 'simple' e.g. "AC", but may be
* Answers the attribute names known for the given feature type, in
* alphabetical order (not case sensitive), or an empty set if no attributes
* are known. An attribute name is typically 'simple' e.g. "AC", but may be
diff --git
a/src/jalview/datamodel/features/FeatureSources.java
b/src/jalview/datamodel/features/FeatureSources.java
index
1be1b82
..
a281eea
100644
(file)
--- a/
src/jalview/datamodel/features/FeatureSources.java
+++ b/
src/jalview/datamodel/features/FeatureSources.java
@@
-1,31
+1,23
@@
package jalview.datamodel.features;
package jalview.datamodel.features;
+import jalview.bin.Instance;
+
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
-/**
- * A singleton to hold metadata about feature attributes, keyed by a unique
- * feature source identifier
- *
- * @author gmcarstairs
- *
- */
public class FeatureSources
{
public class FeatureSources
{
- private static FeatureSources instance = new FeatureSources();
-
- private Map<String, FeatureSourceI> sources;
- /**
- * Answers the singleton instance of this class
- *
- * @return
- */
public static FeatureSources getInstance()
{
public static FeatureSources getInstance()
{
- return instance;
+ Instance i = Instance.getInstance();
+ return (i.featureSources == null
+ ? i.featureSources = new FeatureSources()
+ : i.featureSources);
}
}
+ private Map<String, FeatureSourceI> sources;
+
private FeatureSources()
{
sources = new HashMap<>();
private FeatureSources()
{
sources = new HashMap<>();
diff --git
a/src/jalview/io/FileFormats.java
b/src/jalview/io/FileFormats.java
index
aadcdb9
..
fb490d3
100644
(file)
--- a/
src/jalview/io/FileFormats.java
+++ b/
src/jalview/io/FileFormats.java
@@
-20,6
+20,8
@@
*/
package jalview.io;
*/
package jalview.io;
+import jalview.bin.Instance;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@
-38,8
+40,6
@@
import java.util.Set;
*/
public class FileFormats
{
*/
public class FileFormats
{
- private static FileFormats instance = new FileFormats();
-
/*
* A lookup map of file formats by upper-cased name
*/
/*
* A lookup map of file formats by upper-cased name
*/
@@
-52,7
+52,9
@@
public class FileFormats
public static FileFormats getInstance()
{
public static FileFormats getInstance()
{
- return instance;
+ Instance i = Instance.getInstance();
+ return (i.fileFormats == null ? i.fileFormats = new FileFormats()
+ : i.fileFormats);
}
/**
}
/**
@@
-70,8
+72,8
@@
public class FileFormats
*/
public synchronized void reset()
{
*/
public synchronized void reset()
{
- formats = new LinkedHashMap<String, FileFormatI>();
- identifiable = new HashSet<FileFormatI>();
+ formats = new LinkedHashMap<>();
+ identifiable = new HashSet<>();
for (FileFormat format : FileFormat.values())
{
registerFileFormat(format, format.isIdentifiable());
for (FileFormat format : FileFormat.values())
{
registerFileFormat(format, format.isIdentifiable());
@@
-135,7
+137,7
@@
public class FileFormats
*/
public List<String> getWritableFormats(boolean textOnly)
{
*/
public List<String> getWritableFormats(boolean textOnly)
{
- List<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<>();
for (FileFormatI ff : formats.values())
{
if (ff.isWritable() && (!textOnly || ff.isTextFormat()))
for (FileFormatI ff : formats.values())
{
if (ff.isWritable() && (!textOnly || ff.isTextFormat()))
@@
-154,7
+156,7
@@
public class FileFormats
*/
public List<String> getReadableFormats()
{
*/
public List<String> getReadableFormats()
{
- List<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<>();
for (FileFormatI ff : formats.values())
{
if (ff.isReadable())
for (FileFormatI ff : formats.values())
{
if (ff.isReadable())
diff --git
a/src/jalview/io/cache/AppCache.java
b/src/jalview/io/cache/AppCache.java
index
eaf6ecd
..
459562d
100644
(file)
--- a/
src/jalview/io/cache/AppCache.java
+++ b/
src/jalview/io/cache/AppCache.java
@@
-21,6
+21,7
@@
package jalview.io.cache;
import jalview.bin.Cache;
package jalview.io.cache;
import jalview.bin.Cache;
+import jalview.bin.Instance;
import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.Hashtable;
import java.util.LinkedHashSet;
@@
-28,26
+29,32
@@
import java.util.LinkedHashSet;
/**
* A singleton class used for querying and persisting cache items.
*
/**
* A singleton class used for querying and persisting cache items.
*
+ *
* @author tcnofoegbu
*
*/
public class AppCache
{
* @author tcnofoegbu
*
*/
public class AppCache
{
+
+ public static AppCache getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.appCache == null ? i.appCache = new AppCache() : i.appCache);
+ }
+
+ private AppCache()
+ {
+ cacheItems = new Hashtable<>();
+ }
+
public static final String DEFAULT_LIMIT = "99";
public static final String CACHE_DELIMITER = ";";
public static final String DEFAULT_LIMIT = "99";
public static final String CACHE_DELIMITER = ";";
- private static AppCache instance = null;
-
private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
private Hashtable<String, LinkedHashSet<String>> cacheItems;
private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
private Hashtable<String, LinkedHashSet<String>> cacheItems;
- private AppCache()
- {
- cacheItems = new Hashtable<String, LinkedHashSet<String>>();
- }
-
/**
* Method to obtain all the cache items for a given cache key
*
/**
* Method to obtain all the cache items for a given cache key
*
@@
-59,27
+66,13
@@
public class AppCache
LinkedHashSet<String> foundCache = cacheItems.get(cacheKey);
if (foundCache == null)
{
LinkedHashSet<String> foundCache = cacheItems.get(cacheKey);
if (foundCache == null)
{
- foundCache = new LinkedHashSet<String>();
+ foundCache = new LinkedHashSet<>();
cacheItems.put(cacheKey, foundCache);
}
return foundCache;
}
/**
cacheItems.put(cacheKey, foundCache);
}
return foundCache;
}
/**
- * Returns a singleton instance of AppCache
- *
- * @return
- */
- public static AppCache getInstance()
- {
- if (instance == null)
- {
- instance = new AppCache();
- }
- return instance;
- }
-
- /**
* Method for persisting cache items for a given cache key
*
* @param cacheKey
* Method for persisting cache items for a given cache key
*
* @param cacheKey