JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / io / cache / AppCache.java
index 2a254cc..eaf6ecd 100644 (file)
@@ -21,8 +21,6 @@
 package jalview.io.cache;
 
 import jalview.bin.Cache;
-import jalview.bin.ApplicationSingletonProvider;
-import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 
 import java.util.Hashtable;
 import java.util.LinkedHashSet;
@@ -30,31 +28,26 @@ import java.util.LinkedHashSet;
 /**
  * A singleton class used for querying and persisting cache items.
  * 
- * 
  * @author tcnofoegbu
  *
  */
-public class AppCache implements ApplicationSingletonI
+public class AppCache
 {
-
-  public static AppCache getInstance()
-  {
-    return (AppCache) ApplicationSingletonProvider.getInstance(AppCache.class);
-  }
-
-  private AppCache()
-  {
-    cacheItems = new Hashtable<>();
-  }
-
   public static final String DEFAULT_LIMIT = "99";
 
   public static final String CACHE_DELIMITER = ";";
 
+  private static AppCache instance = null;
+
   private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
 
   private Hashtable<String, LinkedHashSet<String>> cacheItems;
 
+  private AppCache()
+  {
+    cacheItems = new Hashtable<String, LinkedHashSet<String>>();
+  }
+
   /**
    * Method to obtain all the cache items for a given cache key
    * 
@@ -66,13 +59,27 @@ public class AppCache implements ApplicationSingletonI
     LinkedHashSet<String> foundCache = cacheItems.get(cacheKey);
     if (foundCache == null)
     {
-      foundCache = new LinkedHashSet<>();
+      foundCache = new LinkedHashSet<String>();
       cacheItems.put(cacheKey, foundCache);
     }
     return foundCache;
   }
 
   /**
+   * Returns a singleton instance of AppCache
+   * 
+   * @return
+   */
+  public static AppCache getInstance()
+  {
+    if (instance == null)
+    {
+      instance = new AppCache();
+    }
+    return instance;
+  }
+
+  /**
    * Method for persisting cache items for a given cache key
    * 
    * @param cacheKey