X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fcache%2FAppCache.java;fp=src%2Fjalview%2Fio%2Fcache%2FAppCache.java;h=2a254ccc2dcbc7b840b51a8ac9ef978cb11df6b2;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=eaf6ecd65b25423572a18958c5287a29ad1de902;hpb=d4ec118f86b5c9dee801e743c46aaacc7bb521d1;p=jalview.git diff --git a/src/jalview/io/cache/AppCache.java b/src/jalview/io/cache/AppCache.java index eaf6ecd..2a254cc 100644 --- a/src/jalview/io/cache/AppCache.java +++ b/src/jalview/io/cache/AppCache.java @@ -21,6 +21,8 @@ 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; @@ -28,26 +30,31 @@ import java.util.LinkedHashSet; /** * A singleton class used for querying and persisting cache items. * + * * @author tcnofoegbu * */ -public class AppCache +public class AppCache implements ApplicationSingletonI { + + 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> cacheItems; - private AppCache() - { - cacheItems = new Hashtable>(); - } - /** * Method to obtain all the cache items for a given cache key * @@ -59,27 +66,13 @@ public class AppCache LinkedHashSet foundCache = cacheItems.get(cacheKey); if (foundCache == null) { - foundCache = new LinkedHashSet(); + foundCache = new LinkedHashSet<>(); 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