Thanks, sempuki, for a patch that moves all Grid Server's plugins to

PluginLoader. Fix issue 1871.
0.6.0-stable
Mike Mazur 2008-07-31 09:24:28 +00:00
parent fcab0ecfba
commit 2270b25265
33 changed files with 354 additions and 279 deletions

View File

@ -30,7 +30,7 @@ using OpenSim.Framework;
namespace OpenSim.Data namespace OpenSim.Data
{ {
public abstract class AssetDataBase : IAssetProvider public abstract class AssetDataBase : IAssetProviderPlugin
{ {
public abstract AssetBase FetchAsset(LLUUID uuid); public abstract AssetBase FetchAsset(LLUUID uuid);
public abstract void CreateAsset(AssetBase asset); public abstract void CreateAsset(AssetBase asset);

View File

@ -45,7 +45,7 @@ namespace OpenSim.Data.MSSQL
private MSSQLManager database; private MSSQLManager database;
#region IAssetProvider Members #region IAssetProviderPlugin Members
/// <summary> /// <summary>
/// Migration method /// Migration method

View File

@ -39,7 +39,7 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// A MSSQL interface for the inventory server /// A MSSQL interface for the inventory server
/// </summary> /// </summary>
public class MSSQLInventoryData : IInventoryData public class MSSQLInventoryData : IInventoryDataPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -59,6 +59,12 @@ namespace OpenSim.Data.MSSQL
/// </summary> /// </summary>
private MSSQLManager database; private MSSQLManager database;
public void Initialise()
{
m_log.Info("[MSSQLInventoryData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// Loads and initialises the MSSQL inventory storage interface /// Loads and initialises the MSSQL inventory storage interface
/// </summary> /// </summary>
@ -134,15 +140,15 @@ namespace OpenSim.Data.MSSQL
/// The name of this DB provider /// The name of this DB provider
/// </summary> /// </summary>
/// <returns>A string containing the name of the DB provider</returns> /// <returns>A string containing the name of the DB provider</returns>
public string getName() public string Name
{ {
return "MSSQL Inventory Data Interface"; get { return "MSSQL Inventory Data Interface"; }
} }
/// <summary> /// <summary>
/// Closes this DB provider /// Closes this DB provider
/// </summary> /// </summary>
public void Close() public void Dispose()
{ {
// Do nothing. // Do nothing.
} }
@ -151,9 +157,9 @@ namespace OpenSim.Data.MSSQL
/// Returns the version of this DB provider /// Returns the version of this DB provider
/// </summary> /// </summary>
/// <returns>A string containing the DB provider</returns> /// <returns>A string containing the DB provider</returns>
public string getVersion() public string Version
{ {
return database.getVersion(); get { return database.getVersion(); }
} }
/// <summary> /// <summary>
@ -681,7 +687,7 @@ namespace OpenSim.Data.MSSQL
folders.Add(f); folders.Add(f);
} }
// See IInventoryData // See IInventoryDataPlugin
public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
{ {
List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); List<InventoryFolderBase> folders = new List<InventoryFolderBase>();

View File

@ -52,6 +52,12 @@ namespace OpenSim.Data.MSSQL
private string m_usersTableName; private string m_usersTableName;
private string m_userFriendsTableName; private string m_userFriendsTableName;
public override void Initialise()
{
m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// Loads and initialises the MSSQL storage plugin /// Loads and initialises the MSSQL storage plugin
/// </summary> /// </summary>
@ -93,6 +99,8 @@ namespace OpenSim.Data.MSSQL
TestTables(); TestTables();
} }
public override void Dispose () {}
/// <summary> /// <summary>
/// ///

View File

@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL
override public void Dispose() { } override public void Dispose() { }
#region IAssetProvider Members #region IAssetProviderPlugin Members
/// <summary> /// <summary>
/// <list type="bullet"> /// <list type="bullet">

View File

@ -51,7 +51,7 @@ namespace OpenSim.Data.MySQL
override public void Initialise() 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); throw new PluginNotInitialisedException (Name);
} }

View File

@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL
/// <summary> /// <summary>
/// A MySQL interface for the inventory server /// A MySQL interface for the inventory server
/// </summary> /// </summary>
public class MySQLInventoryData : IInventoryData public class MySQLInventoryData : IInventoryDataPlugin
{ {
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -48,6 +48,12 @@ namespace OpenSim.Data.MySQL
/// </summary> /// </summary>
private MySQLManager database; private MySQLManager database;
public void Initialise()
{
m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// <para>Initialises Inventory interface</para> /// <para>Initialises Inventory interface</para>
/// <para> /// <para>
@ -183,16 +189,16 @@ namespace OpenSim.Data.MySQL
/// The name of this DB provider /// The name of this DB provider
/// </summary> /// </summary>
/// <returns>Name of DB provider</returns> /// <returns>Name of DB provider</returns>
public string getName() public string Name
{ {
return "MySQL Inventory Data Interface"; get { return "MySQL Inventory Data Interface"; }
} }
/// <summary> /// <summary>
/// Closes this DB provider /// Closes this DB provider
/// </summary> /// </summary>
/// <remarks>do nothing</remarks> /// <remarks>do nothing</remarks>
public void Close() public void Dispose()
{ {
// Do nothing. // Do nothing.
} }
@ -201,9 +207,9 @@ namespace OpenSim.Data.MySQL
/// Returns the version of this DB provider /// Returns the version of this DB provider
/// </summary> /// </summary>
/// <returns>A string containing the DB provider version</returns> /// <returns>A string containing the DB provider version</returns>
public string getVersion() public string Version
{ {
return database.getVersion(); get { return database.getVersion(); }
} }
/// <summary> /// <summary>
@ -692,7 +698,7 @@ namespace OpenSim.Data.MySQL
/// <summary> /// <summary>
/// See IInventoryData /// See IInventoryDataPlugin
/// </summary> /// </summary>
/// <param name="parentID"></param> /// <param name="parentID"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -55,6 +55,12 @@ namespace OpenSim.Data.MySQL
private string m_appearanceTableName = "avatarappearance"; private string m_appearanceTableName = "avatarappearance";
private string m_connectString; private string m_connectString;
public override void Initialise()
{
m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// Initialise User Interface /// Initialise User Interface
/// Loads and initialises the MySQL storage plugin /// Loads and initialises the MySQL storage plugin
@ -120,6 +126,9 @@ namespace OpenSim.Data.MySQL
m.Update(); m.Update();
} }
public override void Dispose () { }
#region Test and initialization code #region Test and initialization code
/// <summary> /// <summary>
@ -252,7 +261,7 @@ namespace OpenSim.Data.MySQL
UserProfileData row = database.readUserRow(reader); UserProfileData row = database.readUserRow(reader);
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
return row; return row;
} }
@ -398,7 +407,7 @@ namespace OpenSim.Data.MySQL
Lfli.Add(fli); Lfli.Add(fli);
} }
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
} }
} }
@ -450,7 +459,7 @@ namespace OpenSim.Data.MySQL
user.lastName = (string) reader["lastname"]; user.lastName = (string) reader["lastname"];
returnlist.Add(user); returnlist.Add(user);
} }
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
} }
} }
@ -484,7 +493,7 @@ namespace OpenSim.Data.MySQL
user.lastName = (string) reader["lastname"]; user.lastName = (string) reader["lastname"];
returnlist.Add(user); returnlist.Add(user);
} }
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
} }
} }
@ -517,7 +526,7 @@ namespace OpenSim.Data.MySQL
UserProfileData row = database.readUserRow(reader); UserProfileData row = database.readUserRow(reader);
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
return row; return row;
@ -603,7 +612,7 @@ namespace OpenSim.Data.MySQL
UserAgentData row = database.readAgentRow(reader); UserAgentData row = database.readAgentRow(reader);
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
return row; return row;
@ -725,7 +734,7 @@ namespace OpenSim.Data.MySQL
AvatarAppearance appearance = database.readAppearanceRow(reader); AvatarAppearance appearance = database.readAppearanceRow(reader);
reader.Close(); reader.Dispose();
result.Dispose(); result.Dispose();
return appearance; return appearance;

