From 8088802c218d7eb4a47018b5b3bb70e7463a03b1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 9 Feb 2009 21:47:55 +0000 Subject: From Alan Webb These changes replace all direct references to the AssetCache with IAssetCache. There is no change to functionality. Everything works as before. This is laying the groundwork for making it possible to register alternative asset caching mechanisms without disrupting other parts of OpenSim or their dependencies upon AssetCache functionality. --- OpenSim/Region/Application/OpenSimBase.cs | 68 +++++++++++++++++++------------ 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Application/OpenSimBase.cs') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index d032864..f2ea81d 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -309,37 +309,53 @@ namespace OpenSim /// protected virtual void InitialiseAssetCache() { - // If the assetcache is set to default, then use the grid asset service in grid mode and the local database - // based asset service in standalone mode - - IAssetServer assetServer; - if (m_configSettings.AssetStorage == "grid" - || (m_configSettings.AssetStorage == "default" && false == m_configSettings.Standalone)) - { - assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); - } - else if (m_configSettings.AssetStorage == "cryptogrid") // Decrypt-Only + + IAssetServer assetServer = null; + string mode = m_configSettings.AssetStorage; + + if (m_configSettings.Standalone == false && + m_configSettings.AssetStorage == "default") + mode = "grid"; + + switch (mode) { - assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, + case "grid" : + assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); + break; + case "cryptogrid" : + assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, Environment.CurrentDirectory, true); - } - else if (m_configSettings.AssetStorage == "cryptogrid_eou") // Encrypts All Assets - { - assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, + break; + case "cryptogrid_eou" : + assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, Environment.CurrentDirectory, false); + break; + case "file" : + assetServer = new FileAssetClient(m_networkServersInfo.AssetURL); + break; + default : + if (!ResolveAssetServer(out assetServer)) + { + SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource); + sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); + assetServer = sqlAssetServer; + } + break; } - else if (m_configSettings.AssetStorage == "file") - { - assetServer = new FileAssetClient(m_networkServersInfo.AssetURL); - } - else - { - SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource); - sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); - assetServer = sqlAssetServer; - } - m_assetCache = new AssetCache(assetServer); + m_assetCache = ResolveAssetCache(assetServer); + + } + + private bool ResolveAssetServer(out IAssetServer assetServer) + { + assetServer = null; + return false; + } + + private IAssetCache ResolveAssetCache(IAssetServer assetServer) + { + return new AssetCache(assetServer); } public void ProcessLogin(bool LoginEnabled) -- cgit v1.1