JAL-972 - refactored local source builder to registry implementation and made Cache...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Feb 2012 16:03:02 +0000 (16:03 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Feb 2012 16:03:02 +0000 (16:03 +0000)
src/jalview/bin/Cache.java

index 15e368d..d810ee7 100755 (executable)
@@ -17,6 +17,9 @@
  */
 package jalview.bin;
 
+import jalview.ws.dbsources.das.api.DasSourceRegistryI;
+import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
+
 import java.awt.Color;
 import java.io.*;
 import java.text.DateFormat;
@@ -579,47 +582,6 @@ public class Cache
   }
 
   /**
-   * generate Das1Sources from the local das source list
-   * 
-   * @return Vector of Das1Sources
-   */
-  public static Vector getLocalDasSources()
-  {
-    Vector localSources = new Vector();
-    String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
-    if (local != null)
-    {
-      StringTokenizer st = new StringTokenizer(local, "\t");
-      while (st.hasMoreTokens())
-      {
-        String token = st.nextToken();
-        int bar = token.indexOf("|");
-        // TODO: replace with JDAS source object.
-        Das1Source source = new Das1Source();
-        source.setUrl(token.substring(bar + 1));
-        if (source.getUrl().startsWith("sequence:"))
-        {
-          source.setUrl(source.getUrl().substring(9));
-          // this source also serves sequences as well as features
-          source.setCapabilities(new String[]
-          { "sequence", "features" });
-        }
-        else
-        {
-          // default is that all user added sources serve features
-          source.setCapabilities(new String[]
-          { "features" });
-        }
-
-        source.setNickname(token.substring(0, bar));
-
-        localSources.addElement(source);
-      }
-    }
-    return localSources;
-  }
-
-  /**
    * GA tracker object - actually JGoogleAnalyticsTracker null if tracking not
    * enabled.
    */
@@ -824,4 +786,18 @@ public class Cache
     }
     return null;
   }
+
+  private static DasSourceRegistryI sourceRegistry=null;
+  /**
+   * initialise and ..
+   * @return instance of the das source registry
+   */
+  public static DasSourceRegistryI getDasSourceRegistry()
+  {
+    if (sourceRegistry==null)
+    {
+      sourceRegistry = new DasSourceRegistry();
+    }
+    return sourceRegistry;
+  }
 }