|
From: <ek...@ba...> - 2003-04-16 23:49:28
|
Correction: Please disregard the
if (saved) {
clearCache( )
}
logic. This is inappropriate to empty the entire HashMap just because one
set of Config entries were updated.
Erik
---------------------- Forwarded by Erik Klein/NY/DOMESTIC/BNY on 04/16/2003 07:48 PM ---------------------------
To: bab...@li...
cc:
Subject: Synchronizing methods in com.babeldoc.core.config.ConfigService
I am proposing adding synchronized blocks to certain methods in this class
to prevent multithreading problems from occurring when reading and writing
configuration information to and from the cache.
Lines preceded by ** are modified or added.
Here are the proposals:
public IConfig getConfig(String name, Locale locale) {
String key = name + locale.toString();
IConfig config = (IConfig) configs.get(key);
if (config == null) {
** synchronized {
config = configService.getConfig(name, locale);
configs.put(key, config);
** }
}
return config;
}
Same modification in public IConfig getConfig(String name).
Additionally, the following changes would be made to saveConfig to keep
the same information from being written by two different threads (with
potentially different data) and to clear the Cache when the save is
complete:
** public synchronized boolean saveConfig(String name, IConfig config) {
//System.out.println("Getting config: "+name);
if (config != null) {
//System.out.println("Config: "+name+" not found, loading.");
** boolean saved = configService.saveConfig(name, config);
** if (saved) {
** clearCache();
** }
** return saved;
} else {
return false;
}
}
Please let me know if you approve of this.
________________________________________________________________________
The information in this e-mail, and any attachment therein, is confidential and for use by the addressee only. If you are not the intended recipient, please return the e-mail to the sender and delete it from your computer. Although The Bank of New York attempts to sweep e-mail and attachments for viruses, it does not guarantee that either are virus-free and accepts no liability for any damage sustained as a result of viruses. |