diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 1c8f9d6a6d..76c6045bc7 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -48,8 +48,67 @@ namespace OpenSim.Framework.Communications.Cache
/// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and
/// AssetNotFound(), which means they do share the same asset and texture caches.I agr
- public class AssetCache : IAssetCache, IAssetReceiver
+ public class AssetCache : IAssetCache
{
+
+ #region IPlugin
+
+ ///
+ /// The methods and properties in this section are needed to
+ /// support the IPlugin interface. They cann all be overridden
+ /// as needed by a derived class.
+ ///
+
+ public virtual string Name
+ {
+ get { return "OpenSim.Framework.Communications.Cache.AssetCache"; }
+ }
+
+ public virtual string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public virtual void Initialise()
+ {
+ m_log.Debug("[ASSET CACHE]: Asset cache null initialisation");
+ }
+
+ public virtual void Initialise(IAssetServer assetServer)
+ {
+ m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation");
+ m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version);
+
+ Initialize();
+
+ m_assetServer = assetServer;
+ m_assetServer.SetReceiver(this);
+
+ Thread assetCacheThread = new Thread(RunAssetManager);
+ assetCacheThread.Name = "AssetCacheThread";
+ assetCacheThread.IsBackground = true;
+ assetCacheThread.Start();
+ ThreadTracker.Add(assetCacheThread);
+
+ }
+
+ public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer)
+ {
+ m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation");
+ Initialise(assetServer);
+ }
+
+ public AssetCache()
+ {
+ m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
+ }
+
+ public void Dispose()
+ {
+ }
+
+ #endregion
+
protected ICache m_memcache = new SimpleMemoryCache();
private static readonly ILog m_log
@@ -83,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache
///
/// The 'server' from which assets can be requested and to which assets are persisted.
///
- private readonly IAssetServer m_assetServer;
+ private IAssetServer m_assetServer;
public IAssetServer AssetServer
{
@@ -132,17 +191,8 @@ namespace OpenSim.Framework.Communications.Cache
///
public AssetCache(IAssetServer assetServer)
{
- m_log.Info("[ASSET CACHE]: Creating Asset cache");
- Initialize();
-
- m_assetServer = assetServer;
- m_assetServer.SetReceiver(this);
-
- Thread assetCacheThread = new Thread(RunAssetManager);
- assetCacheThread.Name = "AssetCacheThread";
- assetCacheThread.IsBackground = true;
- assetCacheThread.Start();
- ThreadTracker.Add(assetCacheThread);
+ m_log.Info("[ASSET CACHE]: Asset cache direct constructor");
+ Initialise(assetServer);
}
///
@@ -342,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache
}
// See IAssetReceiver
- public void AssetReceived(AssetBase asset, bool IsTexture)
+ public virtual void AssetReceived(AssetBase asset, bool IsTexture)
{
AssetInfo assetInf = new AssetInfo(asset);
@@ -393,7 +443,7 @@ namespace OpenSim.Framework.Communications.Cache
}
// See IAssetReceiver
- public void AssetNotFound(UUID assetID, bool IsTexture)
+ public virtual void AssetNotFound(UUID assetID, bool IsTexture)
{
// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID);
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 5c902ec235..7bb2ab9503 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -46,6 +46,61 @@ namespace OpenSim.Framework.Communications.Cache
protected Thread m_localAssetServerThread;
protected IAssetDataPlugin m_assetProvider;
+ #region IPlugin
+
+ ///
+ /// The methods and properties in this region are needed to implement
+ /// the IPlugin interface and its local extensions.
+ /// These can all be overridden as appropriate by a derived class.
+ /// These methods are only applicable when a class is loaded by the
+ /// IPlugin mechanism.
+ ///
+ /// Note that in the case of AssetServerBase, all initialization is
+ /// performed by the default constructor, so nothing additional is
+ /// required here. A derived class may wish to do more.
+ ///
+
+ public virtual string Name
+ {
+ // get { return "OpenSim.Framework.Communications.Cache.AssetServerBase"; }
+ get { return "AssetServerBase"; }
+ }
+
+ public virtual string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public virtual void Initialise()
+ {
+ m_log.Debug("[ASSET SERVER]: IPlugin null initialization");
+ }
+
+ public virtual void Initialise(ConfigSettings settings)
+ {
+ m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(1)");
+ m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
+ }
+
+ public virtual void Initialise(ConfigSettings settings, string p_url)
+ {
+ m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(2)");
+ m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
+ }
+
+ public virtual void Initialise(ConfigSettings settings, string p_url, string p_dir, bool p_t)
+ {
+ m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(3)");
+ m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
+ }
+
+ public virtual void Dispose()
+ {
+ m_log.Debug("[ASSET SERVER]: dispose");
+ }
+
+ #endregion
+
public IAssetDataPlugin AssetProviderPlugin
{
get { return m_assetProvider; }
diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
index 55db28967c..0f4e8acab8 100644
--- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
@@ -44,9 +44,37 @@ namespace OpenSim.Framework.Communications.Cache
{
public class CryptoGridAssetClient : AssetServerBase
{
+
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string _assetServerUrl;
+ private bool m_encryptOnUpload;
+ private RjinKeyfile m_encryptKey;
+ private readonly Dictionary m_keyfiles = new Dictionary();
+
+ #region IPlugin
+
+ public override string Name
+ {
+ get { return "Crypto"; }
+ }
+
+ public override string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public override void Initialise(ConfigSettings p_set, string p_url, string p_dir, bool p_t)
+ {
+ m_log.Debug("[CRYPTOGRID] Plugin configured initialisation");
+ Initialise(p_url, p_dir, p_t);
+ }
+
+ #endregion
+
#region Keyfile Classes
[Serializable]
- private class RjinKeyfile
+ public class RjinKeyfile
{
public string Secret;
public string AlsoKnownAs;
@@ -94,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
/// this may not be the most efficient way of handling encryption, so - as
/// soon as you feel comfortable with it - you may want to redesign this class.
///
- private class UtilRijndael
+ public class UtilRijndael
{
///
/// Encrypts specified plaintext using Rijndael symmetric key algorithm
@@ -332,15 +360,19 @@ namespace OpenSim.Framework.Communications.Cache
}
#endregion
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private readonly string _assetServerUrl;
- private readonly bool m_encryptOnUpload;
- private readonly RjinKeyfile m_encryptKey;
- private readonly Dictionary m_keyfiles = new Dictionary();
+ public CryptoGridAssetClient() {}
public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly)
{
+ m_log.Debug("[CRYPTOGRID] Direct constructor");
+ Initialise(serverUrl, keydir, decOnly);
+ }
+
+ public void Initialise(string serverUrl, string keydir, bool decOnly)
+ {
+
+ m_log.Debug("[CRYPTOGRID] Common constructor");
+
_assetServerUrl = serverUrl;
string[] keys = Directory.GetFiles(keydir, "*.deckey");
diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
index 9a60b53a9c..e6574a1804 100644
--- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
@@ -26,16 +26,49 @@
*/
using System.IO;
+using System.Reflection;
+using log4net;
using System.Xml.Serialization;
namespace OpenSim.Framework.Communications.Cache
{
public class FileAssetClient : AssetServerBase
{
- private readonly string m_dir;
+
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ #region IPlugin
+
+ public override string Name
+ {
+ get { return "File"; }
+ }
+
+ public override string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public override void Initialise(ConfigSettings p_set, string p_url)
+ {
+ m_log.Debug("[FILEASSET] Plugin configured initialisation");
+ Initialise(p_url);
+ }
+
+ #endregion
+
+ private string m_dir;
private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase));
- public FileAssetClient(string dir)
+ public FileAssetClient() {}
+
+ public FileAssetClient(string p_url)
+ {
+ m_log.Debug("[FILEASSET] Direct constructor");
+ Initialise(p_url);
+ }
+
+ public void Initialise(string dir)
{
if (!Directory.Exists(dir))
{
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index 1cc9833cce..6522ad00f7 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -36,11 +36,40 @@ namespace OpenSim.Framework.Communications.Cache
{
public class GridAssetClient : AssetServerBase
{
+
+ #region IPlugin
+
+ public override string Name
+ {
+ get { return "Grid"; }
+ }
+
+ public override string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public override void Initialise(ConfigSettings p_set, string p_url)
+ {
+ m_log.Debug("[GRIDASSET] Plugin configured initialisation");
+ Initialise(p_url);
+ }
+
+ #endregion
+
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string _assetServerUrl;
- public GridAssetClient(string serverUrl)
+ public GridAssetClient() {}
+
+ public GridAssetClient(string p_url)
+ {
+ m_log.Debug("[GRIDASSET] Direct constructor");
+ Initialise(p_url);
+ }
+
+ public void Initialise(string serverUrl)
{
_assetServerUrl = serverUrl;
}
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 6266bf00fb..52742884a8 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -34,9 +34,38 @@ namespace OpenSim.Framework.Communications.Cache
{
public class SQLAssetServer : AssetServerBase
{
+
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ #region IPlugin
+
+ public override string Name
+ {
+ get { return "SQL"; }
+ }
+
+ public override string Version
+ {
+ get { return "1.0"; }
+ }
+
+ public override void Initialise(ConfigSettings p_set)
+ {
+ m_log.Debug("[SQLASSET] Plugin configured initialisation");
+ Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource);
+ }
+
+ #endregion
+
+ public SQLAssetServer() {}
+
public SQLAssetServer(string pluginName, string connect)
+ {
+ m_log.Debug("[SQLASSET] Direct constructor");
+ Initialise(pluginName, connect);
+ }
+
+ public void Initialise(string pluginName, string connect)
{
AddPlugin(pluginName, connect);
}
diff --git a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml
new file mode 100644
index 0000000000..61a9f0f47a
--- /dev/null
+++ b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs
index 3d66311168..5f5e16f4e2 100644
--- a/OpenSim/Framework/ConfigSettings.cs
+++ b/OpenSim/Framework/ConfigSettings.cs
@@ -156,6 +156,14 @@ namespace OpenSim.Framework
set { m_assetStorage = value; }
}
+ private string m_assetCache;
+
+ public string AssetCache
+ {
+ get { return m_assetCache; }
+ set { m_assetCache = value; }
+ }
+
protected string m_storageConnectionString;
public string StorageConnectionString
diff --git a/OpenSim/Framework/IAssetCache.cs b/OpenSim/Framework/IAssetCache.cs
index b90dffcf32..22f5755dfa 100644
--- a/OpenSim/Framework/IAssetCache.cs
+++ b/OpenSim/Framework/IAssetCache.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Framework
public delegate void AssetRequestCallback(UUID assetId, AssetBase asset);
- public interface IAssetCache : IAssetReceiver
+ public interface IAssetCache : IAssetReceiver, IPlugin
{
IAssetServer AssetServer { get; }
@@ -47,5 +47,25 @@ namespace OpenSim.Framework
void ExpireAsset(UUID assetID);
void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest);
+ void Initialise(ConfigSettings cs, IAssetServer server);
+
}
+
+ public class AssetCachePluginInitialiser : PluginInitialiserBase
+ {
+ private ConfigSettings config;
+ private IAssetServer server;
+
+ public AssetCachePluginInitialiser (ConfigSettings p_sv, IAssetServer p_as)
+ {
+ config = p_sv;
+ server = p_as;
+ }
+ public override void Initialise (IPlugin plugin)
+ {
+ IAssetCache p = plugin as IAssetCache;
+ p.Initialise (config, server);
+ }
+ }
+
}
diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs
index d2f5ce7d76..0d9afe96be 100644
--- a/OpenSim/Framework/IAssetServer.cs
+++ b/OpenSim/Framework/IAssetServer.cs
@@ -32,8 +32,11 @@ namespace OpenSim.Framework
///
/// Description of IAssetServer.
///
- public interface IAssetServer
+ public interface IAssetServer : IPlugin
{
+ void Initialise(ConfigSettings settings);
+ void Initialise(ConfigSettings settings, string url, string dir, bool test);
+ void Initialise(ConfigSettings settings, string url);
void SetReceiver(IAssetReceiver receiver);
void RequestAsset(UUID assetID, bool isTexture);
void StoreAsset(AssetBase asset);
@@ -62,8 +65,62 @@ namespace OpenSim.Framework
void AssetNotFound(UUID assetID, bool IsTexture);
}
+ public class AssetServerClientPluginInitialiser : PluginInitialiserBase
+ {
+ private ConfigSettings config;
+
+ public AssetServerClientPluginInitialiser (ConfigSettings p_sv)
+ {
+ config = p_sv;
+ }
+ public override void Initialise (IPlugin plugin)
+ {
+ IAssetServer p = plugin as IAssetServer;
+ p.Initialise (config);
+ }
+ }
+
+ public class LegacyAssetServerClientPluginInitialiser : PluginInitialiserBase
+ {
+ private ConfigSettings config;
+ private string assetURL;
+
+ public LegacyAssetServerClientPluginInitialiser (ConfigSettings p_sv, string p_url)
+ {
+ config = p_sv;
+ assetURL = p_url;
+ }
+ public override void Initialise (IPlugin plugin)
+ {
+ IAssetServer p = plugin as IAssetServer;
+ p.Initialise (config, assetURL);
+ }
+ }
+
+ public class CryptoAssetServerClientPluginInitialiser : PluginInitialiserBase
+ {
+ private ConfigSettings config;
+ private string assetURL;
+ private string currdir;
+ private bool test;
+
+ public CryptoAssetServerClientPluginInitialiser (ConfigSettings p_sv, string p_url, string p_dir, bool p_test)
+ {
+ config = p_sv;
+ assetURL = p_url;
+ currdir = p_dir;
+ test = p_test;
+ }
+ public override void Initialise (IPlugin plugin)
+ {
+ IAssetServer p = plugin as IAssetServer;
+ p.Initialise (config, assetURL, currdir, test);
+ }
+ }
+
public interface IAssetPlugin
{
IAssetServer GetAssetServer();
}
+
}
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 228c0aae95..638125c331 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -268,6 +268,7 @@ namespace OpenSim
m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
+ m_configSettings.AssetCache = startupConfig.GetString("AssetCache");
m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
}
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 914bd7e07b..8198138458 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -55,6 +55,12 @@ namespace OpenSim
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ // These are the names of the plugin-points extended by this
+ // class during system startup.
+
+ private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
+ private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetServerClient";
+
protected string proxyUrl;
protected int proxyOffset = 0;
@@ -309,57 +315,183 @@ namespace OpenSim
}
///
- /// Initialises the assetcache
+ /// Initialises the asset cache. This supports legacy configuration values
+ /// to ensure consistent operation, but values outside of that namespace
+ /// are handled by the more generic resolution mechanism provided by
+ /// the ResolveAssetServer virtual method. If extended resolution fails,
+ /// then the normal default action is taken.
+ /// Creation of the AssetCache is handled by ResolveAssetCache. This
+ /// function accepts a reference to the instantiated AssetServer and
+ /// returns an IAssetCache implementation, if possible. This is a virtual
+ /// method.
///
+
protected virtual void InitialiseAssetCache()
{
+ LegacyAssetServerClientPluginInitialiser linit = null;
+ CryptoAssetServerClientPluginInitialiser cinit = null;
+ AssetServerClientPluginInitialiser init = null;
+
IAssetServer assetServer = null;
string mode = m_configSettings.AssetStorage;
- if (m_configSettings.Standalone == false &&
- m_configSettings.AssetStorage == "default")
- mode = "grid";
+ if (mode == null | mode == String.Empty)
+ mode = "default";
- switch (mode)
+ // If "default" is specified, then the value is adjusted
+ // according to whether or not the server is running in
+ // standalone mode.
+
+ if (mode.ToLower() == "default")
{
- case "grid" :
- assetServer = new GridAssetClient(m_networkServersInfo.AssetURL);
- break;
- case "cryptogrid" :
- assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
- Environment.CurrentDirectory, true);
- 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;
+ if (m_configSettings.Standalone == false)
+ mode = "grid";
+ else
+ mode = "local";
}
+ switch (mode.ToLower())
+ {
+
+ // If grid is specified then the grid server is chose regardless
+ // of whether the server is standalone.
+
+ case "grid" :
+ linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
+ assetServer = loadAssetServer("Grid", linit);
+ break;
+
+
+ // If cryptogrid is specified then the cryptogrid server is chose regardless
+ // of whether the server is standalone.
+
+ case "cryptogrid" :
+ cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
+ Environment.CurrentDirectory, true);
+ assetServer = loadAssetServer("Crypto", cinit);
+ break;
+
+ // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless
+ // of whether the server is standalone.
+
+ case "cryptogrid_eou" :
+ cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
+ Environment.CurrentDirectory, false);
+ assetServer = loadAssetServer("Crypto", cinit);
+ break;
+
+ // If file is specified then the file server is chose regardless
+ // of whether the server is standalone.
+
+ case "file" :
+ linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
+ assetServer = loadAssetServer("File", linit);
+ break;
+
+ // If local is specified then we're going to use the local SQL server
+ // implementation. We drop through, because that will be the fallback
+ // for the following default clause too.
+
+ case "local" :
+ break;
+
+ // If the asset_database value is none of the previously mentioned strings, then we
+ // try to load a turnkey plugin that matches this value. If not we drop through to
+ // a local default.
+
+ default :
+ try
+ {
+ init = new AssetServerClientPluginInitialiser(m_configSettings);
+ assetServer = loadAssetServer(m_configSettings.AssetStorage, init);
+ break;
+ }
+ catch {}
+ m_log.Info("[OPENSIMBASE] Default assetserver will be used");
+ break;
+
+ }
+
+ // Open the local SQL-based database asset server
+
+ if (assetServer == null)
+ {
+ init = new AssetServerClientPluginInitialiser(m_configSettings);
+ SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init);
+ sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
+ assetServer = sqlAssetServer;
+ }
+
+ // Initialize the asset cache, passing a reference to the selected
+ // asset server interface.
+
m_assetCache = ResolveAssetCache(assetServer);
}
- private bool ResolveAssetServer(out IAssetServer assetServer)
+ // This method loads the identified asset server, passing an approrpiately
+ // initialized Initialise wrapper. There should to be exactly one match,
+ // if not, then the first match is used.
+
+ private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
{
- assetServer = null;
- return false;
+
+ m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id);
+
+ PluginLoader loader = new PluginLoader(pi);
+ loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(id));
+ loader.Load(PLUGIN_ASSET_SERVER_CLIENT);
+ if (loader.Plugins.Count > 0)
+ return (IAssetServer) loader.Plugins[0];
+ else
+ return null;
+
}
- private IAssetCache ResolveAssetCache(IAssetServer assetServer)
+ ///
+ /// Attempt to instantiate an IAssetCache implementation, using the
+ /// provided IAssetServer reference.
+ /// An asset cache implementation must provide a constructor that
+ /// accepts two parameters;
+ /// [1] A ConfigSettings reference.
+ /// [2] An IAssetServer reference.
+ /// The AssetCache value is obtained from the
+ /// [StartUp]/AssetCache value in the configuration file.
+ ///
+
+ protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer)
{
- return new AssetCache(assetServer);
+
+ IAssetCache assetCache = null;
+
+ m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache);
+
+ if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
+ {
+ try
+ {
+
+ PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
+ PluginLoader loader = new PluginLoader(init);
+ loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(m_configSettings.AssetCache));
+
+ loader.Load(PLUGIN_ASSET_CACHE);
+ if (loader.Plugins.Count > 0)
+ assetCache = (IAssetCache) loader.Plugins[0];
+
+ }
+ catch (Exception e)
+ {
+ m_log.Debug("[OPENSIMBASE] ResolveAssetCache completed");
+ m_log.Debug(e);
+ }
+ }
+
+ // If everything else fails, we force load the built-in asset cache
+
+ return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer));
+
}
public void ProcessLogin(bool LoginEnabled)
diff --git a/bin/OpenSim.addin.xml b/bin/OpenSim.addin.xml
index 122a1a854a..707eaf3d6a 100644
--- a/bin/OpenSim.addin.xml
+++ b/bin/OpenSim.addin.xml
@@ -3,7 +3,13 @@
-
+
+
+
+
+
+
+
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 0e1958eab6..3469c2aff5 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -110,6 +110,8 @@
;
; If set to local then the local database based asset service will be used in standalone and grid modes
; If set to grid then the grid based asset service will be used in standalone and grid modes
+ ; All other values will cause a search for a matching assembly that contains an asset server client.
+ ; See also: AssetCache
asset_database = "default"
; Persistence of changed objects happens during regular sweeps. The following control that behaviour to
@@ -197,6 +199,17 @@
;WorldMapModule = "WorldMap"
;MapImageModule = "MapImageModule"
+ ; ##
+ ; ## Customized Cache Implementation
+ ; ##
+ ;
+ ; The AssetCache value allows the name of an alternative caching
+ ; implementation to be specified. This can normally be omitted.
+ ; This value corresponds to the provider value associated with the
+ ; intended cache implementation plugin.
+ ; See also: asset_database
+
+ ; AssetCache = "OpenSim.Framework.Communications.Cache.AssetCache"
; ##
; ## EMAIL MODULE
diff --git a/prebuild.xml b/prebuild.xml
index 30cb8c67d8..887ac8ab73 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -540,6 +540,7 @@
+