From a1cc0e436ff9081f3c0a76de861ed0673cd36142 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 19:13:06 +0000 Subject: changes to allow asset_source to be specified in the opensim.ini this will work for sqlite and nhibernate, but will be ignored for mysql and mssql (reverting to their ini files) until someone writes that bit. --- OpenSim/Data/AssetDataBase.cs | 1 + OpenSim/Data/MSSQL/MSSQLAssetData.cs | 7 +++++++ OpenSim/Data/MySQL/MySQLAssetData.cs | 7 +++++++ OpenSim/Data/NHibernate/NHibernateAssetData.cs | 16 +++++++++++----- OpenSim/Data/SQLite/SQLiteAssetData.cs | 9 ++++++--- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 8 ++++---- OpenSim/Framework/IAssetProvider.cs | 1 + OpenSim/Region/Application/OpenSimMain.cs | 2 +- 8 files changed, 38 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index b30ae73..e3b5c25 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs @@ -40,6 +40,7 @@ namespace OpenSim.Data public abstract string Version { get; } public abstract string Name { get; } + public abstract void Initialise(string connect); public abstract void Initialise(); } } diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 2029b80..d837e4e 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -191,6 +191,13 @@ namespace OpenSim.Data.MSSQL #region IPlugin Members + override public void Initialise(string connect) + { + // TODO: this would allow you to pass in connnect info as + // a string instead of file, if someone writes the support + Initialise(); + } + override public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 111f7d1..b6545d7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -170,6 +170,13 @@ namespace OpenSim.Data.MySQL #region IPlugin Members + override public void Initialise(string connect) + { + // TODO: This will let you pass in the connect string in + // the config, though someone will need to write that. + Initialise(); + } + override public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index db90d09..7bd4a0b 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs @@ -50,18 +50,24 @@ namespace OpenSim.Data.NHibernate public override void Initialise() { - // TODO: hard coding for sqlite based stuff to begin with, just making it easier to test + Initialise("SQLiteDialect;SqliteClientDriver;URI=file:Asset.db,version=3"); + } + public override void Initialise(string connect) + { + // TODO: hard coding for sqlite based stuff to begin with, just making it easier to test + char[] split = {';'}; + string[] parts = connect.Split(split); + // This is stubbing for now, it will become dynamic later and support different db backends cfg = new Configuration(); cfg.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider"); cfg.SetProperty(Environment.Dialect, - "NHibernate.Dialect.SQLiteDialect"); + "NHibernate.Dialect." + parts[0]); cfg.SetProperty(Environment.ConnectionDriver, - "NHibernate.Driver.SqliteClientDriver"); - cfg.SetProperty(Environment.ConnectionString, - "URI=file:Asset.db,version=3"); + "NHibernate.Driver." + parts[1]); + cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); HbmSerializer.Default.Validate = true; diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 2b63d2b..0d8b468 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -56,9 +56,12 @@ namespace OpenSim.Data.SQLite private SqliteConnection m_conn; - public void Initialise(string dbfile, string dbname) + override public void Initialise(string dbconnect) { - m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3"); + if (dbconnect == string.Empty) { + dbconnect = "URI=file:AssetStorage.db,version=3"; + } + m_conn = new SqliteConnection(dbconnect); m_conn.Open(); TestTables(m_conn); return; @@ -289,7 +292,7 @@ namespace OpenSim.Data.SQLite override public void Initialise() { - Initialise("AssetStorage.db", ""); + Initialise("URI=file:AssetStorage.db,version=3"); } override public string Name diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 1afec70..334c5bd 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -35,9 +35,9 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public SQLAssetServer(string pluginName) + public SQLAssetServer(string pluginName, string connect) { - AddPlugin(pluginName); + AddPlugin(pluginName, connect); } public SQLAssetServer(IAssetProvider assetProvider) @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider = assetProvider; } - public void AddPlugin(string FileName) + public void AddPlugin(string FileName, string connect) { m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); @@ -61,7 +61,7 @@ namespace OpenSim.Framework.Communications.Cache IAssetProvider plug = (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProvider = plug; - m_assetProvider.Initialise(); + m_assetProvider.Initialise(connect); m_log.Info("[AssetStorage]: " + "Added " + m_assetProvider.Name + " " + diff --git a/OpenSim/Framework/IAssetProvider.cs b/OpenSim/Framework/IAssetProvider.cs index c9e4c8a..dcb79ea 100644 --- a/OpenSim/Framework/IAssetProvider.cs +++ b/OpenSim/Framework/IAssetProvider.cs @@ -36,5 +36,6 @@ namespace OpenSim.Framework void UpdateAsset(AssetBase asset); bool ExistsAsset(LLUUID uuid); void CommitAssets(); // force a sync to the database + void Initialise(string connect); } } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index ad0ee45..c01fc5a 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -454,7 +454,7 @@ namespace OpenSim } else { - SQLAssetServer sqlAssetServer = new SQLAssetServer(m_standaloneAssetPlugin); + SQLAssetServer sqlAssetServer = new SQLAssetServer(m_standaloneAssetPlugin, m_standaloneAssetSource); sqlAssetServer.LoadDefaultAssets(); assetServer = sqlAssetServer; } -- cgit v1.1