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.
0.6.0-stable
Sean Dague 2008-04-23 19:13:06 +00:00
parent d194f21a5d
commit a1cc0e436f
9 changed files with 40 additions and 13 deletions

View File

@ -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();
}
}

View File

@ -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");

View File

@ -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");

View File

@ -49,19 +49,25 @@ namespace OpenSim.Data.NHibernate
private ISessionFactory factory;
public override void Initialise()
{
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;

View File

@ -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

View File

@ -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 + " " +

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -104,6 +104,8 @@ 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"
; Inventory database provider
inventory_plugin = "OpenSim.Data.SQLite.dll"