Send the config section name up to the service classes themselves (XInventory and Assets).

0.7.4.1
Diva Canto 2012-03-27 10:08:13 -07:00
parent ad865ab4fc
commit 8131a24cde
7 changed files with 40 additions and 46 deletions

View File

@ -59,7 +59,7 @@ namespace OpenSim.Server.Handlers.Asset
if (assetService == String.Empty) if (assetService == String.Empty)
throw new Exception("No LocalServiceModule in config file"); throw new Exception("No LocalServiceModule in config file");
Object[] args = new Object[] { config }; Object[] args = new Object[] { config, m_ConfigName };
m_AssetService = m_AssetService =
ServerUtils.LoadPlugin<IAssetService>(assetService, args); ServerUtils.LoadPlugin<IAssetService>(assetService, args);

View File

@ -67,7 +67,7 @@ namespace OpenSim.Server.Handlers.Asset
if (inventoryService == String.Empty) if (inventoryService == String.Empty)
throw new Exception("No InventoryService in config file"); throw new Exception("No InventoryService in config file");
Object[] args = new Object[] { config }; Object[] args = new Object[] { config, m_ConfigName };
m_InventoryService = m_InventoryService =
ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args); ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);

View File

@ -46,7 +46,12 @@ namespace OpenSim.Services.AssetService
protected static AssetService m_RootInstance; protected static AssetService m_RootInstance;
public AssetService(IConfigSource config) : base(config) public AssetService(IConfigSource config)
: this(config, "AssetService")
{
}
public AssetService(IConfigSource config, string configName) : base(config, configName)
{ {
if (m_RootInstance == null) if (m_RootInstance == null)
{ {
@ -54,9 +59,9 @@ namespace OpenSim.Services.AssetService
if (m_AssetLoader != null) if (m_AssetLoader != null)
{ {
IConfig assetConfig = config.Configs["AssetService"]; IConfig assetConfig = config.Configs[m_ConfigName];
if (assetConfig == null) if (assetConfig == null)
throw new Exception("No AssetService configuration"); throw new Exception("No " + m_ConfigName + " configuration");
string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
String.Empty); String.Empty);

View File

@ -39,16 +39,25 @@ namespace OpenSim.Services.AssetService
{ {
protected IAssetDataPlugin m_Database = null; protected IAssetDataPlugin m_Database = null;
protected IAssetLoader m_AssetLoader = null; protected IAssetLoader m_AssetLoader = null;
protected string m_ConfigName = "AssetService";
public AssetServiceBase(IConfigSource config) : base(config) public AssetServiceBase(IConfigSource config)
: this(config, "AssetService")
{ {
}
public AssetServiceBase(IConfigSource config, string configName) : base(config)
{
if (configName != string.Empty)
m_ConfigName = configName;
string dllName = String.Empty; string dllName = String.Empty;
string connString = String.Empty; string connString = String.Empty;
// //
// Try reading the [AssetService] section first, if it exists // Try reading the [AssetService] section, if it exists
// //
IConfig assetConfig = config.Configs["AssetService"]; IConfig assetConfig = config.Configs[m_ConfigName];
if (assetConfig != null) if (assetConfig != null)
{ {
dllName = assetConfig.GetString("StorageProvider", dllName); dllName = assetConfig.GetString("StorageProvider", dllName);

View File

@ -58,10 +58,10 @@ namespace OpenSim.Services.HypergridService
private UserAccountCache m_Cache; private UserAccountCache m_Cache;
public HGAssetService(IConfigSource config) : base(config) public HGAssetService(IConfigSource config, string configName) : base(config, configName)
{ {
m_log.Debug("[HGAsset Service]: Starting"); m_log.Debug("[HGAsset Service]: Starting");
IConfig assetConfig = config.Configs["HGAssetService"]; IConfig assetConfig = config.Configs[configName];
if (assetConfig == null) if (assetConfig == null)
throw new Exception("No HGAssetService configuration"); throw new Exception("No HGAssetService configuration");

View File

@ -60,36 +60,19 @@ namespace OpenSim.Services.HypergridService
private UserAccountCache m_Cache; private UserAccountCache m_Cache;
public HGInventoryService(IConfigSource config) public HGInventoryService(IConfigSource config, string configName)
: base(config) : base(config, configName)
{ {
m_log.Debug("[HGInventory Service]: Starting"); m_log.Debug("[HGInventory Service]: Starting");
if (configName != string.Empty)
string dllName = String.Empty; m_ConfigName = configName;
string connString = String.Empty;
//string realm = "Inventory"; // OSG version doesn't use this
//
// Try reading the [DatabaseService] section, if it exists
//
IConfig dbConfig = config.Configs["DatabaseService"];
if (dbConfig != null)
{
if (dllName == String.Empty)
dllName = dbConfig.GetString("StorageProvider", String.Empty);
if (connString == String.Empty)
connString = dbConfig.GetString("ConnectionString", String.Empty);
}
// //
// Try reading the [InventoryService] section, if it exists // Try reading the [InventoryService] section, if it exists
// //
IConfig invConfig = config.Configs["HGInventoryService"]; IConfig invConfig = config.Configs[m_ConfigName];
if (invConfig != null) if (invConfig != null)
{ {
dllName = invConfig.GetString("StorageProvider", dllName);
connString = invConfig.GetString("ConnectionString", connString);
// realm = authConfig.GetString("Realm", realm); // realm = authConfig.GetString("Realm", realm);
string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
if (userAccountsDll == string.Empty) if (userAccountsDll == string.Empty)
@ -108,17 +91,6 @@ namespace OpenSim.Services.HypergridService
m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
} }
//
// We tried, but this doesn't exist. We can't proceed.
//
if (dllName == String.Empty)
throw new Exception("No StorageProvider configured");
m_Database = LoadPlugin<IXInventoryData>(dllName,
new Object[] {connString, String.Empty});
if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module");
m_log.Debug("[HG INVENTORY SERVICE]: Starting..."); m_log.Debug("[HG INVENTORY SERVICE]: Starting...");
} }

View File

@ -46,9 +46,17 @@ namespace OpenSim.Services.InventoryService
protected IXInventoryData m_Database; protected IXInventoryData m_Database;
protected bool m_AllowDelete = true; protected bool m_AllowDelete = true;
protected string m_ConfigName = "InventoryService";
public XInventoryService(IConfigSource config) : base(config) public XInventoryService(IConfigSource config)
: this(config, "InventoryService")
{ {
}
public XInventoryService(IConfigSource config, string configName) : base(config)
{
if (configName != string.Empty)
m_ConfigName = configName;
string dllName = String.Empty; string dllName = String.Empty;
string connString = String.Empty; string connString = String.Empty;
//string realm = "Inventory"; // OSG version doesn't use this //string realm = "Inventory"; // OSG version doesn't use this
@ -56,7 +64,7 @@ namespace OpenSim.Services.InventoryService
// //
// Try reading the [InventoryService] section first, if it exists // Try reading the [InventoryService] section first, if it exists
// //
IConfig authConfig = config.Configs["InventoryService"]; IConfig authConfig = config.Configs[m_ConfigName];
if (authConfig != null) if (authConfig != null)
{ {
dllName = authConfig.GetString("StorageProvider", dllName); dllName = authConfig.GetString("StorageProvider", dllName);