import jalview.datamodel.SequenceI;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
+import jalview.ws.SequenceFetcher;
import jalview.ws.SequenceFetcherFactory;
import jalview.ws.seqfetcher.ASequenceFetcher;
private void retrieveCrossRef(List<DBRefEntry> sourceRefs, SequenceI seq,
List<DBRefEntry> xrfs, boolean fromDna, AlignedCodonFrame cf)
{
- ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher();
SequenceI[] retrieved = null;
SequenceI dss = seq.getDatasetSequence() == null ? seq
: seq.getDatasetSequence();
}
try
{
- retrieved = sftch.getSequences(sourceRefs, !fromDna);
+ retrieved = SequenceFetcher.getInstance().getSequences(sourceRefs, !fromDna);
} catch (Exception e)
{
System.err.println(
*/
package jalview.ws;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.ext.ensembl.EnsemblGene;
import jalview.ws.dbsources.EmblCdsSource;
import jalview.ws.dbsources.EmblSource;
* This implements the run-time discovery of sequence database clients.
*
*/
-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;
+
+ /**
+ * 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 setMockFetcher(SequenceFetcher sf)
+ {
+ mockFetcher = sf;
+ }
+
+ /**
+ * 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);
+ }
+
/**
* Thread safe construction of database proxies TODO: extend to a configurable
* database plugin mechanism where classes are instantiated by reflection and
public class SequenceFetcherFactory
{
-
- private static SequenceFetcher instance;
-
- /**
- * Returns a new SequenceFetcher object, or a mock object if one has been set
- *
- * @return
- */
- public static ASequenceFetcher getSequenceFetcher()
- {
- return instance == null ? new SequenceFetcher() : instance;
- }
-
- /**
- * 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 = sf;
- }
+ // BH the two methods in this class merged into SequenceFetcher
}
+//public class SequenceFetcherFactory
+//{
+//
+// private static SequenceFetcher instance;
+//
+// /**
+// * Returns a new SequenceFetcher object, or a mock object if one has been set
+// *
+// * @return
+// */
+// public static ASequenceFetcher getSequenceFetcher()
+// {
+// return instance == null ? new SequenceFetcher() : instance;
+// }
+//
+// /**
+// * 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 = sf;
+// }
+//}
return new SequenceI[] { pep1, pep2 };
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+ SequenceFetcher.setMockFetcher(mockFetcher);
/*
* find UNIPROT xrefs for nucleotide sequence
@AfterClass(alwaysRun = true)
public void tearDown()
{
- SequenceFetcherFactory.setSequenceFetcher(null);
+ SequenceFetcher.setMockFetcher(null);
}
/**
return new SequenceI[] { pep1, pep2 };
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+ SequenceFetcher.setMockFetcher(mockFetcher);
/*
* find UNIPROT xrefs for gene and transcripts
}
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+ SequenceFetcher.setMockFetcher(mockFetcher);
/*
* find EMBL xrefs for Uniprot seqs and verify that