*/
package jalview.ws;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.datamodel.DBRefSource;
import jalview.ext.ensembl.EnsemblGene;
import jalview.ws.dbsources.Uniprot;
import java.util.List;
/**
- * This implements the run-time discovery of sequence database clients.
+ * Thread safe construction of database proxies. This implements the run-time
+ * discovery of sequence database clients.
*
+ * TODO: extend to a configurable database plugin mechanism where classes are
+ * instantiated by reflection and queried for their DbRefSource and version
+ * association.
*/
-public class SequenceFetcher extends ASequenceFetcher
+public class SequenceFetcher extends ASequenceFetcher implements ApplicationSingletonI
{
+ /*
+ * set a mock fetcher here for testing only - reset to null afterwards
+ */
+ private static SequenceFetcher mockFetcher;
+
/**
- * Thread safe construction of database proxies TODO: extend to a configurable
- * database plugin mechanism where classes are instantiated by reflection and
- * queried for their DbRefSource and version association.
+ * Returns a new SequenceFetcher singleton, or a mock object if one has been
+ * set.
+ *
+ * @return
+ */
+ public static SequenceFetcher getInstance()
+ {
+ return mockFetcher != null ? mockFetcher
+ : (SequenceFetcher) ApplicationSingletonProvider
+ .getInstance(SequenceFetcher.class);
+ }
+
+ /**
+ * Set the instance object to use (intended for unit testing with mock
+ * objects).
+ *
+ * Be sure to reset to null in the tearDown method of any tests!
+ *
+ * @param sf
+ */
+ public static void setSequenceFetcher(SequenceFetcher sf)
+ {
+ mockFetcher = sf;
+ }
+
+ /**
+ *
+ * This public constructor is only is for use by testng to anonymously
+ * subclass SequenceFetcher.
+ *
*
*/
public SequenceFetcher()