From 2270b252656146d9d74b84665a7ace6c3139db30 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 09:24:28 +0000 Subject: [PATCH] Thanks, sempuki, for a patch that moves all Grid Server's plugins to PluginLoader. Fix issue 1871. --- OpenSim/Data/AssetDataBase.cs | 2 +- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 2 +- OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 20 ++- OpenSim/Data/MSSQL/MSSQLUserData.cs | 8 + OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 20 ++- OpenSim/Data/MySQL/MySQLUserData.cs | 23 ++- .../NHibernate/NHibernateInventoryData.cs | 33 ++-- OpenSim/Data/NHibernate/NHibernateUserData.cs | 8 +- OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 33 ++-- OpenSim/Data/SQLite/SQLiteUserData.cs | 8 + OpenSim/Data/UserDataBase.cs | 9 +- .../Communications/Cache/AssetServerBase.cs | 2 +- .../Communications/Cache/SQLAssetServer.cs | 8 +- .../Communications/InventoryServiceBase.cs | 79 ++++----- .../Communications/UserManagerBase.cs | 167 ++++++++---------- OpenSim/Framework/IAssetProvider.cs | 13 +- OpenSim/Framework/IInventoryData.cs | 32 ++-- OpenSim/Framework/IUserData.cs | 27 ++- OpenSim/Framework/PluginLoader.cs | 24 ++- OpenSim/Grid/AssetServer/Main.cs | 37 ++-- OpenSim/Grid/AssetServer/RestService.cs | 8 +- OpenSim/Grid/GridServer/GridManager.cs | 7 +- OpenSim/Tests/Inventory/TestInventory.cs | 2 +- bin/LoadRegionsPlugin.addin.xml | 2 +- bin/OpenSim.Data.MSSQL.addin.xml | 13 +- bin/OpenSim.Data.MySQL.addin.xml | 13 +- bin/OpenSim.Data.SQLite.addin.xml | 11 +- bin/OpenSim.Data.addin.xml | 12 ++ bin/RemoteAdminPlugin.addin.xml | 2 +- bin/RestHandler.addin.xml | 2 +- bin/RestRegionPlugin.addin.xml | 2 +- 33 files changed, 354 insertions(+), 279 deletions(-) diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index 6e9e085187..690abd0beb 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs @@ -30,7 +30,7 @@ using OpenSim.Framework; namespace OpenSim.Data { - public abstract class AssetDataBase : IAssetProvider + public abstract class AssetDataBase : IAssetProviderPlugin { public abstract AssetBase FetchAsset(LLUUID uuid); public abstract void CreateAsset(AssetBase asset); diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index e0e20dfa9e..443907f1e5 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -45,7 +45,7 @@ namespace OpenSim.Data.MSSQL private MSSQLManager database; - #region IAssetProvider Members + #region IAssetProviderPlugin Members /// /// Migration method diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index 4a8d6e9b3a..9e60b160a6 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.MSSQL /// /// A MSSQL interface for the inventory server /// - public class MSSQLInventoryData : IInventoryData + public class MSSQLInventoryData : IInventoryDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -59,6 +59,12 @@ namespace OpenSim.Data.MSSQL /// private MSSQLManager database; + public void Initialise() + { + m_log.Info("[MSSQLInventoryData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Loads and initialises the MSSQL inventory storage interface /// @@ -134,15 +140,15 @@ namespace OpenSim.Data.MSSQL /// The name of this DB provider /// /// A string containing the name of the DB provider - public string getName() + public string Name { - return "MSSQL Inventory Data Interface"; + get { return "MSSQL Inventory Data Interface"; } } /// /// Closes this DB provider /// - public void Close() + public void Dispose() { // Do nothing. } @@ -151,9 +157,9 @@ namespace OpenSim.Data.MSSQL /// Returns the version of this DB provider /// /// A string containing the DB provider - public string getVersion() + public string Version { - return database.getVersion(); + get { return database.getVersion(); } } /// @@ -681,7 +687,7 @@ namespace OpenSim.Data.MSSQL folders.Add(f); } - // See IInventoryData + // See IInventoryDataPlugin public List getFolderHierarchy(LLUUID parentID) { List folders = new List(); diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index 0593c62414..0703aab068 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs @@ -52,6 +52,12 @@ namespace OpenSim.Data.MSSQL private string m_usersTableName; private string m_userFriendsTableName; + public override void Initialise() + { + m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Loads and initialises the MSSQL storage plugin /// @@ -93,6 +99,8 @@ namespace OpenSim.Data.MSSQL TestTables(); } + + public override void Dispose () {} /// /// diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 9284ba9c9f..cec736ae0a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL override public void Dispose() { } - #region IAssetProvider Members + #region IAssetProviderPlugin Members /// /// diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index fee457a504..4cddbe57cb 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -51,7 +51,7 @@ namespace OpenSim.Data.MySQL override public void Initialise() { - m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 5bde40a2cd..0fb49c12c2 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL interface for the inventory server /// - public class MySQLInventoryData : IInventoryData + public class MySQLInventoryData : IInventoryDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -48,6 +48,12 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + public void Initialise() + { + m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises Inventory interface /// @@ -183,16 +189,16 @@ namespace OpenSim.Data.MySQL /// The name of this DB provider /// /// Name of DB provider - public string getName() + public string Name { - return "MySQL Inventory Data Interface"; + get { return "MySQL Inventory Data Interface"; } } /// /// Closes this DB provider /// /// do nothing - public void Close() + public void Dispose() { // Do nothing. } @@ -201,9 +207,9 @@ namespace OpenSim.Data.MySQL /// Returns the version of this DB provider /// /// A string containing the DB provider version - public string getVersion() + public string Version { - return database.getVersion(); + get { return database.getVersion(); } } /// @@ -692,7 +698,7 @@ namespace OpenSim.Data.MySQL /// - /// See IInventoryData + /// See IInventoryDataPlugin /// /// /// diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 11d9c26246..d8830de13c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -55,6 +55,12 @@ namespace OpenSim.Data.MySQL private string m_appearanceTableName = "avatarappearance"; private string m_connectString; + public override void Initialise() + { + m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialise User Interface /// Loads and initialises the MySQL storage plugin @@ -120,6 +126,9 @@ namespace OpenSim.Data.MySQL m.Update(); } + public override void Dispose () { } + + #region Test and initialization code /// @@ -252,7 +261,7 @@ namespace OpenSim.Data.MySQL UserProfileData row = database.readUserRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; } @@ -398,7 +407,7 @@ namespace OpenSim.Data.MySQL Lfli.Add(fli); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -450,7 +459,7 @@ namespace OpenSim.Data.MySQL user.lastName = (string) reader["lastname"]; returnlist.Add(user); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -484,7 +493,7 @@ namespace OpenSim.Data.MySQL user.lastName = (string) reader["lastname"]; returnlist.Add(user); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -517,7 +526,7 @@ namespace OpenSim.Data.MySQL UserProfileData row = database.readUserRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; @@ -603,7 +612,7 @@ namespace OpenSim.Data.MySQL UserAgentData row = database.readAgentRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; @@ -725,7 +734,7 @@ namespace OpenSim.Data.MySQL AvatarAppearance appearance = database.readAppearanceRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return appearance; diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 153d2d547f..657a7b2855 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs @@ -42,7 +42,7 @@ using Environment=NHibernate.Cfg.Environment; namespace OpenSim.Data.NHibernate { - public class NHibernateInventoryData: IInventoryData + public class NHibernateInventoryData: IInventoryDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -50,6 +50,12 @@ namespace OpenSim.Data.NHibernate private ISessionFactory factory; private ISession session; + public void Initialise() + { + m_log.Info("[NHibernateInventoryData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises the interface /// @@ -257,7 +263,7 @@ namespace OpenSim.Data.NHibernate /// /// Closes the interface /// - public void Close() + public void Dispose() { } @@ -265,25 +271,28 @@ namespace OpenSim.Data.NHibernate /// The plugin being loaded /// /// A string containing the plugin name - public string getName() + public string Name { - return "NHibernate Inventory Data Interface"; + get { return "NHibernate Inventory Data Interface"; } } /// /// The plugins version /// /// A string containing the plugin version - public string getVersion() + public string Version { - Module module = GetType().Module; - // string dllName = module.Assembly.ManifestModule.Name; - Version dllVersion = module.Assembly.GetName().Version; + get + { + Module module = GetType().Module; + // string dllName = module.Assembly.ManifestModule.Name; + Version dllVersion = module.Assembly.GetName().Version; - return - string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); + return + string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, + dllVersion.Revision); + } } // Move seems to be just update @@ -369,7 +378,7 @@ namespace OpenSim.Data.NHibernate return folders; } - // See IInventoryData + // See IInventoryDataPlugin public List getFolderHierarchy(LLUUID parentID) { List folders = new List(); diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index 9d9aec9b23..bceae7c881 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs @@ -53,6 +53,12 @@ namespace OpenSim.Data.NHibernate private ISessionFactory factory; private ISession session; + public override void Initialise() + { + m_log.Info("[NHibernateUserData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + public override void Initialise(string connect) { char[] split = {';'}; @@ -320,7 +326,7 @@ namespace OpenSim.Data.NHibernate get { return "0.1"; } } - public void Dispose() + public override void Dispose() { } diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index 99560a0918..ef4ef99042 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.SQLite /// /// An Inventory Interface to the SQLite database /// - public class SQLiteInventoryStore : SQLiteUtil, IInventoryData + public class SQLiteInventoryStore : SQLiteUtil, IInventoryDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -50,6 +50,12 @@ namespace OpenSim.Data.SQLite private SqliteDataAdapter invItemsDa; private SqliteDataAdapter invFoldersDa; + public void Initialise() + { + m_log.Info("[SQLiteInventoryData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// /// Initialises Inventory interface @@ -277,7 +283,7 @@ namespace OpenSim.Data.SQLite /// /// Closes the inventory interface /// - public void Close() + public void Dispose() { } @@ -285,25 +291,28 @@ namespace OpenSim.Data.SQLite /// The name of this DB provider /// /// Name of DB provider - public string getName() + public string Name { - return "SQLite Inventory Data Interface"; + get { return "SQLite Inventory Data Interface"; } } /// /// Returns the version of this DB provider /// /// A string containing the DB provider version - public string getVersion() + public string Version { - Module module = GetType().Module; - // string dllName = module.Assembly.ManifestModule.Name; - Version dllVersion = module.Assembly.GetName().Version; + get + { + Module module = GetType().Module; + // string dllName = module.Assembly.ManifestModule.Name; + Version dllVersion = module.Assembly.GetName().Version; - return - string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); + return + string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, + dllVersion.Revision); + } } /// @@ -399,7 +408,7 @@ namespace OpenSim.Data.SQLite } /// - /// See IInventoryData + /// See IInventoryDataPlugin /// /// /// diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index c7673bd3ec..2d3687c3cc 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -65,6 +65,12 @@ namespace OpenSim.Data.SQLite private SqliteDataAdapter daf; SqliteConnection g_conn; + public override void Initialise() + { + m_log.Info("[SQLiteUserData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// /// Initialises User Interface @@ -124,6 +130,8 @@ namespace OpenSim.Data.SQLite return; } + public override void Dispose () {} + /// /// see IUserData, /// Get user data profile by UUID diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index eb21aeec9b..e4e39d65d4 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs @@ -55,9 +55,6 @@ namespace OpenSim.Data public abstract List GetUserFriendList(LLUUID friendlistowner); public abstract bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount); public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); - public abstract string Version {get;} - public abstract string Name {get;} - public abstract void Initialise(string connect); public abstract List GeneratePickerResults(LLUUID queryID, string query); public abstract AvatarAppearance GetUserAppearance(LLUUID user); public abstract void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); @@ -78,5 +75,11 @@ namespace OpenSim.Data public abstract void AddAttachment(LLUUID user, LLUUID item); public abstract void RemoveAttachment(LLUUID user, LLUUID item); public abstract List GetAttachments(LLUUID user); + + public abstract string Version {get;} + public abstract string Name {get;} + public abstract void Initialise(string connect); + public abstract void Initialise(); + public abstract void Dispose(); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f729d78c83..ed5b896f29 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache protected IAssetReceiver m_receiver; protected BlockingQueue m_assetRequests; protected Thread m_localAssetServerThread; - protected IAssetProvider m_assetProvider; + protected IAssetProviderPlugin m_assetProvider; // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 94a85095d1..2f72e11532 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache AddPlugin(pluginName, connect); } - public SQLAssetServer(IAssetProvider assetProvider) + public SQLAssetServer(IAssetProviderPlugin assetProvider) { m_assetProvider = assetProvider; } @@ -54,12 +54,12 @@ namespace OpenSim.Framework.Communications.Cache { if (!pluginType.IsAbstract) { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + Type typeInterface = pluginType.GetInterface("IAssetProviderPlugin", true); if (typeInterface != null) { - IAssetProvider plug = - (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetProviderPlugin plug = + (IAssetProviderPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProvider = plug; m_assetProvider.Initialise(connect); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 06b707ba2b..40701f0af9 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -43,38 +43,25 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Dictionary m_plugins = new Dictionary(); + protected List m_plugins = new List(); #region Plugin methods /// /// Adds a new user server plugin - plugins will be requested in the order they were loaded. /// - /// The filename to the user server plugin DLL - public void AddPlugin(string FileName, string connect) + /// The filename to the user server plugin DLL + public void AddPlugin(string provider, string connect) { - if (!String.IsNullOrEmpty(FileName)) - { - m_log.Info("[AGENT INVENTORY]: Inventory storage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); + PluginLoader loader = + new PluginLoader (new InventoryDataInitialiser (connect)); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IInventoryData", true); - - if (typeInterface != null) - { - IInventoryData plug = - (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(connect); - m_plugins.Add(plug.getName(), plug); - m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface"); - } - } - } - } + // loader will try to load all providers (MySQL, MSSQL, etc) + // unless it is constrainted to the correct "Provider" entry in the addin.xml + loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); + loader.Load(); + + m_plugins = loader.Plugins; } #endregion @@ -103,9 +90,9 @@ namespace OpenSim.Framework.Communications userFolders.Add(rootFolder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.ID); + IList folders = plugin.getFolderHierarchy(rootFolder.ID); userFolders.AddRange(folders); } @@ -127,9 +114,9 @@ namespace OpenSim.Framework.Communications public InventoryFolderBase RequestRootFolder(LLUUID userID) { // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.Value.getUserRootFolder(userID); + return plugin.getUserRootFolder(userID); } return null; } @@ -168,9 +155,9 @@ namespace OpenSim.Framework.Communications public List RequestSubFolders(LLUUID parentFolderID) { List inventoryList = new List(); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.Value.getInventoryFolders(parentFolderID); + return plugin.getInventoryFolders(parentFolderID); } return inventoryList; } @@ -178,9 +165,9 @@ namespace OpenSim.Framework.Communications public List RequestFolderItems(LLUUID folderID) { List itemsList = new List(); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - itemsList = plugin.Value.getInventoryInFolder(folderID); + itemsList = plugin.getInventoryInFolder(folderID); return itemsList; } return itemsList; @@ -194,9 +181,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.addInventoryFolder(folder); + plugin.addInventoryFolder(folder); } // FIXME: Should return false on failure @@ -209,9 +196,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.updateInventoryFolder(folder); + plugin.updateInventoryFolder(folder); } // FIXME: Should return false on failure @@ -224,9 +211,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.moveInventoryFolder(folder); + plugin.moveInventoryFolder(folder); } // FIXME: Should return false on failure @@ -239,9 +226,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.addInventoryItem(item); + plugin.addInventoryItem(item); } // FIXME: Should return false on failure @@ -254,9 +241,9 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat( "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.updateInventoryItem(item); + plugin.updateInventoryItem(item); } // FIXME: Should return false on failure @@ -269,9 +256,9 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat( "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.deleteInventoryItem(item.ID); + plugin.deleteInventoryItem(item.ID); } // FIXME: Should return false on failure @@ -296,9 +283,9 @@ namespace OpenSim.Framework.Communications { // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.deleteInventoryFolder(subFolder.ID); + plugin.deleteInventoryFolder(subFolder.ID); } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1b73152e35..f8e77df6c1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -47,42 +47,23 @@ namespace OpenSim.Framework.Communications = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; - private Dictionary _plugins = new Dictionary(); + private List _plugins = new List(); /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// - /// The filename to the user server plugin DLL - public void AddPlugin(string FileName, string connect) + /// The filename to the user server plugin DLL + public void AddPlugin(string provider, string connect) { - if (!String.IsNullOrEmpty(FileName)) - { - m_log.Info("[USERSTORAGE]: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); + PluginLoader loader = + new PluginLoader (new UserDataInitialiser (connect)); - m_log.Info("[USERSTORAGE]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IUserData", true); - - if (typeInterface != null) - { - IUserData plug = - (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - AddPlugin(plug, connect); - } - } - } - } - } - - public void AddPlugin(IUserData plug, string connect) - { - plug.Initialise(connect); - _plugins.Add(plug.Name, plug); - m_log.Info("[USERSTORAGE]: Added IUserData Interface"); + // loader will try to load all providers (MySQL, MSSQL, etc) + // unless it is constrainted to the correct "Provider" entry in the addin.xml + loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); + loader.Load(); + + _plugins = loader.Plugins; } #region Get UserProfile @@ -90,9 +71,9 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(string fname, string lname) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + UserProfileData profile = plugin.GetUserByName(fname, lname); if (profile != null) { @@ -105,9 +86,9 @@ namespace OpenSim.Framework.Communications } public UserAgentData GetAgentByUUID(LLUUID userId) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserAgentData agent = plugin.Value.GetAgentByUUID(userId); + UserAgentData agent = plugin.GetAgentByUUID(userId); if (agent != null) { @@ -120,9 +101,9 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(LLUUID uuid) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserProfileData profile = plugin.Value.GetUserByUUID(uuid); + UserProfileData profile = plugin.GetUserByUUID(uuid); if (null != profile) { @@ -137,15 +118,15 @@ namespace OpenSim.Framework.Communications public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { List pickerlist = new List(); - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - pickerlist = plugin.Value.GeneratePickerResults(queryID, query); + pickerlist = plugin.GeneratePickerResults(queryID, query); } catch (Exception) { - m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); return new List(); } } @@ -159,17 +140,17 @@ namespace OpenSim.Framework.Communications /// public bool UpdateUserProfile(UserProfileData data) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserProfile(data); + plugin.UpdateUserProfile(data); return true; } catch (Exception e) { m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, - plugin.Key, e.ToString()); + plugin.Name, e.ToString()); } } return false; @@ -186,15 +167,15 @@ namespace OpenSim.Framework.Communications /// Agent profiles public UserAgentData GetUserAgent(LLUUID uuid) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByUUID(uuid); + return plugin.GetAgentByUUID(uuid); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -208,15 +189,15 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string name) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByName(name); + return plugin.GetAgentByName(name); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -231,15 +212,15 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string fname, string lname) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByName(fname, lname); + return plugin.GetAgentByName(fname, lname); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -248,15 +229,15 @@ namespace OpenSim.Framework.Communications public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); + plugin.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -268,15 +249,15 @@ namespace OpenSim.Framework.Communications /// A List of FriendListItems that contains info about the user's friends public List GetUserFriendList(LLUUID ownerID) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetUserFriendList(ownerID); + return plugin.GetUserFriendList(ownerID); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -285,60 +266,60 @@ namespace OpenSim.Framework.Communications public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.StoreWebLoginKey(agentID, webLoginKey); + plugin.StoreWebLoginKey(agentID, webLoginKey); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserFriend(friendlistowner,friend,perms); + plugin.AddNewUserFriend(friendlistowner,friend,perms); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.RemoveUserFriend(friendlistowner, friend); + plugin.RemoveUserFriend(friendlistowner, friend); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserFriendPerms(friendlistowner, friend, perms); + plugin.UpdateUserFriendPerms(friendlistowner, friend, perms); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -564,15 +545,15 @@ namespace OpenSim.Framework.Communications user.HomeRegionX = regX; user.HomeRegionY = regY; - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserProfile(user); + plugin.AddNewUserProfile(user); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -586,16 +567,16 @@ namespace OpenSim.Framework.Communications m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString()); return false; } - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserProfile(UserProfile); + plugin.UpdateUserProfile(UserProfile); } catch (Exception e) { m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() - + " via " + plugin.Key + "(" + e.ToString() + ")"); + + " via " + plugin.Name + "(" + e.ToString() + ")"); return false; } } @@ -612,16 +593,16 @@ namespace OpenSim.Framework.Communications /// The agent data to be added public bool AddUserAgent(UserAgentData agentdata) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserAgent(agentdata); + plugin.AddNewUserAgent(agentdata); return true; } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); } } return false; @@ -631,15 +612,15 @@ namespace OpenSim.Framework.Communications /// TODO: stubs for now to get us to a compiling state gently public AvatarAppearance GetUserAppearance(LLUUID user) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetUserAppearance(user); + return plugin.GetUserAppearance(user); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } return null; @@ -647,60 +628,60 @@ namespace OpenSim.Framework.Communications public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserAppearance(user, appearance); + plugin.UpdateUserAppearance(user, appearance); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } } public void AddAttachment(LLUUID user, LLUUID item) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddAttachment(user, item); + plugin.AddAttachment(user, item); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); } } } public void RemoveAttachment(LLUUID user, LLUUID item) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.RemoveAttachment(user, item); + plugin.RemoveAttachment(user, item); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); } } } public List GetAttachments(LLUUID user) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAttachments(user); + return plugin.GetAttachments(user); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } return new List(); diff --git a/OpenSim/Framework/IAssetProvider.cs b/OpenSim/Framework/IAssetProvider.cs index a9d0e33a36..00d290e996 100644 --- a/OpenSim/Framework/IAssetProvider.cs +++ b/OpenSim/Framework/IAssetProvider.cs @@ -29,7 +29,7 @@ using libsecondlife; namespace OpenSim.Framework { - public interface IAssetProvider : IPlugin + public interface IAssetProviderPlugin : IPlugin { AssetBase FetchAsset(LLUUID uuid); void CreateAsset(AssetBase asset); @@ -37,4 +37,15 @@ namespace OpenSim.Framework bool ExistsAsset(LLUUID uuid); void Initialise(string connect); } + + public class AssetDataInitialiser : PluginInitialiserBase + { + private string connect; + public AssetDataInitialiser (string s) { connect = s; } + public override void Initialise (IPlugin plugin) + { + IAssetProviderPlugin p = plugin as IAssetProviderPlugin; + p.Initialise (connect); + } + } } diff --git a/OpenSim/Framework/IInventoryData.cs b/OpenSim/Framework/IInventoryData.cs index fabcbe28ec..0d4c555cc2 100644 --- a/OpenSim/Framework/IInventoryData.cs +++ b/OpenSim/Framework/IInventoryData.cs @@ -33,30 +33,13 @@ namespace OpenSim.Framework /// /// An interface for accessing inventory data from a storage server /// - public interface IInventoryData + public interface IInventoryDataPlugin : IPlugin { /// /// Initialises the interface /// void Initialise(string connect); - /// - /// Closes the interface - /// - void Close(); - - /// - /// The plugin being loaded - /// - /// A string containing the plugin name - string getName(); - - /// - /// The plugins version - /// - /// A string containing the plugin version - string getVersion(); - /// /// Returns all child folders in the hierarchy from the parent folder and down. /// Does not return the parent folder itself. @@ -149,4 +132,15 @@ namespace OpenSim.Framework /// The id of the folder void deleteInventoryFolder(LLUUID folder); } -} \ No newline at end of file + + public class InventoryDataInitialiser : PluginInitialiserBase + { + private string connect; + public InventoryDataInitialiser (string s) { connect = s; } + public override void Initialise (IPlugin plugin) + { + IInventoryDataPlugin p = plugin as IInventoryDataPlugin; + p.Initialise (connect); + } + } +} diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index 59527135de..27686c0811 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -33,7 +33,7 @@ namespace OpenSim.Framework /// /// An interface for connecting to user storage servers. /// - public interface IUserData + public interface IUserData : IPlugin { /// /// Returns a user profile from a database via their UUID @@ -153,18 +153,6 @@ namespace OpenSim.Framework /// Successful? bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); - /// - /// Returns the plugin version - /// - /// Plugin version in MAJOR.MINOR.REVISION.BUILD format - string Version {get;} - - /// - /// Returns the plugin name - /// - /// Plugin name, eg MySQL User Provider - string Name {get;} - /// /// Initialises the plugin (artificial constructor) /// @@ -182,4 +170,15 @@ namespace OpenSim.Framework void RemoveAttachment(LLUUID user, LLUUID item); List GetAttachments(LLUUID user); } -} \ No newline at end of file + + public class UserDataInitialiser : PluginInitialiserBase + { + private string connect; + public UserDataInitialiser (string s) { connect = s; } + public override void Initialise (IPlugin plugin) + { + IUserData p = plugin as IUserData; + p.Initialise (connect); + } + } +} diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs index 616fa3e4cf..3bc4de62aa 100644 --- a/OpenSim/Framework/PluginLoader.cs +++ b/OpenSim/Framework/PluginLoader.cs @@ -96,6 +96,11 @@ namespace OpenSim.Framework get { return loaded; } } + public T Plugin + { + get { return (loaded.Count == 1)? loaded [0] : default (T); } + } + public PluginLoader () { Initialiser = new PluginInitialiserBase(); @@ -114,11 +119,26 @@ namespace OpenSim.Framework initialise_plugin_dir_ (dir); } - public void AddExtensionPoint (string extpoint) + public void Add (string extpoint) { + if (extpoints.Contains (extpoint)) + return; + extpoints.Add (extpoint); } + public void Add (string extpoint, IPluginConstraint cons) + { + Add (extpoint); + AddConstraint (extpoint, cons); + } + + public void Add (string extpoint, IPluginFilter filter) + { + Add (extpoint); + AddFilter (extpoint, filter); + } + public void AddConstraint (string extpoint, IPluginConstraint cons) { constraints.Add (extpoint, cons); @@ -131,7 +151,7 @@ namespace OpenSim.Framework public void Load (string extpoint) { - AddExtensionPoint (extpoint); + Add (extpoint); Load(); } diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 7053f72cb3..7c7e39be8c 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -53,7 +53,7 @@ namespace OpenSim.Grid.AssetServer // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); - private IAssetProvider m_assetProvider; + private IAssetProviderPlugin m_assetProvider; [STAThread] public static void Main(string[] args) @@ -116,36 +116,19 @@ namespace OpenSim.Grid.AssetServer return null; } - public IAssetProvider LoadDatabasePlugin(string FileName, string connect) + public IAssetProviderPlugin LoadDatabasePlugin(string provider, string connect) { - m_log.Info("[ASSET SERVER]: LoadDatabasePlugin: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - IAssetProvider assetPlugin = null; - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + PluginLoader loader = + new PluginLoader (new AssetDataInitialiser (connect)); - if (typeInterface != null) - { - IAssetProvider plug = - (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - assetPlugin = plug; - assetPlugin.Initialise(connect); + // loader will try to load all providers (MySQL, MSSQL, etc) + // unless it is constrainted to the correct "Provider" entry in the addin.xml + loader.Add ("/OpenSim/AssetData", new PluginProviderFilter (provider)); + loader.Load(); - m_log.Info("[ASSET SERVER]: Added " + assetPlugin.Name + " " + assetPlugin.Version); - break; - } - - typeInterface = null; - } - } - - pluginAssembly = null; - return assetPlugin; + return loader.Plugin; } - + public void setupDB(AssetConfig config) { try diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 372f5f8946..f63b78bda3 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs @@ -45,14 +45,14 @@ namespace OpenSim.Grid.AssetServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private OpenAsset_Main m_assetManager; - private IAssetProvider m_assetProvider; + private IAssetProviderPlugin m_assetProvider; /// /// Constructor. /// /// /// - public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) + public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProviderPlugin assetProvider) : base("GET", "/assets") { m_log.Info("[REST]: In Get Request"); @@ -121,7 +121,7 @@ namespace OpenSim.Grid.AssetServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private OpenAsset_Main m_assetManager; - private IAssetProvider m_assetProvider; + private IAssetProviderPlugin m_assetProvider; public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) @@ -142,7 +142,7 @@ namespace OpenSim.Grid.AssetServer return new byte[] {}; } - public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) + public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProviderPlugin assetProvider) : base("POST", "/assets") { // m_assetManager = assetManager; diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 98e670f597..3101a388de 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -67,13 +67,10 @@ namespace OpenSim.Grid.GridServer PluginLoader logloader = new PluginLoader (new LogDataInitialiser (connect)); - gridloader.AddExtensionPoint ("/OpenSim/GridData"); - logloader.AddExtensionPoint ("/OpenSim/LogData"); - // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml - gridloader.AddFilter ("/OpenSim/GridData", new PluginProviderFilter (provider)); - logloader.AddFilter ("/OpenSim/LogData", new PluginProviderFilter (provider)); + gridloader.Add ("/OpenSim/GridData", new PluginProviderFilter (provider)); + logloader.Add ("/OpenSim/LogData", new PluginProviderFilter (provider)); gridloader.Load(); logloader.Load(); diff --git a/OpenSim/Tests/Inventory/TestInventory.cs b/OpenSim/Tests/Inventory/TestInventory.cs index 3083c894ad..7863904b55 100644 --- a/OpenSim/Tests/Inventory/TestInventory.cs +++ b/OpenSim/Tests/Inventory/TestInventory.cs @@ -42,7 +42,7 @@ namespace OpenSim.Test.Inventory [TestFixture] public class TestInventory { - IInventoryData _dbPlugin; + IInventoryDataPlugin _dbPlugin; LLUUID _agent_1_id; public static LLUUID LibraryFolderRootUuid = new LLUUID("5926de2a-c2d7-4c11-ac4e-74512ffeb6d1"); diff --git a/bin/LoadRegionsPlugin.addin.xml b/bin/LoadRegionsPlugin.addin.xml index a12f91a0c9..37222b7359 100644 --- a/bin/LoadRegionsPlugin.addin.xml +++ b/bin/LoadRegionsPlugin.addin.xml @@ -6,6 +6,6 @@ - + diff --git a/bin/OpenSim.Data.MSSQL.addin.xml b/bin/OpenSim.Data.MSSQL.addin.xml index 9b05e59b36..15fd29e57c 100644 --- a/bin/OpenSim.Data.MSSQL.addin.xml +++ b/bin/OpenSim.Data.MSSQL.addin.xml @@ -6,9 +6,18 @@ - + - + + + + + + + + + + diff --git a/bin/OpenSim.Data.MySQL.addin.xml b/bin/OpenSim.Data.MySQL.addin.xml index f7372e6ccc..9e995479d0 100644 --- a/bin/OpenSim.Data.MySQL.addin.xml +++ b/bin/OpenSim.Data.MySQL.addin.xml @@ -6,9 +6,18 @@ - + - + + + + + + + + + + diff --git a/bin/OpenSim.Data.SQLite.addin.xml b/bin/OpenSim.Data.SQLite.addin.xml index 1d2f29ee2d..e6764facbd 100644 --- a/bin/OpenSim.Data.SQLite.addin.xml +++ b/bin/OpenSim.Data.SQLite.addin.xml @@ -6,6 +6,15 @@ - + + + + + + + + + + diff --git a/bin/OpenSim.Data.addin.xml b/bin/OpenSim.Data.addin.xml index 991f652444..9530c16906 100644 --- a/bin/OpenSim.Data.addin.xml +++ b/bin/OpenSim.Data.addin.xml @@ -1,6 +1,9 @@ + + + @@ -10,4 +13,13 @@ + + + + + + + + + diff --git a/bin/RemoteAdminPlugin.addin.xml b/bin/RemoteAdminPlugin.addin.xml index a0b8bee4ae..d68f2e42ec 100644 --- a/bin/RemoteAdminPlugin.addin.xml +++ b/bin/RemoteAdminPlugin.addin.xml @@ -6,6 +6,6 @@ - + diff --git a/bin/RestHandler.addin.xml b/bin/RestHandler.addin.xml index 33a148449e..777a2dc27f 100644 --- a/bin/RestHandler.addin.xml +++ b/bin/RestHandler.addin.xml @@ -6,6 +6,6 @@ - + diff --git a/bin/RestRegionPlugin.addin.xml b/bin/RestRegionPlugin.addin.xml index 9fc8e6be4d..94eca48371 100644 --- a/bin/RestRegionPlugin.addin.xml +++ b/bin/RestRegionPlugin.addin.xml @@ -6,6 +6,6 @@ - +