View File

@ -42,7 +42,7 @@ using Environment=NHibernate.Cfg.Environment;
namespace OpenSim.Data.NHibernate namespace OpenSim.Data.NHibernate
{ {
public class NHibernateInventoryData: IInventoryData public class NHibernateInventoryData: IInventoryDataPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -50,6 +50,12 @@ namespace OpenSim.Data.NHibernate
private ISessionFactory factory; private ISessionFactory factory;
private ISession session; private ISession session;
public void Initialise()
{
m_log.Info("[NHibernateInventoryData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// Initialises the interface /// Initialises the interface
/// </summary> /// </summary>
@ -257,7 +263,7 @@ namespace OpenSim.Data.NHibernate
/// <summary> /// <summary>
/// Closes the interface /// Closes the interface
/// </summary> /// </summary>
public void Close() public void Dispose()
{ {
} }
@ -265,25 +271,28 @@ namespace OpenSim.Data.NHibernate
/// The plugin being loaded /// The plugin being loaded
/// </summary> /// </summary>
/// <returns>A string containing the plugin name</returns> /// <returns>A string containing the plugin name</returns>
public string getName() public string Name
{ {
return "NHibernate Inventory Data Interface"; get { return "NHibernate Inventory Data Interface"; }
} }
/// <summary> /// <summary>
/// The plugins version /// The plugins version
/// </summary> /// </summary>
/// <returns>A string containing the plugin version</returns> /// <returns>A string containing the plugin version</returns>
public string getVersion() public string Version
{ {
Module module = GetType().Module; get
// string dllName = module.Assembly.ManifestModule.Name; {
Version dllVersion = module.Assembly.GetName().Version; Module module = GetType().Module;
// string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision); dllVersion.Revision);
}
} }
// Move seems to be just update // Move seems to be just update
@ -369,7 +378,7 @@ namespace OpenSim.Data.NHibernate
return folders; return folders;
} }
// See IInventoryData // See IInventoryDataPlugin
public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
{ {
List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); List<InventoryFolderBase> folders = new List<InventoryFolderBase>();

View File

@ -53,6 +53,12 @@ namespace OpenSim.Data.NHibernate
private ISessionFactory factory; private ISessionFactory factory;
private ISession session; 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) public override void Initialise(string connect)
{ {
char[] split = {';'}; char[] split = {';'};
@ -320,7 +326,7 @@ namespace OpenSim.Data.NHibernate
get { return "0.1"; } get { return "0.1"; }
} }
public void Dispose() public override void Dispose()
{ {
} }

View File

@ -39,7 +39,7 @@ namespace OpenSim.Data.SQLite
/// <summary> /// <summary>
/// An Inventory Interface to the SQLite database /// An Inventory Interface to the SQLite database
/// </summary> /// </summary>
public class SQLiteInventoryStore : SQLiteUtil, IInventoryData public class SQLiteInventoryStore : SQLiteUtil, IInventoryDataPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -50,6 +50,12 @@ namespace OpenSim.Data.SQLite
private SqliteDataAdapter invItemsDa; private SqliteDataAdapter invItemsDa;
private SqliteDataAdapter invFoldersDa; private SqliteDataAdapter invFoldersDa;
public void Initialise()
{
m_log.Info("[SQLiteInventoryData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// <list type="bullet"> /// <list type="bullet">
/// <item>Initialises Inventory interface</item> /// <item>Initialises Inventory interface</item>
@ -277,7 +283,7 @@ namespace OpenSim.Data.SQLite
/// <summary> /// <summary>
/// Closes the inventory interface /// Closes the inventory interface
/// </summary> /// </summary>
public void Close() public void Dispose()
{ {
} }
@ -285,25 +291,28 @@ namespace OpenSim.Data.SQLite
/// The name of this DB provider /// The name of this DB provider
/// </summary> /// </summary>
/// <returns>Name of DB provider</returns> /// <returns>Name of DB provider</returns>
public string getName() public string Name
{ {
return "SQLite Inventory Data Interface"; get { return "SQLite Inventory Data Interface"; }
} }
/// <summary> /// <summary>
/// Returns the version of this DB provider /// Returns the version of this DB provider
/// </summary> /// </summary>
/// <returns>A string containing the DB provider version</returns> /// <returns>A string containing the DB provider version</returns>
public string getVersion() public string Version
{ {
Module module = GetType().Module; get
// string dllName = module.Assembly.ManifestModule.Name; {
Version dllVersion = module.Assembly.GetName().Version; Module module = GetType().Module;
// string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision); dllVersion.Revision);
}
} }
/// <summary> /// <summary>
@ -399,7 +408,7 @@ namespace OpenSim.Data.SQLite
} }
/// <summary> /// <summary>
/// See IInventoryData /// See IInventoryDataPlugin
/// </summary> /// </summary>
/// <param name="parentID"></param> /// <param name="parentID"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -65,6 +65,12 @@ namespace OpenSim.Data.SQLite
private SqliteDataAdapter daf; private SqliteDataAdapter daf;
SqliteConnection g_conn; SqliteConnection g_conn;
public override void Initialise()
{
m_log.Info("[SQLiteUserData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary> /// <summary>
/// <list type="bullet"> /// <list type="bullet">
/// <item>Initialises User Interface</item> /// <item>Initialises User Interface</item>
@ -124,6 +130,8 @@ namespace OpenSim.Data.SQLite
return; return;
} }
public override void Dispose () {}
/// <summary> /// <summary>
/// see IUserData, /// see IUserData,
/// Get user data profile by UUID /// Get user data profile by UUID

