allow for Inventory database source to be specified in main

configs.  This works with sqlite and nhibernate backends, and
stays with default seperate ini files for mysql and mssql until
someone writes those.
0.6.0-stable
Sean Dague 2008-04-23 20:48:23 +00:00
parent a1cc0e436f
commit 3dd98a112f
12 changed files with 75 additions and 52 deletions

View File

@ -51,6 +51,12 @@ namespace OpenSim.Data.MSSQL
/// <summary>
/// Loads and initialises this database plugin
/// </summary>
public void Initialise(string connect)
{
// TODO: actually use the provided connect string
Initialise();
}
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");

View File

@ -51,6 +51,12 @@ namespace OpenSim.Data.MySQL
/// <summary>
/// Loads and initialises this database plugin
/// </summary>
public void Initialise(string connect)
{
// TODO: actually use the provided connect string
Initialise();
}
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");

View File

@ -55,11 +55,11 @@ namespace OpenSim.Data.NHibernate
public override void Initialise(string connect)
{
// TODO: hard coding for sqlite based stuff to begin with, just making it easier to test
// Split out the dialect, driver, and connect string
char[] split = {';'};
string[] parts = connect.Split(split);
// This is stubbing for now, it will become dynamic later and support different db backends
// NHibernate setup
cfg = new Configuration();
cfg.SetProperty(Environment.ConnectionProvider,
"NHibernate.Connection.DriverConnectionProvider");
@ -75,6 +75,10 @@ namespace OpenSim.Data.NHibernate
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
cfg.AddInputStream(stream);
// If uncommented this will auto create tables, but it
// does drops of the old tables, so we need a smarter way
// to acturally manage this.
// new SchemaExport(cfg).Create(true, true);
factory = cfg.BuildSessionFactory();

View File

@ -50,25 +50,21 @@ namespace OpenSim.Data.NHibernate
/// <summary>
/// Initialises the interface
/// </summary>
public void Initialise()
public void Initialise(string connect)
{
Initialise("Inventory.db", "Inventory");
}
// Split out the dialect, driver, and connect string
char[] split = {';'};
string[] parts = connect.Split(split);
public void Initialise(string dbfile, string dbname)
{
// TODO: hard coding for sqlite based stuff to begin with, just making it easier to test
// This is stubbing for now, it will become dynamic later and support different db backends
// Establish NHibernate Connection
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:" + dbfile + ",version=3");
"NHibernate.Driver." + parts[1]);
cfg.SetProperty(Environment.ConnectionString, parts[2]);
cfg.AddAssembly("OpenSim.Data.NHibernate");
HbmSerializer.Default.Validate = true;
@ -76,6 +72,10 @@ namespace OpenSim.Data.NHibernate
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
cfg.AddInputStream(stream);
// If uncommented this will auto create tables, but it
// does drops of the old tables, so we need a smarter way
// to acturally manage this.
// new SchemaExport(cfg).Create(true, true);
factory = cfg.BuildSessionFactory();

View File

@ -50,17 +50,13 @@ namespace OpenSim.Data.SQLite
/// <summary>
/// Initialises the interface
/// </summary>
public void Initialise()
public void Initialise(string dbconnect)
{
Initialise("inventoryStore.db", "inventoryDatabase");
if (dbconnect == string.Empty) {
dbconnect = "URI=file:inventoryStore.db,version=3";
}
public void Initialise(string dbfile, string dbname)
{
string connectionString = "URI=file:" + dbfile + ",version=3";
m_log.Info("[Inventory]: Sqlite - connecting: " + dbfile);
SqliteConnection conn = new SqliteConnection(connectionString);
m_log.Info("[Inventory]: Sqlite - connecting: " + dbconnect);
SqliteConnection conn = new SqliteConnection(dbconnect);
conn.Open();

View File

@ -46,7 +46,7 @@ namespace OpenSim.Framework.Communications
/// Adds a new user server plugin - plugins will be requested in the order they were loaded.
/// </summary>
/// <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))
{
@ -63,7 +63,7 @@ namespace OpenSim.Framework.Communications
{
IInventoryData plug =
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
plug.Initialise(connect);
m_plugins.Add(plug.getName(), plug);
m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface");
}

View File

@ -38,7 +38,7 @@ namespace OpenSim.Framework
/// <summary>
/// Initialises the interface
/// </summary>
void Initialise();
void Initialise(string connect);
/// <summary>
/// Closes the interface

View File

@ -40,6 +40,7 @@ namespace OpenSim.Framework
public string UserRecvKey = String.Empty;
public string DatabaseProvider = String.Empty;
public string DatabaseConnect = String.Empty;
public static uint DefaultHttpPort = 8004;
public uint HttpPort = DefaultHttpPort;
@ -68,6 +69,8 @@ namespace OpenSim.Framework
"Key to expect from user server", "null", false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Data.SQLite.dll", false);
configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Database Connect String", "", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
}
@ -91,6 +94,9 @@ namespace OpenSim.Framework
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "database_connect":
DatabaseConnect = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;

View File

@ -48,7 +48,7 @@ namespace OpenSim.Grid.InventoryServer
/// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
/// </summary>
/// <param name="FileName">The filename to the inventory server plugin DLL</param>
public void AddDatabasePlugin(string FileName)
public void AddDatabasePlugin(string FileName, string dbconnect)
{
m_log.Info("[" + OpenInventory_Main.LogName + "]: Invenstorage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
@ -65,7 +65,7 @@ namespace OpenSim.Grid.InventoryServer
{
IInventoryData plug =
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
plug.Initialise(dbconnect);
_databasePlugin = plug;
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
"Invenstorage: Added IInventoryData Interface");

View File

@ -72,7 +72,7 @@ namespace OpenSim.Grid.InventoryServer
m_inventoryService = new GridInventoryService();
// m_inventoryManager = new InventoryManager();
m_inventoryService.AddPlugin(m_config.DatabaseProvider);
m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
m_log.Info("[" + LogName + "]: Starting HTTP server ...");

View File

@ -353,7 +353,7 @@ namespace OpenSim
if (m_sandbox)
{
LocalInventoryService inventoryService = new LocalInventoryService();
inventoryService.AddPlugin(m_standaloneInventoryPlugin);
inventoryService.AddPlugin(m_standaloneInventoryPlugin, m_standaloneInventorySource);
LocalUserServices userService =
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,

View File

@ -104,13 +104,18 @@ welcome_message = "Welcome to OpenSim"
; Asset database provider
asset_plugin = "OpenSim.Data.SQLite.dll"
; asset_plugin = "OpenSim.Data.MySQL.dll"
; the Asset DB source. This only works for sqlite and nhibernate for now
asset_source = "URI=file:Asset.db,version=3"
; Asset Source SQLite Exampe
; asset_source = "URI=file:Asset.db,version=3"
; Asset Source NHibernate Example (DIALECT;DRIVER;CONNECTSTRING)
; asset_source = "SQLiteDialect;SqliteClientDriver;URI=file:Asset.db,version=3"
; Inventory database provider
inventory_plugin = "OpenSim.Data.SQLite.dll"
; inventory_plugin = "OpenSim.Data.MySQL.dll"
; User Data Database provider
userDatabase_plugin = "OpenSim.Data.SQLite.dll"
; userDatabase_plugin = "OpenSim.Data.MySQL.dll"