JAL-3253 jalview.bin.Instance streamlining
[jalview.git] / src / jalview / io / gff / SequenceOntologyFactory.java
index 97ebf2a..258b16a 100644 (file)
@@ -33,25 +33,37 @@ import jalview.bin.Instance;
 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);
+  }
+
 }