From e0e0db366061eae148364e3d5670f275b1ab25b7 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Fri, 18 Jul 2008 04:51:41 +0000 Subject: Thanks, sempuki, for a patch that moves all grid plugins to new PluginLoader (issue 1763). --- OpenSim/Data/GridDataBase.cs | 12 ++++++---- OpenSim/Data/IGridData.cs | 45 +++++++++++++++++------------------ OpenSim/Data/ILogData.cs | 34 +++++++++++++------------- OpenSim/Data/MSSQL/MSSQLGridData.cs | 22 +++++++++++++---- OpenSim/Data/MSSQL/MSSQLLogData.cs | 30 ++++++++++++++++++----- OpenSim/Data/MySQL/MySQLAssetData.cs | 1 + OpenSim/Data/MySQL/MySQLGridData.cs | 22 +++++++++++++---- OpenSim/Data/MySQL/MySQLLogData.cs | 26 +++++++++++++++----- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/SQLite/SQLiteGridData.cs | 25 +++++++++++++++---- 10 files changed, 145 insertions(+), 74 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index 0c9d24a..6480f84 100644 --- a/OpenSim/Data/GridDataBase.cs +++ b/OpenSim/Data/GridDataBase.cs @@ -29,19 +29,21 @@ using libsecondlife; namespace OpenSim.Data { - public abstract class GridDataBase : IGridData + public abstract class GridDataBase : IGridDataPlugin { public abstract RegionProfileData GetProfileByHandle(ulong regionHandle); public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID); public abstract RegionProfileData GetProfileByString(string regionName); public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); - public abstract void Initialise(string connect); - public abstract void Close(); - public abstract string getName(); - public abstract string getVersion(); public abstract DataResponse AddProfile(RegionProfileData profile); public abstract ReservationData GetReservationAtPoint(uint x, uint y); public abstract DataResponse UpdateProfile(RegionProfileData profile); + + public abstract void Initialise(); + public abstract void Initialise(string connect); + public abstract void Dispose(); + public abstract string Name { get; } + public abstract string Version { get; } } } diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs index e242312..fa24d82 100644 --- a/OpenSim/Data/IGridData.cs +++ b/OpenSim/Data/IGridData.cs @@ -26,6 +26,10 @@ */ using libsecondlife; +using Mono.Addins; +using OpenSim.Framework; + +[assembly : AddinRoot("OpenSim.Data", "0.5")] namespace OpenSim.Data { @@ -40,9 +44,15 @@ namespace OpenSim.Data /// /// A standard grid interface /// - public interface IGridData + [TypeExtensionPoint("/OpenSim/GridDataStore")] + public interface IGridDataPlugin : IPlugin { /// + /// Initialises the interface + /// + void Initialise(string connect); + + /// /// Returns a sim profile from a regionHandle /// /// A 64bit Region Handle @@ -84,28 +94,6 @@ namespace OpenSim.Data bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); /// - /// Initialises the interface - /// - void Initialise(string connect); - - /// - /// Closes the interface - /// - void Close(); - - /// - /// The plugin being loaded - /// - /// A string containing the plugin name - string getName(); - - /// - /// The plugins version - /// - /// A string containing the plugin version - string getVersion(); - - /// /// Adds a new profile to the database /// /// The profile to add @@ -116,4 +104,15 @@ namespace OpenSim.Data ReservationData GetReservationAtPoint(uint x, uint y); } + + public class GridDataStoreInitialiser : PluginInitialiserBase + { + private string connect; + public GridDataStoreInitialiser (string s) { connect = s; } + public override void Initialise (IPlugin plugin) + { + IGridDataPlugin p = plugin as IGridDataPlugin; + p.Initialise (connect); + } + } } diff --git a/OpenSim/Data/ILogData.cs b/OpenSim/Data/ILogData.cs index 7275637..34657dc 100644 --- a/OpenSim/Data/ILogData.cs +++ b/OpenSim/Data/ILogData.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using Mono.Addins; +using OpenSim.Framework; + namespace OpenSim.Data { /// @@ -61,7 +64,8 @@ namespace OpenSim.Data /// /// An interface to a LogData storage system /// - public interface ILogData + [TypeExtensionPoint("/OpenSim/GridLogData")] + public interface ILogDataPlugin : IPlugin { void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage); @@ -70,22 +74,16 @@ namespace OpenSim.Data /// Initialises the interface /// void Initialise(string connect); - - /// - /// Closes the interface - /// - void Close(); - - /// - /// The plugin being loaded - /// - /// A string containing the plugin name - string getName(); - - /// - /// The plugins version - /// - /// A string containing the plugin version - string getVersion(); + } + + public class LogDataInitialiser : PluginInitialiserBase + { + private string connect; + public LogDataInitialiser (string s) { connect = s; } + public override void Initialise (IPlugin plugin) + { + ILogDataPlugin p = plugin as ILogDataPlugin; + p.Initialise (connect); + } } } diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 0abd0d0..7de77d1 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs @@ -33,12 +33,18 @@ using System.Security.Cryptography; using System.Text; using libsecondlife; using log4net; +using Mono.Addins; +using OpenSim.Framework; + +[assembly : Addin] +[assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MSSQL { /// /// A grid data interface for MSSQL Server /// + [Extension("/OpenSim/GridDataStore")] public class MSSQLGridData : GridDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -50,6 +56,12 @@ namespace OpenSim.Data.MSSQL private string m_regionsTableName; + override public void Initialise() + { + m_log.Info("[MSSQLGridData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises the Grid Interface /// @@ -101,7 +113,7 @@ namespace OpenSim.Data.MSSQL /// /// Shuts down the grid interface /// - override public void Close() + override public void Dispose() { // nothing to close } @@ -110,18 +122,18 @@ namespace OpenSim.Data.MSSQL /// The name of this DB provider. /// /// A string containing the storage system name - override public string getName() + override public string Name { - return "Sql OpenGridData"; + get { return "Sql OpenGridData"; } } /// /// Database provider version. /// /// A string containing the storage system version - override public string getVersion() + override public string Version { - return "0.1"; + get { return "0.1"; } } /// diff --git a/OpenSim/Data/MSSQL/MSSQLLogData.cs b/OpenSim/Data/MSSQL/MSSQLLogData.cs index 849d0fb..d0d81b6 100644 --- a/OpenSim/Data/MSSQL/MSSQLLogData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLogData.cs @@ -25,21 +25,39 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Reflection; using System.Collections.Generic; using System.Data; +using log4net; +using Mono.Addins; +using OpenSim.Framework; + +// Only one attribute per assembly. See: *GridData.cs +// [assembly : Addin] +// [assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MSSQL { /// /// An interface to the log database for MSSQL /// - internal class MSSQLLogData : ILogData + [Extension("/OpenSim/GridLogData")] + internal class MSSQLLogData : ILogDataPlugin { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// public MSSQLManager database; + public void Initialise() + { + m_log.Info("[MSSQLLogData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Artificial constructor called when the plugin is loaded /// @@ -97,15 +115,15 @@ namespace OpenSim.Data.MSSQL /// Returns the name of this DB provider /// /// A string containing the DB provider name - public string getName() + public string Name { - return "MSSQL Logdata Interface"; + get { return "MSSQL Logdata Interface"; } } /// /// Closes the database provider /// - public void Close() + public void Dispose() { // Do nothing. } @@ -114,9 +132,9 @@ namespace OpenSim.Data.MSSQL /// Returns the version of this DB provider /// /// A string containing the provider version - public string getVersion() + public string Version { - return "0.1"; + get { return "0.1"; } } } } diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 6cb0b4c..9284ba9 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -34,6 +34,7 @@ using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; + namespace OpenSim.Data.MySQL { /// diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index bb71c99..8142c74 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -33,12 +33,18 @@ using System.Security.Cryptography; using System.Text; using libsecondlife; using log4net; +using Mono.Addins; +using OpenSim.Framework; + +[assembly : Addin] +[assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MySQL { /// /// A MySQL Interface for the Grid Server /// + [Extension("/OpenSim/GridDataStore")] public class MySQLGridData : GridDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -48,6 +54,12 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + override public void Initialise() + { + m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises Grid interface /// @@ -144,7 +156,7 @@ namespace OpenSim.Data.MySQL /// /// Shuts down the grid interface /// - override public void Close() + override public void Dispose() { database.Close(); } @@ -153,18 +165,18 @@ namespace OpenSim.Data.MySQL /// Returns the plugin name /// /// Plugin name - override public string getName() + override public string Name { - return "MySql OpenGridData"; + get { return "MySql OpenGridData"; } } /// /// Returns the plugin version /// /// Plugin version - override public string getVersion() + override public string Version { - return "0.1"; + get { return "0.1"; } } /// diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index fee7f2f..f11aec5 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -28,20 +28,34 @@ using System; using System.Reflection; using System.Collections.Generic; using log4net; +using Mono.Addins; +using OpenSim.Framework; + +// Only one attribute per assembly. See: *GridData.cs +// [assembly : Addin] +// [assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MySQL { /// /// An interface to the log database for MySQL /// - internal class MySQLLogData : ILogData + [Extension("/OpenSim/GridLogData")] + internal class MySQLLogData : ILogDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// public MySQLManager database; + public void Initialise() + { + m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Artificial constructor called when the plugin is loaded /// Uses the obsolete mysql_connection.ini if connect string is empty. @@ -128,16 +142,16 @@ namespace OpenSim.Data.MySQL /// Returns the name of this DB provider /// /// A string containing the DB provider name - public string getName() + public string Name { - return "MySQL Logdata Interface"; + get { return "MySQL Logdata Interface";} } /// /// Closes the database provider /// /// do nothing - public void Close() + public void Dispose() { // Do nothing. } @@ -146,9 +160,9 @@ namespace OpenSim.Data.MySQL /// Returns the version of this DB provider /// /// A string containing the provider version - public string getVersion() + public string Version { - return "0.1"; + get { return "0.1"; } } } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index cf4bce3..89d0672 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -227,7 +227,7 @@ namespace OpenSim.Data.MySQL return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); + dllVersion.Revision); } /// diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs index 6fd7235..1e07458 100644 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridData.cs @@ -28,23 +28,38 @@ using System; using System.Collections.Generic; using System.Data; +using System.Reflection; using System.Security.Cryptography; using System.Text; using libsecondlife; +using log4net; +using Mono.Addins; using OpenSim.Framework; +[assembly : Addin] +[assembly : AddinDependency("OpenSim.Data", "0.5")] + namespace OpenSim.Data.SQLite { /// /// A Grid Interface to the SQLite database /// + [Extension("/OpenSim/GridDataStore")] public class SQLiteGridData : GridDataBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// SQLite database manager /// private SQLiteManager database; + override public void Initialise() + { + m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// /// Initialises Inventory interface @@ -61,7 +76,7 @@ namespace OpenSim.Data.SQLite /// /// Shuts down the grid interface /// - override public void Close() + override public void Dispose() { database.Close(); } @@ -70,18 +85,18 @@ namespace OpenSim.Data.SQLite /// Returns the name of this grid interface /// /// A string containing the grid interface - override public string getName() + override public string Name { - return "SQLite OpenGridData"; + get { return "SQLite OpenGridData"; } } /// /// Returns the version of this grid interface /// /// A string containing the version - override public string getVersion() + override public string Version { - return "0.1"; + get { return "0.1"; } } /// -- cgit v1.1