do not synchronize over all configuration entry stores

This commit is contained in:
Sebastian Sdorra
2013-06-20 18:36:51 +02:00
parent a504ddf543
commit 76217dc0ef
2 changed files with 16 additions and 13 deletions

View File

@@ -84,9 +84,6 @@ public class JAXBConfigurationEntryStore<V>
implements ConfigurationEntryStore<V>
{
/** Field description */
private static final Object LOCK = new Object();
/** Field description */
private static final String TAG_CONFIGURATION = "configuration";
@@ -116,11 +113,11 @@ public class JAXBConfigurationEntryStore<V>
* @param file
* @param type
*/
JAXBConfigurationEntryStore(KeyGenerator keyGenerator, File file,
JAXBConfigurationEntryStore(File file, KeyGenerator keyGenerator,
Class<V> type)
{
this.keyGenerator = keyGenerator;
this.file = file;
this.keyGenerator = keyGenerator;
this.type = type;
try
@@ -149,7 +146,7 @@ public class JAXBConfigurationEntryStore<V>
{
logger.debug("clear configuration store");
synchronized (LOCK)
synchronized (file)
{
entries.clear();
store();
@@ -186,7 +183,7 @@ public class JAXBConfigurationEntryStore<V>
{
logger.debug("put item {} to configuration store", id);
synchronized (LOCK)
synchronized (file)
{
entries.put(id, item);
store();
@@ -204,7 +201,7 @@ public class JAXBConfigurationEntryStore<V>
{
logger.debug("remove item {} from configuration store", id);
synchronized (LOCK)
synchronized (file)
{
entries.remove(id);
store();
@@ -429,15 +426,15 @@ public class JAXBConfigurationEntryStore<V>
//~--- fields ---------------------------------------------------------------
/** Field description */
private final File file;
/** Field description */
private JAXBContext context;
/** Field description */
private Map<String, V> entries = Maps.newHashMap();
/** Field description */
private File file;
/** Field description */
private KeyGenerator keyGenerator;

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.store;
//~--- non-JDK imports --------------------------------------------------------
@@ -100,8 +101,13 @@ public class JAXBConfigurationEntryStoreFactory
logger.debug("create new configuration store for type {} with name {}",
type, name);
return new JAXBConfigurationEntryStore<T>(keyGenerator,
new File(directory, name.concat(StoreConstants.FILE_EXTENSION)), type);
//J-
return new JAXBConfigurationEntryStore<T>(
new File(directory,name.concat(StoreConstants.FILE_EXTENSION)),
keyGenerator,
type
);
//J+
}
//~--- fields ---------------------------------------------------------------