*/
package jalview.ws;
+import jalview.bin.Instance;
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
{
+
+ /**
+ * Returns a new SequenceFetcher singleton, or a mock object if one has been
+ * set. Used by CrossRef and java.gui.SequenceFetcher.
+ *
+ * @return
+ */
+ public static SequenceFetcher getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.sequenceFetcher == null
+ ? j.sequenceFetcher = new SequenceFetcher()
+ : j.sequenceFetcher);
+ }
+
/**
- * 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.
+ *
+ * This public constructor is only is for use by testng to anonymously
+ * subclass SequenceFetcher.
+ *
*
*/
public SequenceFetcher()
addAllDatabases();
}
+ /**
+ * 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)
+ {
+ Instance.getInstance().sequenceFetcher = sf;
+ }
+
public void addAllDatabases()
{
addDBRefSourceImpl(EnsemblGene.class); // includes EnsemblGenomes.class