View File

@ -55,9 +55,6 @@ namespace OpenSim.Data
public abstract List<FriendListItem> GetUserFriendList(LLUUID friendlistowner); public abstract List<FriendListItem> GetUserFriendList(LLUUID friendlistowner);
public abstract bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount); public abstract bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount);
public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); 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<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); public abstract List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
public abstract AvatarAppearance GetUserAppearance(LLUUID user); public abstract AvatarAppearance GetUserAppearance(LLUUID user);
public abstract void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); 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 AddAttachment(LLUUID user, LLUUID item);
public abstract void RemoveAttachment(LLUUID user, LLUUID item); public abstract void RemoveAttachment(LLUUID user, LLUUID item);
public abstract List<LLUUID> GetAttachments(LLUUID user); public abstract List<LLUUID> 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();
} }
} }

View File

@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache
protected IAssetReceiver m_receiver; protected IAssetReceiver m_receiver;
protected BlockingQueue<AssetRequest> m_assetRequests; protected BlockingQueue<AssetRequest> m_assetRequests;
protected Thread m_localAssetServerThread; protected Thread m_localAssetServerThread;
protected IAssetProvider m_assetProvider; protected IAssetProviderPlugin m_assetProvider;
// Temporarily hardcoded - should be a plugin // Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); protected IAssetLoader assetLoader = new AssetLoaderFileSystem();

View File

