From a7fe1b63f31fdfe438ed52512ccd277f9e33ff2e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 1 Jun 2007 23:34:37 +0000 Subject: * ZOMG Wtf Comments? * OpenGrid.Framework.Data is now well documented --- .../OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs | 68 ++++++++++++++++++---- 1 file changed, 58 insertions(+), 10 deletions(-) (limited to 'OpenGridServices/OpenGrid.Config') diff --git a/OpenGridServices/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs b/OpenGridServices/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs index 2d00ca6..cbe64e6 100644 --- a/OpenGridServices/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs +++ b/OpenGridServices/OpenGrid.Config/GridConfigDb4o/DbGridConfig.cs @@ -12,7 +12,7 @@ * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY @@ -32,8 +32,15 @@ using Db4objects.Db4o; namespace OpenGrid.Config.GridConfigDb4o { + /// + /// A grid configuration interface for returning the DB4o Config Provider + /// public class Db40ConfigPlugin: IGridConfig { + /// + /// Loads and returns a configuration objeect + /// + /// A grid configuration object public GridConfig GetConfigObject() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Loading Db40Config dll"); @@ -41,49 +48,81 @@ namespace OpenGrid.Config.GridConfigDb4o } } + /// + /// A DB4o based Gridserver configuration object + /// public class DbGridConfig : GridConfig { + /// + /// The DB4o Database + /// private IObjectContainer db; + /// + /// User configuration for the Grid Config interfaces + /// public void LoadDefaults() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + // About the grid options this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner", "OGS development team"); + // Asset Options this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server","http://127.0.0.1:8003/"); - this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server","null"); - this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server","null"); + this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server","null"); + this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server","null"); - this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server","http://127.0.0.1:8002/"); - this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server","null"); - this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server","null"); + // User Server Options + this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server","http://127.0.0.1:8002/"); + this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server","null"); + this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server","null"); - this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims","null"); - this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims","null"); + // Region Server Options + this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims","null"); + this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims","null"); } + /// + /// Initialises a new configuration object + /// public override void InitConfig() { try { + // Perform Db4o initialisation db = Db4oFactory.OpenFile("opengrid.yap"); + + // Locate the grid configuration object IObjectSet result = db.Get(typeof(DbGridConfig)); + // Found? if(result.Count==1) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Config.cs:InitConfig() - Found a GridConfig object in the local database, loading"); foreach (DbGridConfig cfg in result) { + // Import each setting into this class + // Grid Settings this.GridOwner=cfg.GridOwner; + // Asset Settings this.DefaultAssetServer=cfg.DefaultAssetServer; this.AssetSendKey=cfg.AssetSendKey; this.AssetRecvKey=cfg.AssetRecvKey; + // User Settings this.DefaultUserServer=cfg.DefaultUserServer; this.UserSendKey=cfg.UserSendKey; this.UserRecvKey=cfg.UserRecvKey; + // Region Settings this.SimSendKey=cfg.SimSendKey; this.SimRecvKey=cfg.SimRecvKey; } + // Create a new configuration object from this class } else { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); + + // Load default settings into this class LoadDefaults(); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Writing out default settings to local database"); + + // Saves to the database file... + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Writing out default settings to local database"); db.Set(this); + + // Closes file locks db.Close(); } } catch(Exception e) { @@ -91,19 +130,28 @@ namespace OpenGrid.Config.GridConfigDb4o OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString()); } + // Grid Settings OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Grid settings loaded:"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Grid owner: " + this.GridOwner); + + // Asset Settings OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Default asset server: " + this.DefaultAssetServer); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to send to asset server: " + this.AssetSendKey); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to expect from asset server: " + this.AssetRecvKey); + + // User Settings OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Default user server: " + this.DefaultUserServer); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to send to user server: " + this.UserSendKey); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to expect from user server: " + this.UserRecvKey); + + // Region Settings OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to send to sims: " + this.SimSendKey); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Key to expect from sims: " + this.SimRecvKey); } - + /// + /// Closes down the database and releases filesystem locks + /// public void Shutdown() { db.Close(); } -- cgit v1.1