From 0eb0ed1646eeef1f532c11e057bd1003f381bd9c Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Fri, 20 Mar 2009 10:06:30 +0000 Subject: [PATCH] Formatting (line-endings) only git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13697 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/config/xml/RepoXMLConfigService.java | 498 +++++++++--------- 1 file changed, 249 insertions(+), 249 deletions(-) diff --git a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java index aec292640f..bb8edb4b26 100644 --- a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java +++ b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java @@ -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 configDataCache; + // Internal cache (clusterable) + private SimpleCache configDataCache; - // used to reset the cache - private ThreadLocal tenantDomainThreadLocal = new ThreadLocal(); - private ThreadLocal configDataThreadLocal = new ThreadLocal(); - + // used to reset the cache + private ThreadLocal tenantDomainThreadLocal = new ThreadLocal(); + private ThreadLocal configDataThreadLocal = new ThreadLocal(); + 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 configDataCache) + public void setConfigDataCache(SimpleCache 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 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 configDeployments = super.initConfig(); - - configData = getConfigDataLocal(tenantDomain); - if (configData != null) - { - configData.setConfigDeployments(configDeployments); - } - + // parse config + List 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 getEvaluators() { - return getConfigData().getEvaluators(); - } + return getConfigData().getEvaluators(); + } @Override protected void putEvaluators(Map evaluators) { - getConfigData().setEvaluators(evaluators); - } - + getConfigData().setEvaluators(evaluators); + } + @Override protected void removeEvaluators() { - removeConfigData(); - } + removeConfigData(); + } @Override protected Map> getSectionsByArea() { - return getConfigData().getSectionsByArea(); - } + return getConfigData().getSectionsByArea(); + } @Override protected void putSectionsByArea(Map> sectionsByArea) { - getConfigData().setSectionsByArea(sectionsByArea); - } - + getConfigData().setSectionsByArea(sectionsByArea); + } + @Override protected void removeSectionsByArea() { - removeConfigData(); - } + removeConfigData(); + } @Override protected List getSections() { - return getConfigData().getSections(); - } + return getConfigData().getSections(); + } @Override protected void putSections(List sections) { - getConfigData().setSections(sections); - } - + getConfigData().setSections(sections); + } + @Override protected void removeSections() { - removeConfigData(); - } + removeConfigData(); + } @Override protected Map getElementReaders() { - return getConfigData().getElementReaders(); - } + return getConfigData().getElementReaders(); + } @Override - protected void putElementReaders(Map elementReaders) + protected void putElementReaders(Map 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 evaluators; - private Map> sectionsByArea; - private List sections; - private Map elementReaders; - - private List configDeployments; - - public ConfigImpl getGlobalConfig() - { - return globalConfig; - } - public void setGlobalConfig(ConfigImpl globalConfig) - { - this.globalConfig = globalConfig; - } - public Map getEvaluators() - { - return evaluators; - } - public void setEvaluators(Map evaluators) - { - this.evaluators = evaluators; - } - public Map> getSectionsByArea() - { - return sectionsByArea; - } - public void setSectionsByArea(Map> sectionsByArea) - { - this.sectionsByArea = sectionsByArea; - } - public List getSections() - { - return sections; - } - public void setSections(List sections) - { - this.sections = sections; - } - public Map getElementReaders() - { - return elementReaders; - } - public void setElementReaders(Map elementReaders) - { - this.elementReaders = elementReaders; - } - public List getConfigDeployments() - { - return configDeployments; - } - public void setConfigDeployments(List configDeployments) - { - this.configDeployments = configDeployments; - } - } + + private class ConfigData + { + private ConfigImpl globalConfig; + private Map evaluators; + private Map> sectionsByArea; + private List sections; + private Map elementReaders; + + private List configDeployments; + + public ConfigImpl getGlobalConfig() + { + return globalConfig; + } + public void setGlobalConfig(ConfigImpl globalConfig) + { + this.globalConfig = globalConfig; + } + public Map getEvaluators() + { + return evaluators; + } + public void setEvaluators(Map evaluators) + { + this.evaluators = evaluators; + } + public Map> getSectionsByArea() + { + return sectionsByArea; + } + public void setSectionsByArea(Map> sectionsByArea) + { + this.sectionsByArea = sectionsByArea; + } + public List getSections() + { + return sections; + } + public void setSections(List sections) + { + this.sections = sections; + } + public Map getElementReaders() + { + return elementReaders; + } + public void setElementReaders(Map elementReaders) + { + this.elementReaders = elementReaders; + } + public List getConfigDeployments() + { + return configDeployments; + } + public void setConfigDeployments(List configDeployments) + { + this.configDeployments = configDeployments; + } + } }