@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
AddPlugin(pluginName, connect); AddPlugin(pluginName, connect);
} }
public SQLAssetServer(IAssetProvider assetProvider) public SQLAssetServer(IAssetProviderPlugin assetProvider)
{ {
m_assetProvider = assetProvider; m_assetProvider = assetProvider;
} }
@ -54,12 +54,12 @@ namespace OpenSim.Framework.Communications.Cache
{ {
if (!pluginType.IsAbstract) if (!pluginType.IsAbstract)
{ {
Type typeInterface = pluginType.GetInterface("IAssetProvider", true); Type typeInterface = pluginType.GetInterface("IAssetProviderPlugin", true);
if (typeInterface != null) if (typeInterface != null)
{ {
IAssetProvider plug = IAssetProviderPlugin plug =
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); (IAssetProviderPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
m_assetProvider = plug; m_assetProvider = plug;
m_assetProvider.Initialise(connect); m_assetProvider.Initialise(connect);

View File

@ -43,38 +43,25 @@ namespace OpenSim.Framework.Communications
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>(); protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>();
#region Plugin methods #region Plugin methods
/// <summary> /// <summary>
/// Adds a new user server plugin - plugins will be requested in the order they were loaded. /// Adds a new user server plugin - plugins will be requested in the order they were loaded.
/// </summary> /// </summary>
/// <param name="FileName">The filename to the user server plugin DLL</param> /// <param name="provider">The filename to the user server plugin DLL</param>
public void AddPlugin(string FileName, string connect) public void AddPlugin(string provider, string connect)
{ {
if (!String.IsNullOrEmpty(FileName)) PluginLoader<IInventoryDataPlugin> loader =
{ new PluginLoader<IInventoryDataPlugin> (new InventoryDataInitialiser (connect));
m_log.Info("[AGENT INVENTORY]: Inventory storage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes()) // loader will try to load all providers (MySQL, MSSQL, etc)
{ // unless it is constrainted to the correct "Provider" entry in the addin.xml
if (!pluginType.IsAbstract) loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider));
{ loader.Load();
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
m_plugins = loader.Plugins;
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");
}
}
}
}
} }
#endregion #endregion
@ -103,9 +90,9 @@ namespace OpenSim.Framework.Communications
userFolders.Add(rootFolder); userFolders.Add(rootFolder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.ID); IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID);
userFolders.AddRange(folders); userFolders.AddRange(folders);
} }
@ -127,9 +114,9 @@ namespace OpenSim.Framework.Communications
public InventoryFolderBase RequestRootFolder(LLUUID userID) public InventoryFolderBase RequestRootFolder(LLUUID userID)
{ {
// FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
return plugin.Value.getUserRootFolder(userID); return plugin.getUserRootFolder(userID);
} }
return null; return null;
} }
@ -168,9 +155,9 @@ namespace OpenSim.Framework.Communications
public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID) public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
{ {
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
return plugin.Value.getInventoryFolders(parentFolderID); return plugin.getInventoryFolders(parentFolderID);
} }
return inventoryList; return inventoryList;
} }
@ -178,9 +165,9 @@ namespace OpenSim.Framework.Communications
public List<InventoryItemBase> RequestFolderItems(LLUUID folderID) public List<InventoryItemBase> RequestFolderItems(LLUUID folderID)
{ {
List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
itemsList = plugin.Value.getInventoryInFolder(folderID); itemsList = plugin.getInventoryInFolder(folderID);
return itemsList; return itemsList;
} }
return itemsList; return itemsList;
@ -194,9 +181,9 @@ namespace OpenSim.Framework.Communications
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.addInventoryFolder(folder); plugin.addInventoryFolder(folder);
} }
// FIXME: Should return false on failure // FIXME: Should return false on failure
@ -209,9 +196,9 @@ namespace OpenSim.Framework.Communications
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.updateInventoryFolder(folder); plugin.updateInventoryFolder(folder);
} }
// FIXME: Should return false on failure // FIXME: Should return false on failure
@ -224,9 +211,9 @@ namespace OpenSim.Framework.Communications
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.moveInventoryFolder(folder); plugin.moveInventoryFolder(folder);
} }
// FIXME: Should return false on failure // FIXME: Should return false on failure
@ -239,9 +226,9 @@ namespace OpenSim.Framework.Communications
m_log.DebugFormat( m_log.DebugFormat(
"[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.addInventoryItem(item); plugin.addInventoryItem(item);
} }
// FIXME: Should return false on failure // FIXME: Should return false on failure
@ -254,9 +241,9 @@ namespace OpenSim.Framework.Communications
m_log.InfoFormat( m_log.InfoFormat(
"[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.updateInventoryItem(item); plugin.updateInventoryItem(item);
} }
// FIXME: Should return false on failure // FIXME: Should return false on failure
@ -269,9 +256,9 @@ namespace OpenSim.Framework.Communications
m_log.InfoFormat( m_log.InfoFormat(
"[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> 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 // 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); // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (IInventoryDataPlugin plugin in m_plugins)
{ {
plugin.Value.deleteInventoryFolder(subFolder.ID); plugin.deleteInventoryFolder(subFolder.ID);
} }
} }

View File

@ -47,42 +47,23 @@ namespace OpenSim.Framework.Communications
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public UserConfig _config; public UserConfig _config;
private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>(); private List<IUserData> _plugins = new List<IUserData>();
/// <summary> /// <summary>
/// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
/// </summary> /// </summary>
/// <param name="FileName">The filename to the user server plugin DLL</param> /// <param name="provider">The filename to the user server plugin DLL</param>
public void AddPlugin(string FileName, string connect) public void AddPlugin(string provider, string connect)
{ {
if (!String.IsNullOrEmpty(FileName)) PluginLoader<IUserData> loader =
{ new PluginLoader<IUserData> (new UserDataInitialiser (connect));
m_log.Info("[USERSTORAGE]: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
m_log.Info("[USERSTORAGE]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); // loader will try to load all providers (MySQL, MSSQL, etc)
foreach (Type pluginType in pluginAssembly.GetTypes()) // unless it is constrainted to the correct "Provider" entry in the addin.xml
{ loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider));
if (!pluginType.IsAbstract) loader.Load();
{
Type typeInterface = pluginType.GetInterface("IUserData", true); _plugins = loader.Plugins;
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");
} }
#region Get UserProfile #region Get UserProfile
@ -90,9 +71,9 @@ namespace OpenSim.Framework.Communications
// see IUserService // see IUserService
public UserProfileData GetUserProfile(string fname, string lname) public UserProfileData GetUserProfile(string fname, string lname)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
UserProfileData profile = plugin.Value.GetUserByName(fname, lname); UserProfileData profile = plugin.GetUserByName(fname, lname);
if (profile != null) if (profile != null)
{ {
@ -105,9 +86,9 @@ namespace OpenSim.Framework.Communications
} }
public UserAgentData GetAgentByUUID(LLUUID userId) public UserAgentData GetAgentByUUID(LLUUID userId)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
UserAgentData agent = plugin.Value.GetAgentByUUID(userId); UserAgentData agent = plugin.GetAgentByUUID(userId);
if (agent != null) if (agent != null)
{ {
@ -120,9 +101,9 @@ namespace OpenSim.Framework.Communications
// see IUserService // see IUserService
public UserProfileData GetUserProfile(LLUUID uuid) public UserProfileData GetUserProfile(LLUUID uuid)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
UserProfileData profile = plugin.Value.GetUserByUUID(uuid); UserProfileData profile = plugin.GetUserByUUID(uuid);
if (null != profile) if (null != profile)
{ {
@ -137,15 +118,15 @@ namespace OpenSim.Framework.Communications
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query) public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{ {
List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
pickerlist = plugin.Value.GeneratePickerResults(queryID, query); pickerlist = plugin.GeneratePickerResults(queryID, query);
} }
catch (Exception) 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<AvatarPickerAvatar>(); return new List<AvatarPickerAvatar>();
} }
} }
@ -159,17 +140,17 @@ namespace OpenSim.Framework.Communications
/// <returns></returns> /// <returns></returns>
public bool UpdateUserProfile(UserProfileData data) public bool UpdateUserProfile(UserProfileData data)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.UpdateUserProfile(data); plugin.UpdateUserProfile(data);
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, 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; return false;
@ -186,15 +167,15 @@ namespace OpenSim.Framework.Communications
/// <returns>Agent profiles</returns> /// <returns>Agent profiles</returns>
public UserAgentData GetUserAgent(LLUUID uuid) public UserAgentData GetUserAgent(LLUUID uuid)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetAgentByUUID(uuid); return plugin.GetAgentByUUID(uuid);
} }
catch (Exception e) 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
/// <returns>A user agent</returns> /// <returns>A user agent</returns>
public UserAgentData GetUserAgent(string name) public UserAgentData GetUserAgent(string name)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetAgentByName(name); return plugin.GetAgentByName(name);
} }
catch (Exception e) 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
/// <returns>A user agent</returns> /// <returns>A user agent</returns>
public UserAgentData GetUserAgent(string fname, string lname) public UserAgentData GetUserAgent(string fname, string lname)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetAgentByName(fname, lname); return plugin.GetAgentByName(fname, lname);
} }
catch (Exception e) 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) public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); plugin.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle);
} }
catch (Exception e) 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
/// <returns>A List of FriendListItems that contains info about the user's friends</returns> /// <returns>A List of FriendListItems that contains info about the user's friends</returns>
public List<FriendListItem> GetUserFriendList(LLUUID ownerID) public List<FriendListItem> GetUserFriendList(LLUUID ownerID)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetUserFriendList(ownerID); return plugin.GetUserFriendList(ownerID);
} }
catch (Exception e) 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) public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.StoreWebLoginKey(agentID, webLoginKey); plugin.StoreWebLoginKey(agentID, webLoginKey);
} }
catch (Exception e) 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) public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.AddNewUserFriend(friendlistowner,friend,perms); plugin.AddNewUserFriend(friendlistowner,friend,perms);
} }
catch (Exception e) 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) public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.RemoveUserFriend(friendlistowner, friend); plugin.RemoveUserFriend(friendlistowner, friend);
} }
catch (Exception e) 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) public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.UpdateUserFriendPerms(friendlistowner, friend, perms); plugin.UpdateUserFriendPerms(friendlistowner, friend, perms);
} }
catch (Exception e) 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.HomeRegionX = regX;
user.HomeRegionY = regY; user.HomeRegionY = regY;
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.AddNewUserProfile(user); plugin.AddNewUserProfile(user);
} }
catch (Exception e) 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()); m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString());
return false; return false;
} }
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.UpdateUserProfile(UserProfile); plugin.UpdateUserProfile(UserProfile);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString()
+ " via " + plugin.Key + "(" + e.ToString() + ")"); + " via " + plugin.Name + "(" + e.ToString() + ")");
return false; return false;
} }
} }
@ -612,16 +593,16 @@ namespace OpenSim.Framework.Communications
/// <param name="agentdata">The agent data to be added</param> /// <param name="agentdata">The agent data to be added</param>
public bool AddUserAgent(UserAgentData agentdata) public bool AddUserAgent(UserAgentData agentdata)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.AddNewUserAgent(agentdata); plugin.AddNewUserAgent(agentdata);
return true; return true;
} }
catch (Exception e) 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; return false;
@ -631,15 +612,15 @@ namespace OpenSim.Framework.Communications
/// TODO: stubs for now to get us to a compiling state gently /// TODO: stubs for now to get us to a compiling state gently
public AvatarAppearance GetUserAppearance(LLUUID user) public AvatarAppearance GetUserAppearance(LLUUID user)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetUserAppearance(user); return plugin.GetUserAppearance(user);
} }
catch (Exception e) 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; return null;
@ -647,60 +628,60 @@ namespace OpenSim.Framework.Communications
public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.UpdateUserAppearance(user, appearance); plugin.UpdateUserAppearance(user, appearance);
} }
catch (Exception e) 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) public void AddAttachment(LLUUID user, LLUUID item)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.AddAttachment(user, item); plugin.AddAttachment(user, item);
} }
catch (Exception e) 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) public void RemoveAttachment(LLUUID user, LLUUID item)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
plugin.Value.RemoveAttachment(user, item); plugin.RemoveAttachment(user, item);
} }
catch (Exception e) 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<LLUUID> GetAttachments(LLUUID user) public List<LLUUID> GetAttachments(LLUUID user)
{ {
foreach (KeyValuePair<string, IUserData> plugin in _plugins) foreach (IUserData plugin in _plugins)
{ {
try try
{ {
return plugin.Value.GetAttachments(user); return plugin.GetAttachments(user);
} }
catch (Exception e) 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<LLUUID>(); return new List<LLUUID>();

View File

@ -29,7 +29,7 @@ using libsecondlife;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public interface IAssetProvider : IPlugin public interface IAssetProviderPlugin : IPlugin
{ {
AssetBase FetchAsset(LLUUID uuid); AssetBase FetchAsset(LLUUID uuid);
void CreateAsset(AssetBase asset); void CreateAsset(AssetBase asset);
@ -37,4 +37,15 @@ namespace OpenSim.Framework
bool ExistsAsset(LLUUID uuid); bool ExistsAsset(LLUUID uuid);
void Initialise(string connect); 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);
}
}
} }

View File

@ -33,30 +33,13 @@ namespace OpenSim.Framework
/// <summary> /// <summary>
/// An interface for accessing inventory data from a storage server /// An interface for accessing inventory data from a storage server
/// </summary> /// </summary>
public interface IInventoryData public interface IInventoryDataPlugin : IPlugin
{ {
/// <summary> /// <summary>
/// Initialises the interface /// Initialises the interface
/// </summary> /// </summary>
void Initialise(string connect); void Initialise(string connect);
/// <summary>
/// Closes the interface
/// </summary>
void Close();
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
string getName();
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
string getVersion();
/// <summary> /// <summary>
/// Returns all child folders in the hierarchy from the parent folder and down. /// Returns all child folders in the hierarchy from the parent folder and down.
/// Does not return the parent folder itself. /// Does not return the parent folder itself.
@ -149,4 +132,15 @@ namespace OpenSim.Framework
/// <param name="folder">The id of the folder</param> /// <param name="folder">The id of the folder</param>
void deleteInventoryFolder(LLUUID folder); void deleteInventoryFolder(LLUUID folder);
} }
}
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);
}
}
}

