Merged BRANCHES/DEV/THOR1 to HEAD:

=> CLOUD-1347 / CLOUD-1348 
   30569: THOR-156
   30776: THOR-172


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46551 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2013-02-13 09:42:13 +00:00
parent 1be15184cb
commit 1616d63a25
9 changed files with 127 additions and 299 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -18,10 +18,13 @@
*/
package org.alfresco.repo.transaction;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.util.GUID;
/**
@@ -45,7 +48,8 @@ public class TransactionAwareSingleton<T> extends TransactionListenerAdapter
private final String txnKey;
private final ReadLock singletonReadLock;
private final WriteLock singletonWriteLock;
private Object singletonValue;
private Map<String, Object> tenantSingletonValue = new HashMap<String, Object>(1); // tenant-aware
public TransactionAwareSingleton()
{
@@ -61,7 +65,7 @@ public class TransactionAwareSingleton<T> extends TransactionListenerAdapter
singletonWriteLock.lock();
try
{
singletonValue = value;
tenantSingletonValue.put(TenantUtil.getCurrentDomain(), value);
}
finally
{
@@ -75,7 +79,7 @@ public class TransactionAwareSingleton<T> extends TransactionListenerAdapter
singletonReadLock.lock();
try
{
return singletonValue;
return tenantSingletonValue.get(TenantUtil.getCurrentDomain());
}
finally
{
@@ -144,4 +148,4 @@ public class TransactionAwareSingleton<T> extends TransactionListenerAdapter
{
public Object newValue;
}
}
}