X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fbin%2FCache.java;h=c95b507c2cf150c0d39282906d09d22ebc89bb74;hb=d82d17a7ba88f90e6b8b1b591245a7ee70b3975c;hp=d7542b826a2c401caa47398200e4e09777332b11;hpb=208f2c3de82e3327c4f930ab7d04f5b812ccd277;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index d7542b8..c95b507 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -20,6 +20,7 @@ */ package jalview.bin; +import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.datamodel.PDBEntry; import jalview.gui.UserDefinedColours; import jalview.schemes.ColourSchemeLoader; @@ -207,10 +208,13 @@ import org.apache.log4j.SimpleLayout; * @author $author$ * @version $Revision$ */ -public class Cache +public class Cache implements ApplicationSingletonI { - static Cache instance; + private Cache() + { + // private singleton + } /** * In Java, this will be a static field instance, which will be @@ -219,10 +223,9 @@ public class Cache * * @return */ - public static Cache getInstance() + private static Cache getInstance() { - Jalview j = Jalview.getInstance(); - return (j.cache == null ? j.cache = new Cache() : j.cache); + return (Cache) ApplicationSingletonProvider.getInstance(Cache.class); } /** @@ -280,11 +283,6 @@ public class Cache */ public static Logger log; - private Cache() - { - // inaccessible - } - /** Jalview Properties */ // BH 2019.05.08 was static @SuppressWarnings("serial") @@ -299,8 +297,7 @@ public class Cache }; /** Default file is ~/.jalview_properties */ - // BH 2019.05.07 note: Instances of Jalview will share this file. - static String propertiesFile; + private String propertiesFile; /** * flag to possibly allow properties to be written to a property file @@ -626,18 +623,7 @@ public class Cache */ public static String getProperty(String key) { - return getInstance().getPropertyImpl(key); - } - - private String getPropertyImpl(String key) - { - String prop = applicationProperties.getProperty(key); - if (prop == null && Platform.isJS()) - { - prop = applicationProperties.getProperty(Platform.getUniqueAppletID() - + "_" + JS_PROPERTY_PREFIX + key); - } - return prop; + return getInstance().applicationProperties.getProperty(key); } /** @@ -710,7 +696,7 @@ public class Cache try { oldValue = applicationProperties.setProperty(key, obj); - if (andSave && !propsAreReadOnly) + if (andSave && !propsAreReadOnly && propertiesFile != null) { FileOutputStream out = new FileOutputStream(propertiesFile); applicationProperties.store(out, "---JalviewX Properties File---");