plumb in connection string to the user database paths. mysql and mssql
just ignore this for now, but it lets us get connect strings to sqlite and nhibernate.0.6.0-stable
parent
72a7c2e2bb
commit
1b7f1c956c
|
@ -55,10 +55,11 @@ namespace OpenSim.Data.MSSQL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and initialises the MySQL storage plugin
|
/// Loads and initialises the MySQL storage plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
override public void Initialise()
|
override public void Initialise(string connect)
|
||||||
{
|
{
|
||||||
// Load from an INI file connection details
|
// TODO: do something with the connect string instead of
|
||||||
// TODO: move this to XML?
|
// ignoring it.
|
||||||
|
|
||||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||||
|
|
|
@ -55,10 +55,10 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and initialises the MySQL storage plugin
|
/// Loads and initialises the MySQL storage plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
override public void Initialise()
|
override public void Initialise(string connect)
|
||||||
{
|
{
|
||||||
// Load from an INI file connection details
|
// TODO: actually do something with our connect string
|
||||||
// TODO: move this to XML? Yes, PLEASE!
|
// instead of loading the second config
|
||||||
|
|
||||||
IniFile iniFile = new IniFile("mysql_connection.ini");
|
IniFile iniFile = new IniFile("mysql_connection.ini");
|
||||||
string settingHostname = iniFile.ParseFileReadValue("hostname");
|
string settingHostname = iniFile.ParseFileReadValue("hostname");
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -35,6 +36,7 @@ using NHibernate.Cfg;
|
||||||
using NHibernate.Expression;
|
using NHibernate.Expression;
|
||||||
using NHibernate.Mapping.Attributes;
|
using NHibernate.Mapping.Attributes;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using Environment=NHibernate.Cfg.Environment;
|
||||||
|
|
||||||
namespace OpenSim.Data.NHibernate
|
namespace OpenSim.Data.NHibernate
|
||||||
{
|
{
|
||||||
|
@ -48,20 +50,24 @@ namespace OpenSim.Data.NHibernate
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ISessionFactory factory;
|
private ISessionFactory factory;
|
||||||
|
|
||||||
public override void Initialise()
|
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, 3);
|
||||||
|
if (parts.Length != 3) {
|
||||||
|
// TODO: make this a real exception type
|
||||||
|
throw new Exception("Malformed Inventory connection string '" + connect + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// This is stubbing for now, it will become dynamic later and support different db backends
|
// This is stubbing for now, it will become dynamic later and support different db backends
|
||||||
cfg = new Configuration();
|
cfg = new Configuration();
|
||||||
cfg.SetProperty(Environment.ConnectionProvider,
|
cfg.SetProperty(Environment.ConnectionProvider,
|
||||||
"NHibernate.Connection.DriverConnectionProvider");
|
"NHibernate.Connection.DriverConnectionProvider");
|
||||||
cfg.SetProperty(Environment.Dialect,
|
cfg.SetProperty(Environment.Dialect,
|
||||||
"NHibernate.Dialect.SQLiteDialect");
|
"NHibernate.Dialect." + parts[0]);
|
||||||
cfg.SetProperty(Environment.ConnectionDriver,
|
cfg.SetProperty(Environment.ConnectionDriver,
|
||||||
"NHibernate.Driver.SqliteClientDriver");
|
"NHibernate.Driver." + parts[1]);
|
||||||
cfg.SetProperty(Environment.ConnectionString,
|
cfg.SetProperty(Environment.ConnectionString, parts[2]);
|
||||||
"URI=file:User.db,version=3");
|
|
||||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||||
|
|
||||||
HbmSerializer.Default.Validate = true;
|
HbmSerializer.Default.Validate = true;
|
||||||
|
|
|
@ -64,9 +64,13 @@ namespace OpenSim.Data.SQLite
|
||||||
private SqliteDataAdapter daf;
|
private SqliteDataAdapter daf;
|
||||||
SqliteConnection g_conn;
|
SqliteConnection g_conn;
|
||||||
|
|
||||||
override public void Initialise()
|
override public void Initialise(string connect)
|
||||||
{
|
{
|
||||||
SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3");
|
// default to something sensible
|
||||||
|
if (connect == "")
|
||||||
|
connect = "URI=file:userprofiles.db,version=3";
|
||||||
|
|
||||||
|
SqliteConnection conn = new SqliteConnection(connect);
|
||||||
TestTables(conn);
|
TestTables(conn);
|
||||||
|
|
||||||
// This sucks, but It doesn't seem to work with the dataset Syncing :P
|
// This sucks, but It doesn't seem to work with the dataset Syncing :P
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace OpenSim.Data
|
||||||
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 Version {get;}
|
||||||
public abstract string Name {get;}
|
public abstract string Name {get;}
|
||||||
public abstract void Initialise();
|
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 UserAppearance GetUserAppearance(LLUUID user);
|
public abstract UserAppearance GetUserAppearance(LLUUID user);
|
||||||
public abstract void UpdateUserAppearance(LLUUID user, UserAppearance appearance);
|
public abstract void UpdateUserAppearance(LLUUID user, UserAppearance appearance);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications
|
||||||
/// 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="FileName">The filename to the user server plugin DLL</param>
|
||||||
public void AddPlugin(string FileName)
|
public void AddPlugin(string FileName, string connect)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(FileName))
|
if (!String.IsNullOrEmpty(FileName))
|
||||||
{
|
{
|
||||||
|
@ -71,16 +71,16 @@ namespace OpenSim.Framework.Communications
|
||||||
{
|
{
|
||||||
IUserData plug =
|
IUserData plug =
|
||||||
(IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
(IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||||
AddPlugin(plug);
|
AddPlugin(plug, connect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddPlugin(IUserData plug)
|
public void AddPlugin(IUserData plug, string connect)
|
||||||
{
|
{
|
||||||
plug.Initialise();
|
plug.Initialise(connect);
|
||||||
_plugins.Add(plug.Name, plug);
|
_plugins.Add(plug.Name, plug);
|
||||||
m_log.Info("[USERSTORAGE]: Added IUserData Interface");
|
m_log.Info("[USERSTORAGE]: Added IUserData Interface");
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ namespace OpenSim.Framework
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialises the plugin (artificial constructor)
|
/// Initialises the plugin (artificial constructor)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Initialise();
|
void Initialise(string connect);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user appearance
|
/// Gets the user appearance
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace OpenSim.Framework
|
||||||
public static bool DefaultHttpSSL = false;
|
public static bool DefaultHttpSSL = false;
|
||||||
private ConfigurationMember configMember;
|
private ConfigurationMember configMember;
|
||||||
public string DatabaseProvider = String.Empty;
|
public string DatabaseProvider = String.Empty;
|
||||||
|
public string DatabaseConnect = String.Empty;
|
||||||
public string DefaultStartupMsg = String.Empty;
|
public string DefaultStartupMsg = String.Empty;
|
||||||
public uint DefaultX = 1000;
|
public uint DefaultX = 1000;
|
||||||
public uint DefaultY = 1000;
|
public uint DefaultY = 1000;
|
||||||
|
@ -77,6 +78,8 @@ namespace OpenSim.Framework
|
||||||
false);
|
false);
|
||||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
|
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
|
||||||
"DLL for database provider", "OpenSim.Data.MySQL.dll", false);
|
"DLL for database provider", "OpenSim.Data.MySQL.dll", false);
|
||||||
|
configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
|
||||||
|
"Connection String for Database", "", false);
|
||||||
|
|
||||||
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
||||||
"Http Listener port", DefaultHttpPort.ToString(), false);
|
"Http Listener port", DefaultHttpPort.ToString(), false);
|
||||||
|
@ -110,6 +113,9 @@ namespace OpenSim.Framework
|
||||||
case "database_provider":
|
case "database_provider":
|
||||||
DatabaseProvider = (string) configuration_result;
|
DatabaseProvider = (string) configuration_result;
|
||||||
break;
|
break;
|
||||||
|
case "database_connect":
|
||||||
|
DatabaseConnect = (string) configuration_result;
|
||||||
|
break;
|
||||||
case "http_port":
|
case "http_port":
|
||||||
HttpPort = (uint) configuration_result;
|
HttpPort = (uint) configuration_result;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
m_log.Info("[REGION]: Establishing data connection");
|
m_log.Info("[REGION]: Establishing data connection");
|
||||||
m_userManager = new UserManager();
|
m_userManager = new UserManager();
|
||||||
m_userManager._config = Cfg;
|
m_userManager._config = Cfg;
|
||||||
m_userManager.AddPlugin(Cfg.DatabaseProvider);
|
m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
|
||||||
|
|
||||||
m_loginService = new UserLoginService(
|
m_loginService = new UserLoginService(
|
||||||
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
|
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
|
||||||
|
|
|
@ -362,7 +362,7 @@ namespace OpenSim
|
||||||
LocalUserServices userService =
|
LocalUserServices userService =
|
||||||
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
|
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
|
||||||
m_networkServersInfo.DefaultHomeLocY, inventoryService);
|
m_networkServersInfo.DefaultHomeLocY, inventoryService);
|
||||||
userService.AddPlugin(m_standaloneUserPlugin);
|
userService.AddPlugin(m_standaloneUserPlugin, m_standaloneUserSource);
|
||||||
|
|
||||||
LocalBackEndServices backendService = new LocalBackEndServices();
|
LocalBackEndServices backendService = new LocalBackEndServices();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue