public class SequenceOntologyFactory
{
- private SequenceOntologyFactory()
+ public static synchronized SequenceOntologyI getSequenceOntology()
{
- // noninstantiable
+ SequenceOntologyFactory j = getInstance();
+ return (j.sequenceOntology == null
+ ? j.sequenceOntology = new SequenceOntologyLite()
+ : j.sequenceOntology);
}
- // private static SequenceOntologyI instance; // moved to Jalview.instance for
- // JavaScript
- public static synchronized SequenceOntologyI getInstance()
+ /**
+ * For testng only
+ *
+ * @param so
+ */
+ public static void setInstance(SequenceOntologyI so)
{
- Instance j = Instance.getInstance();
- if (j.sequenceOntology == null)
- {
- j.sequenceOntology = new SequenceOntologyLite();
- }
- return j.sequenceOntology;
+ getInstance().sequenceOntology = so;
}
- public static void setInstance(SequenceOntologyI so)
+ private SequenceOntologyI sequenceOntology;
+
+ private SequenceOntologyFactory()
{
- Instance.getInstance().sequenceOntology = so;
+ // private singleton
}
+
+ private static synchronized SequenceOntologyFactory getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.sequenceOntologyFactory == null
+ ? j.sequenceOntologyFactory = new SequenceOntologyFactory()
+ : j.sequenceOntologyFactory);
+ }
+
}