- 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
0.6.3-post-fixes
Mike Mazur 2009-02-03 05:20:44 +00:00
parent d3eae4073e
commit d259238c74
6 changed files with 185 additions and 74 deletions

View File

@ -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
{
/// <summary>
/// A static class containing a series of methods for obtaining handles to
/// database storage objects.
/// </summary>
// Yeah, it's not really a factory, but maybe it'll morph into one?
public static class DataPluginFactory
{
/// <summary>
/// Returns a list of new inventory data plugins. Plugins will be
/// requested in the order they were added.
/// </summary>
/// <param name="provider">
/// The filename of the inventory server plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public static List<IInventoryDataPlugin> LoadInventoryDataPlugins(string provider, string connect)
{
PluginLoader<IInventoryDataPlugin> loader = new PluginLoader<IInventoryDataPlugin> (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;
}
/// <summary>
/// Returns a list of new user data plugins. Plugins will be requested
/// in the order they were added.
/// </summary>
/// <param name="provider">
/// The filename of the user data plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public static List<IUserDataPlugin> LoadUserDataPlugins(string provider, string connect)
{
PluginLoader<IUserDataPlugin> loader = new PluginLoader<IUserDataPlugin>(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;
}
/// <summary>
/// Returns a list of new grid data plugins. Plugins will be requested
/// in the order they were added.
/// </summary>
/// <param name="provider">
/// The filename of the user data plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public static List<IGridDataPlugin> LoadGridDataPlugins(string provider, string connect)
{
PluginLoader<IGridDataPlugin> loader = new PluginLoader<IGridDataPlugin>(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;
}
/// <summary>
/// Returns a list of new log data plugins. Plugins will be requested
/// in the order they were added.
/// </summary>
/// <param name="provider">
/// The filename of the user data plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public static List<ILogDataPlugin> LoadLogDataPlugins(string provider, string connect)
{
PluginLoader<ILogDataPlugin> loader = new PluginLoader<ILogDataPlugin>(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<IAssetDataPlugin> loader = new PluginLoader<IAssetDataPlugin> (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;
}
}
}

View File

@ -59,20 +59,18 @@ namespace OpenSim.Framework.Communications
}
/// <summary>
/// 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'.
/// </summary>
/// <param name="provider">The filename of the inventory server plugin DLL</param>
/// <param name="provider">
/// The filename of the inventory server plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public void AddPlugin(string provider, string connect)
{
PluginLoader<IInventoryDataPlugin> loader =
new PluginLoader<IInventoryDataPlugin> (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

View File

@ -74,21 +74,18 @@ namespace OpenSim.Framework.Communications
}
/// <summary>
/// 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'.
/// </summary>
/// <param name="provider">The filename to the user data plugin DLL</param>
/// <param name="connect"></param>
/// <param name="provider">
/// The filename of the inventory server plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public void AddPlugin(string provider, string connect)
{
PluginLoader<IUserDataPlugin> loader =
new PluginLoader<IUserDataPlugin>(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

View File

@ -112,24 +112,11 @@ namespace OpenSim.Grid.AssetServer
return null;
}
public IAssetDataPlugin LoadDatabasePlugin(string provider, string connect)
{
PluginLoader<IAssetDataPlugin> loader =
new PluginLoader<IAssetDataPlugin> (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");

View File

@ -71,27 +71,20 @@ namespace OpenSim.Grid.GridServer
}
/// <summary>
/// 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.
/// </summary>
/// <param name="provider">The name of the grid server plugin DLL</param>
/// <param name="provider">
/// The filename of the inventory server plugin DLL.
/// </param>
/// <param name="connect">
/// The connection string for the storage backend.
/// </param>
public void AddPlugin(string provider, string connect)
{
PluginLoader<IGridDataPlugin> gridloader =
new PluginLoader<IGridDataPlugin> (new GridDataInitialiser (connect));
PluginLoader<ILogDataPlugin> logloader =
new PluginLoader<ILogDataPlugin> (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);
}
/// <summary>

View File

@ -1,10 +1,5 @@
<Addin id="OpenSim.Data" isroot="true" version="0.5">
<Runtime>
<Import assembly="OpenSim.Grid.UserServer.exe"/>
<Import assembly="OpenSim.Grid.GridServer.exe"/>
<Import assembly="OpenSim.Grid.AssetServer.exe"/>
<Import assembly="OpenSim.Grid.InventoryServer.exe"/>
<Import assembly="OpenSim.Grid.MessagingServer.exe"/>
<Import assembly="OpenSim.Data.dll" />
<Import assembly="OpenSim.Framework.dll" />
</Runtime>