From 2270b252656146d9d74b84665a7ace6c3139db30 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 09:24:28 +0000 Subject: Thanks, sempuki, for a patch that moves all Grid Server's plugins to PluginLoader. Fix issue 1871. --- .../Communications/Cache/AssetServerBase.cs | 2 +- .../Communications/Cache/SQLAssetServer.cs | 8 +- .../Communications/InventoryServiceBase.cs | 81 +++++----- .../Framework/Communications/UserManagerBase.cs | 169 +++++++++------------ OpenSim/Framework/IAssetProvider.cs | 13 +- OpenSim/Framework/IInventoryData.cs | 32 ++-- OpenSim/Framework/IUserData.cs | 27 ++-- OpenSim/Framework/PluginLoader.cs | 24 ++- 8 files changed, 174 insertions(+), 182 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f729d78..ed5b896 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 94a8509..2f72e11 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 06b707b..40701f0 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); - - 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"); - } - } - } - } + PluginLoader loader = + new PluginLoader (new InventoryDataInitialiser (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/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 1b73152..f8e77df 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); - - 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"); + PluginLoader loader = + new PluginLoader (new UserDataInitialiser (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/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 a9d0e33..00d290e 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 fabcbe2..0d4c555 100644 --- a/OpenSim/Framework/IInventoryData.cs +++ b/OpenSim/Framework/IInventoryData.cs @@ -33,7 +33,7 @@ namespace OpenSim.Framework /// /// An interface for accessing inventory data from a storage server /// - public interface IInventoryData + public interface IInventoryDataPlugin : IPlugin { /// /// Initialises the interface @@ -41,23 +41,6 @@ namespace OpenSim.Framework 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 5952713..27686c0 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 @@ -154,18 +154,6 @@ namespace OpenSim.Framework 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) /// void Initialise(string connect); @@ -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 616fa3e..3bc4de6 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(); } -- cgit v1.1