* Introduced common abstract AssetDataBase implementing IAssetProvider
* changed the semantics of SQLiteBase to SQLiteUtils * Added abstract placeholder files for the other db providers0.6.0-stable
parent
830626999c
commit
8c901e9347
|
@ -34,7 +34,7 @@ using OpenSim.Framework.Console;
|
|||
|
||||
namespace OpenSim.Framework.Data.MSSQL
|
||||
{
|
||||
internal class MSSQLAssetData : IAssetProvider
|
||||
internal class MSSQLAssetData : AssetDataBase
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
UpgradeAssetsTable(tableList["assets"]);
|
||||
}
|
||||
|
||||
public AssetBase FetchAsset(LLUUID assetID)
|
||||
override public AssetBase FetchAsset(LLUUID assetID)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
return asset;
|
||||
}
|
||||
|
||||
public void CreateAsset(AssetBase asset)
|
||||
override public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
if (ExistsAsset((LLUUID) asset.FullID))
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
}
|
||||
|
||||
|
||||
public void UpdateAsset(AssetBase asset)
|
||||
override public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
|
||||
"name = @name, " +
|
||||
|
@ -169,7 +169,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
}
|
||||
}
|
||||
|
||||
public bool ExistsAsset(LLUUID uuid)
|
||||
override public bool ExistsAsset(LLUUID uuid)
|
||||
{
|
||||
if (FetchAsset(uuid) != null)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
/// <summary>
|
||||
/// All writes are immediately commited to the database, so this is a no-op
|
||||
/// </summary>
|
||||
public void CommitAssets()
|
||||
override public void CommitAssets()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
|
||||
#region IPlugin Members
|
||||
|
||||
public void Initialise()
|
||||
override public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
|
||||
|
@ -205,13 +205,13 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
TestTables();
|
||||
}
|
||||
|
||||
public string Version
|
||||
override public string Version
|
||||
{
|
||||
// get { return database.getVersion(); }
|
||||
get { return database.getVersion(); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
override public string Name
|
||||
{
|
||||
get { return "MSSQL Asset storage engine"; }
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ using OpenSim.Framework.Console;
|
|||
|
||||
namespace OpenSim.Framework.Data.MySQL
|
||||
{
|
||||
internal class MySQLAssetData : IAssetProvider
|
||||
internal class MySQLAssetData : AssetDataBase, IPlugin
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
UpgradeAssetsTable(tableList["assets"]);
|
||||
}
|
||||
|
||||
public AssetBase FetchAsset(LLUUID assetID)
|
||||
override public AssetBase FetchAsset(LLUUID assetID)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
lock (_dbConnection)
|
||||
|
@ -108,7 +108,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
return asset;
|
||||
}
|
||||
|
||||
public void CreateAsset(AssetBase asset)
|
||||
override public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
lock (_dbConnection)
|
||||
{
|
||||
|
@ -147,12 +147,12 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateAsset(AssetBase asset)
|
||||
override public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
CreateAsset(asset);
|
||||
}
|
||||
|
||||
public bool ExistsAsset(LLUUID uuid)
|
||||
override public bool ExistsAsset(LLUUID uuid)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
/// <summary>
|
||||
/// All writes are immediately commited to the database, so this is a no-op
|
||||
/// </summary>
|
||||
public void CommitAssets()
|
||||
override public void CommitAssets()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
|
||||
#region IPlugin Members
|
||||
|
||||
public void Initialise()
|
||||
override public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
||||
|
@ -183,12 +183,12 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
TestTables();
|
||||
}
|
||||
|
||||
public string Version
|
||||
override public string Version
|
||||
{
|
||||
get { return _dbConnection.getVersion(); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
override public string Name
|
||||
{
|
||||
get { return "MySQL Asset storage engine"; }
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
/// <summary>
|
||||
/// A User storage interface for the DB4o database system
|
||||
/// </summary>
|
||||
public class SQLiteAssetData : SQLiteBase, IAssetProvider
|
||||
public class SQLiteAssetData : AssetDataBase
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
return;
|
||||
}
|
||||
|
||||
public AssetBase FetchAsset(LLUUID uuid)
|
||||
override public AssetBase FetchAsset(LLUUID uuid)
|
||||
{
|
||||
|
||||
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
|
||||
|
@ -86,7 +86,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
public void CreateAsset(AssetBase asset)
|
||||
override public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID));
|
||||
if (ExistsAsset(asset.FullID))
|
||||
|
@ -111,7 +111,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateAsset(AssetBase asset)
|
||||
override public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
LogAssetLoad(asset);
|
||||
|
||||
|
@ -144,7 +144,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
asset.InvType, temporary, local, assetLength));
|
||||
}
|
||||
|
||||
public bool ExistsAsset(LLUUID uuid)
|
||||
override public bool ExistsAsset(LLUUID uuid)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
public void CommitAssets() // force a sync to the database
|
||||
override public void CommitAssets() // force a sync to the database
|
||||
{
|
||||
m_log.Info("[SQLITE]: Attempting commit");
|
||||
// lock (ds)
|
||||
|
@ -197,14 +197,14 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
{
|
||||
DataTable assets = new DataTable("assets");
|
||||
|
||||
createCol(assets, "UUID", typeof (String));
|
||||
createCol(assets, "Name", typeof (String));
|
||||
createCol(assets, "Description", typeof (String));
|
||||
createCol(assets, "Type", typeof (Int32));
|
||||
createCol(assets, "InvType", typeof (Int32));
|
||||
createCol(assets, "Local", typeof (Boolean));
|
||||
createCol(assets, "Temporary", typeof (Boolean));
|
||||
createCol(assets, "Data", typeof (Byte[]));
|
||||
SQLiteUtil.createCol(assets, "UUID", typeof (String));
|
||||
SQLiteUtil.createCol(assets, "Name", typeof (String));
|
||||
SQLiteUtil.createCol(assets, "Description", typeof (String));
|
||||
SQLiteUtil.createCol(assets, "Type", typeof (Int32));
|
||||
SQLiteUtil.createCol(assets, "InvType", typeof (Int32));
|
||||
SQLiteUtil.createCol(assets, "Local", typeof (Boolean));
|
||||
SQLiteUtil.createCol(assets, "Temporary", typeof (Boolean));
|
||||
SQLiteUtil.createCol(assets, "Data", typeof (Byte[]));
|
||||
// Add in contraints
|
||||
assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]};
|
||||
return assets;
|
||||
|
@ -248,7 +248,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
|
||||
private void InitDB(SqliteConnection conn)
|
||||
{
|
||||
string createAssets = defineTable(createAssetsTable());
|
||||
string createAssets = SQLiteUtil.defineTable(createAssetsTable());
|
||||
SqliteCommand pcmd = new SqliteCommand(createAssets, conn);
|
||||
pcmd.ExecuteNonQuery();
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
|
||||
#region IPlugin interface
|
||||
|
||||
public string Version
|
||||
override public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -286,12 +286,12 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
override public void Initialise()
|
||||
{
|
||||
Initialise("AssetStorage.db", "");
|
||||
}
|
||||
|
||||
public string Name
|
||||
override public string Name
|
||||
{
|
||||
get { return "SQLite Asset storage engine"; }
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ using OpenSim.Framework.Console;
|
|||
|
||||
namespace OpenSim.Framework.Data.SQLite
|
||||
{
|
||||
public class SQLiteInventoryStore : SQLiteBase, IInventoryData
|
||||
public class SQLiteInventoryStore : SQLiteUtil, IInventoryData
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ using OpenSim.Framework.Console;
|
|||
|
||||
namespace OpenSim.Framework.Data.SQLite
|
||||
{
|
||||
internal class SQLiteManager : SQLiteBase
|
||||
internal class SQLiteManager : SQLiteUtil
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
/// <summary>
|
||||
/// A User storage interface for the SQLite database system
|
||||
/// </summary>
|
||||
public class SQLiteUserData : SQLiteBase, IUserData
|
||||
public class SQLiteUserData : SQLiteUtil, IUserData
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
|
|
@ -34,17 +34,17 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
/// <summary>
|
||||
/// A base class for methods needed by all SQLite database classes
|
||||
/// </summary>
|
||||
public class SQLiteBase
|
||||
public class SQLiteUtil
|
||||
{
|
||||
/***********************************************************************
|
||||
*
|
||||
* Database Definition Functions
|
||||
* Database Definition Helper Functions
|
||||
*
|
||||
* This should be db agnostic as we define them in ADO.NET terms
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
protected static void createCol(DataTable dt, string name, Type type)
|
||||
public static void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
dt.Columns.Add(col);
|
||||
|
@ -60,7 +60,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
protected static SqliteCommand createInsertCommand(string table, DataTable dt)
|
||||
public static SqliteCommand createInsertCommand(string table, DataTable dt)
|
||||
{
|
||||
/**
|
||||
* This is subtle enough to deserve some commentary.
|
||||
|
@ -95,7 +95,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
return cmd;
|
||||
}
|
||||
|
||||
protected static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
|
||||
public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
|
||||
{
|
||||
string sql = "update " + table + " set ";
|
||||
string subsql = String.Empty;
|
||||
|
@ -123,7 +123,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
|
||||
|
||||
protected static string defineTable(DataTable dt)
|
||||
public static string defineTable(DataTable dt)
|
||||
{
|
||||
string sql = "create table " + dt.TableName + "(";
|
||||
string subsql = String.Empty;
|
||||
|
@ -168,7 +168,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
/// for us.
|
||||
///</summary>
|
||||
///<returns>a built sqlite parameter</returns>
|
||||
protected static SqliteParameter createSqliteParameter(string name, Type type)
|
||||
public static SqliteParameter createSqliteParameter(string name, Type type)
|
||||
{
|
||||
SqliteParameter param = new SqliteParameter();
|
||||
param.ParameterName = ":" + name;
|
||||
|
@ -184,7 +184,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
protected static DbType dbtypeFromType(Type type)
|
||||
public static DbType dbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
|
||||
// this is something we'll need to implement for each db
|
||||
// slightly differently.
|
||||
protected static string sqliteType(Type type)
|
||||
public static string sqliteType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
{
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
{
|
||||
public abstract class AssetDataBase : IAssetProvider
|
||||
{
|
||||
public abstract AssetBase FetchAsset(LLUUID uuid);
|
||||
public abstract void CreateAsset(AssetBase asset);
|
||||
public abstract void UpdateAsset(AssetBase asset);
|
||||
public abstract bool ExistsAsset(LLUUID uuid);
|
||||
public abstract void CommitAssets();
|
||||
|
||||
public abstract string Version { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract void Initialise();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
{
|
||||
public abstract class DataStoreBase
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
{
|
||||
public abstract class GridDataBase
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
{
|
||||
public abstract class InventoryDataBase
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
{
|
||||
public abstract class UserDataBase
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue