From d259238c748aafe366fd1d04e0248ef23116fd28 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:44 +0000 Subject: - moved data plugin loading code from various places to OpenSim/Data/DataPluginFactory.cs - removed dependencies on a few executable assemblies in bin/OpenSim.Data.addin.xml - trim trailing whitespace --- OpenSim/Data/DataPluginFactory.cs | 141 +++++++++++++++++++++ .../Communications/InventoryServiceBase.cs | 20 ++- .../Framework/Communications/UserManagerBase.cs | 21 ++- OpenSim/Grid/AssetServer/Main.cs | 15 +-- OpenSim/Grid/GridServer/GridManager.cs | 43 +++---- bin/OpenSim.Data.addin.xml | 19 +-- 6 files changed, 185 insertions(+), 74 deletions(-) create mode 100644 OpenSim/Data/DataPluginFactory.cs diff --git a/OpenSim/Data/DataPluginFactory.cs b/OpenSim/Data/DataPluginFactory.cs new file mode 100644 index 0000000..5293e94 --- /dev/null +++ b/OpenSim/Data/DataPluginFactory.cs @@ -0,0 +1,141 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using OpenSim.Framework; + +namespace OpenSim.Data +{ + /// + /// A static class containing a series of methods for obtaining handles to + /// database storage objects. + /// + // Yeah, it's not really a factory, but maybe it'll morph into one? + public static class DataPluginFactory + { + /// + /// Returns a list of new inventory data plugins. Plugins will be + /// requested in the order they were added. + /// + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// + public static List LoadInventoryDataPlugins(string provider, string connect) + { + 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(); + + return loader.Plugins; + } + + /// + /// Returns a list of new user data plugins. Plugins will be requested + /// in the order they were added. + /// + /// + /// The filename of the user data plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// + public static List LoadUserDataPlugins(string provider, string connect) + { + 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(); + + return loader.Plugins; + } + + /// + /// Returns a list of new grid data plugins. Plugins will be requested + /// in the order they were added. + /// + /// + /// The filename of the user data plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// + public static List LoadGridDataPlugins(string provider, string connect) + { + PluginLoader loader = new PluginLoader(new GridDataInitialiser(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/GridData", new PluginProviderFilter(provider)); + loader.Load(); + + return loader.Plugins; + } + + /// + /// Returns a list of new log data plugins. Plugins will be requested + /// in the order they were added. + /// + /// + /// The filename of the user data plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// + public static List LoadLogDataPlugins(string provider, string connect) + { + PluginLoader loader = new PluginLoader(new LogDataInitialiser(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/LogData", new PluginProviderFilter(provider)); + loader.Load(); + + return loader.Plugins; + } + + public static IAssetDataPlugin LoadAssetDataPlugin(string provider, string connect) + { + PluginLoader loader = new PluginLoader (new AssetDataInitialiser (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(); + + return loader.Plugin; + } + + } +} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index ec5c493..a031bdf 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -59,20 +59,18 @@ namespace OpenSim.Framework.Communications } /// - /// Adds a new inventory data plugin - plugins will be requested in the order they were loaded. + /// Adds a list of inventory data plugins, as described by `provider' + /// and `connect', to `m_plugins'. /// - /// The filename of the inventory server plugin DLL + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// public void AddPlugin(string provider, string connect) { - 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.AddRange(loader.Plugins); + m_plugins.AddRange(DataPluginFactory.LoadInventoryDataPlugins(provider, connect)); } #endregion diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b12abb3..886900d 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -74,21 +74,18 @@ namespace OpenSim.Framework.Communications } /// - /// Add a new user data plugin - plugins will be requested in the order they were added. + /// Adds a list of user data plugins, as described by `provider' and + /// `connect', to `_plugins'. /// - /// The filename to the user data plugin DLL - /// + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// public void AddPlugin(string provider, string connect) { - 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.AddRange(loader.Plugins); + _plugins.AddRange(DataPluginFactory.LoadUserDataPlugins(provider, connect)); } #region Get UserProfile diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 07fe0a4..060c473 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -112,24 +112,11 @@ namespace OpenSim.Grid.AssetServer return null; } - public IAssetDataPlugin LoadDatabasePlugin(string provider, string connect) - { - PluginLoader loader = - new PluginLoader (new AssetDataInitialiser (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(); - - return loader.Plugin; - } - public void setupDB(AssetConfig config) { try { - m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider, config.DatabaseConnect); + m_assetProvider = DataPluginFactory.LoadAssetDataPlugin(config.DatabaseProvider, config.DatabaseConnect); if (m_assetProvider == null) { m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index daee729..3fc0393 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -53,12 +53,12 @@ namespace OpenSim.Grid.GridServer private List _MessageServers = new List(); public GridConfig Config; - + /// /// Used to notify old regions as to which OpenSim version to upgrade to /// private string m_opensimVersion; - + /// /// Constructor /// @@ -71,27 +71,20 @@ namespace OpenSim.Grid.GridServer } /// - /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. + /// Adds a list of grid and log data plugins, as described by + /// `provider' and `connect', to `_plugins' and `_logplugins', + /// respectively. /// - /// The name of the grid server plugin DLL + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// public void AddPlugin(string provider, string connect) { - PluginLoader gridloader = - new PluginLoader (new GridDataInitialiser (connect)); - - PluginLoader logloader = - new PluginLoader (new LogDataInitialiser (connect)); - - // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.xml - gridloader.Add ("/OpenSim/GridData", new PluginProviderFilter (provider)); - logloader.Add ("/OpenSim/LogData", new PluginProviderFilter (provider)); - - gridloader.Load(); - logloader.Load(); - - _plugins = gridloader.Plugins; - _logplugins = logloader.Plugins; + _plugins = DataPluginFactory.LoadGridDataPlugins(provider, connect); + _logplugins = DataPluginFactory.LoadLogDataPlugins(provider, connect); } /// @@ -389,8 +382,8 @@ namespace OpenSim.Grid.GridServer m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString()); } - - m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); + + m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); if (!Config.AllowRegionRegistration) { @@ -399,12 +392,12 @@ namespace OpenSim.Grid.GridServer sim.regionName); return ErrorResponse("This grid is currently not accepting region registrations."); - } - + } + int majorInterfaceVersion = 0; if (requestData.ContainsKey("major_interface_version")) int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); - + if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) { return ErrorResponse( diff --git a/bin/OpenSim.Data.addin.xml b/bin/OpenSim.Data.addin.xml index 2a3db5f..65774ff 100644 --- a/bin/OpenSim.Data.addin.xml +++ b/bin/OpenSim.Data.addin.xml @@ -1,26 +1,21 @@ - - - - - - - + + - + - + - + - + - + -- cgit v1.1