View File

@ -33,7 +33,7 @@ namespace OpenSim.Framework
/// <summary> /// <summary>
/// An interface for connecting to user storage servers. /// An interface for connecting to user storage servers.
/// </summary> /// </summary>
public interface IUserData public interface IUserData : IPlugin
{ {
/// <summary> /// <summary>
/// Returns a user profile from a database via their UUID /// Returns a user profile from a database via their UUID
@ -153,18 +153,6 @@ namespace OpenSim.Framework
/// <returns>Successful?</returns> /// <returns>Successful?</returns>
bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory);
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
string Version {get;}
/// <summary>
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name, eg MySQL User Provider</returns>
string Name {get;}
/// <summary> /// <summary>
/// Initialises the plugin (artificial constructor) /// Initialises the plugin (artificial constructor)
/// </summary> /// </summary>
@ -182,4 +170,15 @@ namespace OpenSim.Framework
void RemoveAttachment(LLUUID user, LLUUID item); void RemoveAttachment(LLUUID user, LLUUID item);
List<LLUUID> GetAttachments(LLUUID user); List<LLUUID> GetAttachments(LLUUID user);
} }
}
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);
}
}
}

View File

@ -96,6 +96,11 @@ namespace OpenSim.Framework
get { return loaded; } get { return loaded; }
} }
public T Plugin
{
get { return (loaded.Count == 1)? loaded [0] : default (T); }
}
public PluginLoader () public PluginLoader ()
{ {
Initialiser = new PluginInitialiserBase(); Initialiser = new PluginInitialiserBase();
@ -114,11 +119,26 @@ namespace OpenSim.Framework
initialise_plugin_dir_ (dir); initialise_plugin_dir_ (dir);
} }
public void AddExtensionPoint (string extpoint) public void Add (string extpoint)
{ {
if (extpoints.Contains (extpoint))
return;
extpoints.Add (extpoint); 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) public void AddConstraint (string extpoint, IPluginConstraint cons)
{ {
constraints.Add (extpoint, cons); constraints.Add (extpoint, cons);
@ -131,7 +151,7 @@ namespace OpenSim.Framework
public void Load (string extpoint) public void Load (string extpoint)
{ {
AddExtensionPoint (extpoint); Add (extpoint);
Load(); Load();
} }

View File

@ -53,7 +53,7 @@ namespace OpenSim.Grid.AssetServer
// Temporarily hardcoded - should be a plugin // Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
private IAssetProvider m_assetProvider; private IAssetProviderPlugin m_assetProvider;
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
@ -116,36 +116,19 @@ namespace OpenSim.Grid.AssetServer
return null; 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); PluginLoader<IAssetProviderPlugin> loader =
Assembly pluginAssembly = Assembly.LoadFrom(FileName); new PluginLoader<IAssetProviderPlugin> (new AssetDataInitialiser (connect));
IAssetProvider assetPlugin = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IAssetProvider", true);
if (typeInterface != null) // loader will try to load all providers (MySQL, MSSQL, etc)
{ // unless it is constrainted to the correct "Provider" entry in the addin.xml
IAssetProvider plug = loader.Add ("/OpenSim/AssetData", new PluginProviderFilter (provider));
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); loader.Load();
assetPlugin = plug;
assetPlugin.Initialise(connect);
m_log.Info("[ASSET SERVER]: Added " + assetPlugin.Name + " " + assetPlugin.Version); return loader.Plugin;
break;
}
typeInterface = null;
}
}
pluginAssembly = null;
return assetPlugin;
} }
public void setupDB(AssetConfig config) public void setupDB(AssetConfig config)
{ {
try try

View File

@ -45,14 +45,14 @@ namespace OpenSim.Grid.AssetServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private OpenAsset_Main m_assetManager; // private OpenAsset_Main m_assetManager;
private IAssetProvider m_assetProvider; private IAssetProviderPlugin m_assetProvider;
/// <summary> /// <summary>
/// Constructor. /// Constructor.
/// </summary> /// </summary>
/// <param name="assetManager"></param> /// <param name="assetManager"></param>
/// <param name="assetProvider"></param> /// <param name="assetProvider"></param>
public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProviderPlugin assetProvider)
: base("GET", "/assets") : base("GET", "/assets")
{ {
m_log.Info("[REST]: In Get Request"); 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 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private OpenAsset_Main m_assetManager; // private OpenAsset_Main m_assetManager;
private IAssetProvider m_assetProvider; private IAssetProviderPlugin m_assetProvider;
public override byte[] Handle(string path, Stream request, public override byte[] Handle(string path, Stream request,
OSHttpRequest httpRequest, OSHttpResponse httpResponse) OSHttpRequest httpRequest, OSHttpResponse httpResponse)
@ -142,7 +142,7 @@ namespace OpenSim.Grid.AssetServer
return new byte[] {}; return new byte[] {};
} }
public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProviderPlugin assetProvider)
: base("POST", "/assets") : base("POST", "/assets")
{ {
// m_assetManager = assetManager; // m_assetManager = assetManager;

View File

@ -67,13 +67,10 @@ namespace OpenSim.Grid.GridServer
PluginLoader<ILogDataPlugin> logloader = PluginLoader<ILogDataPlugin> logloader =
new PluginLoader<ILogDataPlugin> (new LogDataInitialiser (connect)); new PluginLoader<ILogDataPlugin> (new LogDataInitialiser (connect));
gridloader.AddExtensionPoint ("/OpenSim/GridData");
logloader.AddExtensionPoint ("/OpenSim/LogData");
// loader will try to load all providers (MySQL, MSSQL, etc) // loader will try to load all providers (MySQL, MSSQL, etc)
// unless it is constrainted to the correct "Provider" entry in the addin.xml // unless it is constrainted to the correct "Provider" entry in the addin.xml
gridloader.AddFilter ("/OpenSim/GridData", new PluginProviderFilter (provider)); gridloader.Add ("/OpenSim/GridData", new PluginProviderFilter (provider));
logloader.AddFilter ("/OpenSim/LogData", new PluginProviderFilter (provider)); logloader.Add ("/OpenSim/LogData", new PluginProviderFilter (provider));
gridloader.Load(); gridloader.Load();
logloader.Load(); logloader.Load();

View File

@ -42,7 +42,7 @@ namespace OpenSim.Test.Inventory
[TestFixture] [TestFixture]
public class TestInventory public class TestInventory
{ {
IInventoryData _dbPlugin; IInventoryDataPlugin _dbPlugin;
LLUUID _agent_1_id; LLUUID _agent_1_id;
public static LLUUID LibraryFolderRootUuid = new LLUUID("5926de2a-c2d7-4c11-ac4e-74512ffeb6d1"); public static LLUUID LibraryFolderRootUuid = new LLUUID("5926de2a-c2d7-4c11-ac4e-74512ffeb6d1");

View File

@ -6,6 +6,6 @@
<Addin id="OpenSim" version="0.5" /> <Addin id="OpenSim" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/Startup"> <Extension path = "/OpenSim/Startup">
<Plugin type="OpenSim.ApplicationPlugins.LoadRegions.LoadRegionsPlugin" /> <Plugin id="LoadRegions" type="OpenSim.ApplicationPlugins.LoadRegions.LoadRegionsPlugin" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -6,9 +6,18 @@
<Addin id="OpenSim.Data" version="0.5" /> <Addin id="OpenSim.Data" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/GridData"> <Extension path = "/OpenSim/GridData">
<Plugin provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLGridData" /> <Plugin id="MSSQLGridData" provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLGridData" />
</Extension> </Extension>
<Extension path = "/OpenSim/LogData"> <Extension path = "/OpenSim/LogData">
<Plugin provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLLogData" /> <Plugin id="MSSQLLogData" provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLLogData" />
</Extension>
<Extension path = "/OpenSim/AssetData">
<Plugin id="MSSQLAssetData" provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLAssetData" />
</Extension>
<Extension path = "/OpenSim/InventoryData">
<Plugin id="MSSQLInventoryData" provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLInventoryData" />
</Extension>
<Extension path = "/OpenSim/UserData">
<Plugin id="MSSQLUserData" provider="OpenSim.Data.MSSQL.dll" type="OpenSim.Data.MSSQL.MSSQLUserData" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -6,9 +6,18 @@
<Addin id="OpenSim.Data" version="0.5" /> <Addin id="OpenSim.Data" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/GridData"> <Extension path = "/OpenSim/GridData">
<Plugin provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLGridData" /> <Plugin id="MySQLGridData" provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLGridData" />
</Extension> </Extension>
<Extension path = "/OpenSim/LogData"> <Extension path = "/OpenSim/LogData">
<Plugin provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLLogData" /> <Plugin id="MySQLLogData" provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLLogData" />
</Extension>
<Extension path = "/OpenSim/AssetData">
<Plugin id="MySQLAssetData" provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLAssetData" />
</Extension>
<Extension path = "/OpenSim/InventoryData">
<Plugin id="MySQLInventoryData" provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLInventoryData" />
</Extension>
<Extension path = "/OpenSim/UserData">
<Plugin id="MySQLUserData" provider="OpenSim.Data.MySQL.dll" type="OpenSim.Data.MySQL.MySQLUserData" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -6,6 +6,15 @@
<Addin id="OpenSim.Data" version="0.5" /> <Addin id="OpenSim.Data" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/GridData"> <Extension path = "/OpenSim/GridData">
<Plugin provider="OpenSim.Data.SQLite.dll" type="OpenSim.Data.SQLite.SQLiteGridData" /> <Plugin id="SQLiteGridData" provider="OpenSim.Data.SQLite.dll" type="OpenSim.Data.SQLite.SQLiteGridData" />
</Extension>
<Extension path = "/OpenSim/AssetData">
<Plugin id="SQLiteAssetData" provider="OpenSim.Data.SQLite.dll" type="OpenSim.Data.SQLite.SQLiteAssetData" />
</Extension>
<Extension path = "/OpenSim/InventoryData">
<Plugin id="SQLiteInventoryData" provider="OpenSim.Data.SQLite.dll" type="OpenSim.Data.SQLite.SQLiteInventoryStore" />
</Extension>
<Extension path = "/OpenSim/UserData">
<Plugin id="SQLiteUserData" provider="OpenSim.Data.SQLite.dll" type="OpenSim.Data.SQLite.SQLiteUserData" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -1,6 +1,9 @@
<Addin id="OpenSim.Data" isroot="true" version="0.5"> <Addin id="OpenSim.Data" isroot="true" version="0.5">
<Runtime> <Runtime>
<Import assembly="OpenSim.Grid.UserServer.exe"/>
<Import assembly="OpenSim.Grid.GridServer.exe"/> <Import assembly="OpenSim.Grid.GridServer.exe"/>
<Import assembly="OpenSim.Grid.AssetServer.exe"/>
<Import assembly="OpenSim.Grid.InventoryServer.exe"/>
<Import assembly="OpenSim.Data.dll"/> <Import assembly="OpenSim.Data.dll"/>
<Import assembly="OpenSim.Framework.dll"/> <Import assembly="OpenSim.Framework.dll"/>
</Runtime> </Runtime>
@ -10,4 +13,13 @@
<ExtensionPoint path = "/OpenSim/LogData"> <ExtensionPoint path = "/OpenSim/LogData">
<ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Data.ILogDataPlugin"/> <ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Data.ILogDataPlugin"/>
</ExtensionPoint> </ExtensionPoint>
<ExtensionPoint path = "/OpenSim/AssetData">
<ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Framework.IAssetProviderPlugin"/>
</ExtensionPoint>
<ExtensionPoint path = "/OpenSim/InventoryData">
<ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Framework.IInventoryDataPlugin"/>
</ExtensionPoint>
<ExtensionPoint path = "/OpenSim/UserData">
<ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Framework.IUserData"/>
</ExtensionPoint>
</Addin> </Addin>

View File

@ -6,6 +6,6 @@
<Addin id="OpenSim" version="0.5" /> <Addin id="OpenSim" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/Startup"> <Extension path = "/OpenSim/Startup">
<Plugin type="OpenSim.ApplicationPlugins.RemoteController.RemoteAdminPlugin" /> <Plugin id="RemoteController" type="OpenSim.ApplicationPlugins.RemoteController.RemoteAdminPlugin" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -6,6 +6,6 @@
<Addin id="OpenSim" version="0.5" /> <Addin id="OpenSim" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/Startup"> <Extension path = "/OpenSim/Startup">
<Plugin type="OpenSim.ApplicationPlugins.Rest.Inventory.RestHandler" /> <Plugin id="RestInventory" type="OpenSim.ApplicationPlugins.Rest.Inventory.RestHandler" />
</Extension> </Extension>
</Addin> </Addin>

View File

@ -6,6 +6,6 @@
<Addin id="OpenSim" version="0.5" /> <Addin id="OpenSim" version="0.5" />
</Dependencies> </Dependencies>
<Extension path = "/OpenSim/Startup"> <Extension path = "/OpenSim/Startup">
<Plugin type="OpenSim.ApplicationPlugins.Rest.Regions.RestRegionPlugin" /> <Plugin id="RestRegions" type="OpenSim.ApplicationPlugins.Rest.Regions.RestRegionPlugin" />
</Extension> </Extension>
</Addin> </Addin>