diff options
author | Justin Clark-Casey (justincc) | 2013-03-15 21:53:39 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-15 21:53:39 +0000 |
commit | 924d6e892a7b5a61e900b910a5a35de488963529 (patch) | |
tree | 90a557f03dba4e61444cc2b3708cc808b25f6442 /OpenSim/Services/AssetService/XAssetServiceBase.cs | |
parent | Add example code to DOExampleModule to pull data from that previously saved b... (diff) | |
download | opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.zip opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.gz opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.bz2 opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.xz |
Make it possible to chain another asset service underneath the de-duplicating XAssetService.
This makes it possible to use the dedupliicating service without needing to migrate all the existing asset data beforehand.
Currently controlled by a ChainedServiceModule setting in [AssetService] (e.g. ChainedServiceModule = "OpenSim.Services.AssetService.dll:AssetService")
Not yet ready for use.
Diffstat (limited to 'OpenSim/Services/AssetService/XAssetServiceBase.cs')
-rw-r--r-- | OpenSim/Services/AssetService/XAssetServiceBase.cs | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/OpenSim/Services/AssetService/XAssetServiceBase.cs b/OpenSim/Services/AssetService/XAssetServiceBase.cs index 0c5c2c3..c118c9d 100644 --- a/OpenSim/Services/AssetService/XAssetServiceBase.cs +++ b/OpenSim/Services/AssetService/XAssetServiceBase.cs | |||
@@ -27,9 +27,11 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | ||
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 33 | using OpenSim.Data; |
34 | using OpenSim.Server.Base; | ||
33 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
34 | using OpenSim.Services.Base; | 36 | using OpenSim.Services.Base; |
35 | 37 | ||
@@ -37,10 +39,15 @@ namespace OpenSim.Services.AssetService | |||
37 | { | 39 | { |
38 | public class XAssetServiceBase : ServiceBase | 40 | public class XAssetServiceBase : ServiceBase |
39 | { | 41 | { |
40 | protected IXAssetDataPlugin m_Database = null; | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | protected IAssetLoader m_AssetLoader = null; | ||
42 | 43 | ||
43 | public XAssetServiceBase(IConfigSource config) : base(config) | 44 | protected IXAssetDataPlugin m_Database; |
45 | protected IAssetLoader m_AssetLoader; | ||
46 | protected IAssetService m_ChainedAssetService; | ||
47 | |||
48 | protected bool HasChainedAssetService { get { return m_ChainedAssetService != null; } } | ||
49 | |||
50 | public XAssetServiceBase(IConfigSource config, string configName) : base(config) | ||
44 | { | 51 | { |
45 | string dllName = String.Empty; | 52 | string dllName = String.Empty; |
46 | string connString = String.Empty; | 53 | string connString = String.Empty; |
@@ -48,7 +55,7 @@ namespace OpenSim.Services.AssetService | |||
48 | // | 55 | // |
49 | // Try reading the [AssetService] section first, if it exists | 56 | // Try reading the [AssetService] section first, if it exists |
50 | // | 57 | // |
51 | IConfig assetConfig = config.Configs["AssetService"]; | 58 | IConfig assetConfig = config.Configs[configName]; |
52 | if (assetConfig != null) | 59 | if (assetConfig != null) |
53 | { | 60 | { |
54 | dllName = assetConfig.GetString("StorageProvider", dllName); | 61 | dllName = assetConfig.GetString("StorageProvider", dllName); |
@@ -77,17 +84,35 @@ namespace OpenSim.Services.AssetService | |||
77 | if (m_Database == null) | 84 | if (m_Database == null) |
78 | throw new Exception("Could not find a storage interface in the given module"); | 85 | throw new Exception("Could not find a storage interface in the given module"); |
79 | 86 | ||
80 | m_Database.Initialise(connString); | 87 | string chainedAssetServiceDesignator = assetConfig.GetString("ChainedServiceModule", null); |
88 | |||
89 | if (chainedAssetServiceDesignator != null) | ||
90 | { | ||
91 | m_log.InfoFormat( | ||
92 | "[XASSET SERVICE BASE]: Loading chained asset service from {0}", chainedAssetServiceDesignator); | ||
81 | 93 | ||
82 | string loaderName = assetConfig.GetString("DefaultAssetLoader", | 94 | Object[] args = new Object[] { config, configName }; |
83 | String.Empty); | 95 | m_ChainedAssetService = ServerUtils.LoadPlugin<IAssetService>(chainedAssetServiceDesignator, args); |
84 | 96 | ||
85 | if (loaderName != String.Empty) | 97 | if (!HasChainedAssetService) |
98 | throw new Exception( | ||
99 | String.Format("Failed to load ChainedAssetService from {0}", chainedAssetServiceDesignator)); | ||
100 | } | ||
101 | |||
102 | m_Database.Initialise(connString); | ||
103 | |||
104 | if (HasChainedAssetService) | ||
86 | { | 105 | { |
87 | m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName); | 106 | string loaderName = assetConfig.GetString("DefaultAssetLoader", |
107 | String.Empty); | ||
108 | |||
109 | if (loaderName != String.Empty) | ||
110 | { | ||
111 | m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName); | ||
88 | 112 | ||
89 | if (m_AssetLoader == null) | 113 | if (m_AssetLoader == null) |
90 | throw new Exception("Asset loader could not be loaded"); | 114 | throw new Exception("Asset loader could not be loaded"); |
115 | } | ||
91 | } | 116 | } |
92 | } | 117 | } |
93 | } | 118 | } |