mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Formatting (line-endings) only
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13697 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -71,13 +71,13 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private TenantAdminService tenantAdminService;
|
||||
|
||||
// Internal cache (clusterable)
|
||||
private SimpleCache<String, ConfigData> configDataCache;
|
||||
// Internal cache (clusterable)
|
||||
private SimpleCache<String, ConfigData> configDataCache;
|
||||
|
||||
// used to reset the cache
|
||||
private ThreadLocal<String> tenantDomainThreadLocal = new ThreadLocal<String>();
|
||||
private ThreadLocal<ConfigData> configDataThreadLocal = new ThreadLocal<ConfigData>();
|
||||
|
||||
// used to reset the cache
|
||||
private ThreadLocal<String> tenantDomainThreadLocal = new ThreadLocal<String>();
|
||||
private ThreadLocal<ConfigData> configDataThreadLocal = new ThreadLocal<ConfigData>();
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
@@ -93,11 +93,11 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
this.tenantAdminService = tenantAdminService;
|
||||
}
|
||||
|
||||
public void setConfigDataCache(SimpleCache<String, ConfigData> configDataCache)
|
||||
public void setConfigDataCache(SimpleCache<String, ConfigData> configDataCache)
|
||||
{
|
||||
this.configDataCache = configDataCache;
|
||||
this.configDataCache = configDataCache;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an XMLConfigService using the given config source
|
||||
@@ -112,12 +112,12 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
|
||||
public List<ConfigDeployment> initConfig()
|
||||
{
|
||||
return resetRepoConfig().getConfigDeployments();
|
||||
}
|
||||
|
||||
private ConfigData initRepoConfig(String tenantDomain)
|
||||
{
|
||||
ConfigData configData = null;
|
||||
return resetRepoConfig().getConfigDeployments();
|
||||
}
|
||||
|
||||
private ConfigData initRepoConfig(String tenantDomain)
|
||||
{
|
||||
ConfigData configData = null;
|
||||
|
||||
// can be null e.g. initial login, after fresh bootstrap
|
||||
String currentUser = authenticationComponent.getCurrentUserName();
|
||||
@@ -132,15 +132,15 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
{
|
||||
userTransaction.begin();
|
||||
|
||||
// parse config
|
||||
List<ConfigDeployment> configDeployments = super.initConfig();
|
||||
|
||||
configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData != null)
|
||||
{
|
||||
configData.setConfigDeployments(configDeployments);
|
||||
}
|
||||
|
||||
// parse config
|
||||
List<ConfigDeployment> configDeployments = super.initConfig();
|
||||
|
||||
configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData != null)
|
||||
{
|
||||
configData.setConfigDeployments(configDeployments);
|
||||
}
|
||||
|
||||
userTransaction.commit();
|
||||
|
||||
logger.info("Config initialised");
|
||||
@@ -158,7 +158,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
}
|
||||
}
|
||||
|
||||
return configData;
|
||||
return configData;
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
@@ -167,76 +167,76 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
|
||||
logger.info("Config destroyed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the config service
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
resetRepoConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the config service
|
||||
*/
|
||||
private ConfigData resetRepoConfig()
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Resetting repo config service");
|
||||
}
|
||||
|
||||
String tenantDomain = getTenantDomain();
|
||||
try
|
||||
{
|
||||
destroy();
|
||||
|
||||
// create threadlocal, if needed
|
||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData == null)
|
||||
{
|
||||
configData = new ConfigData();
|
||||
this.tenantDomainThreadLocal.set(tenantDomain);
|
||||
this.configDataThreadLocal.set(configData);
|
||||
}
|
||||
|
||||
configData = initRepoConfig(tenantDomain);
|
||||
|
||||
if (configData == null)
|
||||
{
|
||||
// unexpected
|
||||
throw new AlfrescoRuntimeException("Failed to reset configData " + tenantDomain);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
writeLock.lock();
|
||||
configDataCache.put(tenantDomain, configData);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the config service
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
resetRepoConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the config service
|
||||
*/
|
||||
private ConfigData resetRepoConfig()
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Resetting repo config service");
|
||||
}
|
||||
|
||||
String tenantDomain = getTenantDomain();
|
||||
try
|
||||
{
|
||||
destroy();
|
||||
|
||||
// create threadlocal, if needed
|
||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData == null)
|
||||
{
|
||||
configData = new ConfigData();
|
||||
this.tenantDomainThreadLocal.set(tenantDomain);
|
||||
this.configDataThreadLocal.set(configData);
|
||||
}
|
||||
|
||||
configData = initRepoConfig(tenantDomain);
|
||||
|
||||
if (configData == null)
|
||||
{
|
||||
// unexpected
|
||||
throw new AlfrescoRuntimeException("Failed to reset configData " + tenantDomain);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
writeLock.lock();
|
||||
configDataCache.put(tenantDomain, configData);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
||||
return configData;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
readLock.lock();
|
||||
if (configDataCache.get(tenantDomain) != null)
|
||||
{
|
||||
this.configDataThreadLocal.set(null); // it's in the cache, clear the threadlocal
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return configData;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
readLock.lock();
|
||||
if (configDataCache.get(tenantDomain) != null)
|
||||
{
|
||||
this.configDataThreadLocal.set(null); // it's in the cache, clear the threadlocal
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
@@ -274,230 +274,230 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
||||
destroy(); // will be called in context of tenant
|
||||
}
|
||||
|
||||
// re-entrant (eg. via reset)
|
||||
private ConfigData getConfigData()
|
||||
// re-entrant (eg. via reset)
|
||||
private ConfigData getConfigData()
|
||||
{
|
||||
String tenantDomain = getTenantDomain();
|
||||
|
||||
// check threadlocal first - return if set
|
||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData != null)
|
||||
{
|
||||
return configData; // return local config
|
||||
}
|
||||
|
||||
|
||||
// check threadlocal first - return if set
|
||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||
if (configData != null)
|
||||
{
|
||||
return configData; // return local config
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// check cache second - return if set
|
||||
// check cache second - return if set
|
||||
readLock.lock();
|
||||
configData = configDataCache.get(tenantDomain);
|
||||
|
||||
if (configData != null)
|
||||
{
|
||||
return configData; // return cached config
|
||||
}
|
||||
configData = configDataCache.get(tenantDomain);
|
||||
|
||||
if (configData != null)
|
||||
{
|
||||
return configData; // return cached config
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
|
||||
// reset caches - may have been invalidated (e.g. in a cluster)
|
||||
configData = resetRepoConfig();
|
||||
|
||||
if (configData == null)
|
||||
{
|
||||
// unexpected
|
||||
throw new AlfrescoRuntimeException("Failed to get configData " + tenantDomain);
|
||||
}
|
||||
|
||||
return configData;
|
||||
}
|
||||
|
||||
// reset caches - may have been invalidated (e.g. in a cluster)
|
||||
configData = resetRepoConfig();
|
||||
|
||||
if (configData == null)
|
||||
{
|
||||
// unexpected
|
||||
throw new AlfrescoRuntimeException("Failed to get configData " + tenantDomain);
|
||||
}
|
||||
|
||||
return configData;
|
||||
}
|
||||
|
||||
// get threadlocal
|
||||
private ConfigData getConfigDataLocal(String tenantDomain)
|
||||
// get threadlocal
|
||||
private ConfigData getConfigDataLocal(String tenantDomain)
|
||||
{
|
||||
ConfigData configData = this.configDataThreadLocal.get();
|
||||
|
||||
// check to see if domain switched (eg. during login)
|
||||
if ((configData != null) && (tenantDomain.equals(tenantDomainThreadLocal.get())))
|
||||
{
|
||||
return configData; // return threadlocal, if set
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeConfigData()
|
||||
{
|
||||
ConfigData configData = this.configDataThreadLocal.get();
|
||||
|
||||
// check to see if domain switched (eg. during login)
|
||||
if ((configData != null) && (tenantDomain.equals(tenantDomainThreadLocal.get())))
|
||||
{
|
||||
return configData; // return threadlocal, if set
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeConfigData()
|
||||
{
|
||||
try
|
||||
{
|
||||
writeLock.lock();
|
||||
String tenantDomain = getTenantDomain();
|
||||
if (configDataCache.get(tenantDomain) != null)
|
||||
{
|
||||
configDataCache.remove(tenantDomain);
|
||||
}
|
||||
writeLock.lock();
|
||||
String tenantDomain = getTenantDomain();
|
||||
if (configDataCache.get(tenantDomain) != null)
|
||||
{
|
||||
configDataCache.remove(tenantDomain);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
writeLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigImpl getGlobalConfigImpl()
|
||||
{
|
||||
return getConfigData().getGlobalConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putGlobalConfig(ConfigImpl globalConfig)
|
||||
{
|
||||
getConfigData().setGlobalConfig(globalConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigImpl getGlobalConfigImpl()
|
||||
{
|
||||
return getConfigData().getGlobalConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putGlobalConfig(ConfigImpl globalConfig)
|
||||
{
|
||||
getConfigData().setGlobalConfig(globalConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeGlobalConfig()
|
||||
{
|
||||
removeConfigData();
|
||||
}
|
||||
removeConfigData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Evaluator> getEvaluators()
|
||||
{
|
||||
return getConfigData().getEvaluators();
|
||||
}
|
||||
return getConfigData().getEvaluators();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putEvaluators(Map<String, Evaluator> evaluators)
|
||||
{
|
||||
getConfigData().setEvaluators(evaluators);
|
||||
}
|
||||
|
||||
getConfigData().setEvaluators(evaluators);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeEvaluators()
|
||||
{
|
||||
removeConfigData();
|
||||
}
|
||||
removeConfigData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, List<ConfigSection>> getSectionsByArea()
|
||||
{
|
||||
return getConfigData().getSectionsByArea();
|
||||
}
|
||||
return getConfigData().getSectionsByArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
||||
{
|
||||
getConfigData().setSectionsByArea(sectionsByArea);
|
||||
}
|
||||
|
||||
getConfigData().setSectionsByArea(sectionsByArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeSectionsByArea()
|
||||
{
|
||||
removeConfigData();
|
||||
}
|
||||
removeConfigData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ConfigSection> getSections()
|
||||
{
|
||||
return getConfigData().getSections();
|
||||
}
|
||||
return getConfigData().getSections();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putSections(List<ConfigSection> sections)
|
||||
{
|
||||
getConfigData().setSections(sections);
|
||||
}
|
||||
|
||||
getConfigData().setSections(sections);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeSections()
|
||||
{
|
||||
removeConfigData();
|
||||
}
|
||||
removeConfigData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, ConfigElementReader> getElementReaders()
|
||||
{
|
||||
return getConfigData().getElementReaders();
|
||||
}
|
||||
return getConfigData().getElementReaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||
protected void putElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||
{
|
||||
getConfigData().setElementReaders(elementReaders);
|
||||
}
|
||||
|
||||
getConfigData().setElementReaders(elementReaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeElementReaders()
|
||||
{
|
||||
removeConfigData();
|
||||
}
|
||||
removeConfigData();
|
||||
}
|
||||
|
||||
// local helper - returns tenant domain (or empty string if default non-tenant)
|
||||
private String getTenantDomain()
|
||||
{
|
||||
return tenantAdminService.getCurrentUserDomain();
|
||||
}
|
||||
|
||||
private class ConfigData
|
||||
{
|
||||
private ConfigImpl globalConfig;
|
||||
private Map<String, Evaluator> evaluators;
|
||||
private Map<String, List<ConfigSection>> sectionsByArea;
|
||||
private List<ConfigSection> sections;
|
||||
private Map<String, ConfigElementReader> elementReaders;
|
||||
|
||||
private List<ConfigDeployment> configDeployments;
|
||||
|
||||
public ConfigImpl getGlobalConfig()
|
||||
{
|
||||
return globalConfig;
|
||||
}
|
||||
public void setGlobalConfig(ConfigImpl globalConfig)
|
||||
{
|
||||
this.globalConfig = globalConfig;
|
||||
}
|
||||
public Map<String, Evaluator> getEvaluators()
|
||||
{
|
||||
return evaluators;
|
||||
}
|
||||
public void setEvaluators(Map<String, Evaluator> evaluators)
|
||||
{
|
||||
this.evaluators = evaluators;
|
||||
}
|
||||
public Map<String, List<ConfigSection>> getSectionsByArea()
|
||||
{
|
||||
return sectionsByArea;
|
||||
}
|
||||
public void setSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
||||
{
|
||||
this.sectionsByArea = sectionsByArea;
|
||||
}
|
||||
public List<ConfigSection> getSections()
|
||||
{
|
||||
return sections;
|
||||
}
|
||||
public void setSections(List<ConfigSection> sections)
|
||||
{
|
||||
this.sections = sections;
|
||||
}
|
||||
public Map<String, ConfigElementReader> getElementReaders()
|
||||
{
|
||||
return elementReaders;
|
||||
}
|
||||
public void setElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||
{
|
||||
this.elementReaders = elementReaders;
|
||||
}
|
||||
public List<ConfigDeployment> getConfigDeployments()
|
||||
{
|
||||
return configDeployments;
|
||||
}
|
||||
public void setConfigDeployments(List<ConfigDeployment> configDeployments)
|
||||
{
|
||||
this.configDeployments = configDeployments;
|
||||
}
|
||||
}
|
||||
|
||||
private class ConfigData
|
||||
{
|
||||
private ConfigImpl globalConfig;
|
||||
private Map<String, Evaluator> evaluators;
|
||||
private Map<String, List<ConfigSection>> sectionsByArea;
|
||||
private List<ConfigSection> sections;
|
||||
private Map<String, ConfigElementReader> elementReaders;
|
||||
|
||||
private List<ConfigDeployment> configDeployments;
|
||||
|
||||
public ConfigImpl getGlobalConfig()
|
||||
{
|
||||
return globalConfig;
|
||||
}
|
||||
public void setGlobalConfig(ConfigImpl globalConfig)
|
||||
{
|
||||
this.globalConfig = globalConfig;
|
||||
}
|
||||
public Map<String, Evaluator> getEvaluators()
|
||||
{
|
||||
return evaluators;
|
||||
}
|
||||
public void setEvaluators(Map<String, Evaluator> evaluators)
|
||||
{
|
||||
this.evaluators = evaluators;
|
||||
}
|
||||
public Map<String, List<ConfigSection>> getSectionsByArea()
|
||||
{
|
||||
return sectionsByArea;
|
||||
}
|
||||
public void setSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
||||
{
|
||||
this.sectionsByArea = sectionsByArea;
|
||||
}
|
||||
public List<ConfigSection> getSections()
|
||||
{
|
||||
return sections;
|
||||
}
|
||||
public void setSections(List<ConfigSection> sections)
|
||||
{
|
||||
this.sections = sections;
|
||||
}
|
||||
public Map<String, ConfigElementReader> getElementReaders()
|
||||
{
|
||||
return elementReaders;
|
||||
}
|
||||
public void setElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||
{
|
||||
this.elementReaders = elementReaders;
|
||||
}
|
||||
public List<ConfigDeployment> getConfigDeployments()
|
||||
{
|
||||
return configDeployments;
|
||||
}
|
||||
public void setConfigDeployments(List<ConfigDeployment> configDeployments)
|
||||
{
|
||||
this.configDeployments = configDeployments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user