diff options
author | Adam Frisby | 2007-07-11 08:10:25 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:10:25 +0000 |
commit | e2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch) | |
tree | 8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Grid/GridServer.Config/DbGridConfig.cs | |
parent | * Wiping trunk in prep for Sugilite (diff) | |
parent | * Applying dalien's patches from bug#177 and #179 (diff) | |
download | opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2 opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz |
* Bringing Sugilite in to trunk
Diffstat (limited to 'OpenSim/Grid/GridServer.Config/DbGridConfig.cs')
-rw-r--r-- | OpenSim/Grid/GridServer.Config/DbGridConfig.cs | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/OpenSim/Grid/GridServer.Config/DbGridConfig.cs b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs new file mode 100644 index 0000000..4acf81d --- /dev/null +++ b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using Db4objects.Db4o; | ||
30 | using OpenSim.Framework.Console; | ||
31 | using OpenSim.Framework.Interfaces; | ||
32 | |||
33 | namespace OpenGrid.Config.GridConfigDb4o | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// A grid configuration interface for returning the DB4o Config Provider | ||
37 | /// </summary> | ||
38 | public class Db40ConfigPlugin: IGridConfig | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Loads and returns a configuration objeect | ||
42 | /// </summary> | ||
43 | /// <returns>A grid configuration object</returns> | ||
44 | public GridConfig GetConfigObject() | ||
45 | { | ||
46 | MainLog.Instance.Verbose("Loading Db40Config dll"); | ||
47 | return ( new DbGridConfig()); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// A DB4o based Gridserver configuration object | ||
53 | /// </summary> | ||
54 | public class DbGridConfig : GridConfig | ||
55 | { | ||
56 | /// <summary> | ||
57 | /// The DB4o Database | ||
58 | /// </summary> | ||
59 | private IObjectContainer db; | ||
60 | |||
61 | /// <summary> | ||
62 | /// User configuration for the Grid Config interfaces | ||
63 | /// </summary> | ||
64 | public void LoadDefaults() { | ||
65 | MainLog.Instance.Notice("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); | ||
66 | |||
67 | // About the grid options | ||
68 | this.GridOwner = MainLog.Instance.CmdPrompt("Grid owner", "OGS development team"); | ||
69 | |||
70 | // Asset Options | ||
71 | this.DefaultAssetServer = MainLog.Instance.CmdPrompt("Default asset server","http://127.0.0.1:8003/"); | ||
72 | this.AssetSendKey = MainLog.Instance.CmdPrompt("Key to send to asset server","null"); | ||
73 | this.AssetRecvKey = MainLog.Instance.CmdPrompt("Key to expect from asset server","null"); | ||
74 | |||
75 | // User Server Options | ||
76 | this.DefaultUserServer = MainLog.Instance.CmdPrompt("Default user server","http://127.0.0.1:8002/"); | ||
77 | this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server","null"); | ||
78 | this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server","null"); | ||
79 | |||
80 | // Region Server Options | ||
81 | this.SimSendKey = MainLog.Instance.CmdPrompt("Key to send to sims","null"); | ||
82 | this.SimRecvKey = MainLog.Instance.CmdPrompt("Key to expect from sims","null"); | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Initialises a new configuration object | ||
87 | /// </summary> | ||
88 | public override void InitConfig() { | ||
89 | try { | ||
90 | // Perform Db4o initialisation | ||
91 | db = Db4oFactory.OpenFile("opengrid.yap"); | ||
92 | |||
93 | // Locate the grid configuration object | ||
94 | IObjectSet result = db.Get(typeof(DbGridConfig)); | ||
95 | // Found? | ||
96 | if(result.Count==1) { | ||
97 | MainLog.Instance.Verbose("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading"); | ||
98 | foreach (DbGridConfig cfg in result) { | ||
99 | // Import each setting into this class | ||
100 | // Grid Settings | ||
101 | this.GridOwner=cfg.GridOwner; | ||
102 | // Asset Settings | ||
103 | this.DefaultAssetServer=cfg.DefaultAssetServer; | ||
104 | this.AssetSendKey=cfg.AssetSendKey; | ||
105 | this.AssetRecvKey=cfg.AssetRecvKey; | ||
106 | // User Settings | ||
107 | this.DefaultUserServer=cfg.DefaultUserServer; | ||
108 | this.UserSendKey=cfg.UserSendKey; | ||
109 | this.UserRecvKey=cfg.UserRecvKey; | ||
110 | // Region Settings | ||
111 | this.SimSendKey=cfg.SimSendKey; | ||
112 | this.SimRecvKey=cfg.SimRecvKey; | ||
113 | } | ||
114 | // Create a new configuration object from this class | ||
115 | } else { | ||
116 | MainLog.Instance.Verbose("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); | ||
117 | |||
118 | // Load default settings into this class | ||
119 | LoadDefaults(); | ||
120 | |||
121 | // Saves to the database file... | ||
122 | MainLog.Instance.Verbose( "Writing out default settings to local database"); | ||
123 | db.Set(this); | ||
124 | |||
125 | // Closes file locks | ||
126 | db.Close(); | ||
127 | } | ||
128 | } catch(Exception e) { | ||
129 | MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured"); | ||
130 | MainLog.Instance.Warn(e.ToString()); | ||
131 | } | ||
132 | |||
133 | // Grid Settings | ||
134 | MainLog.Instance.Verbose("Grid settings loaded:"); | ||
135 | MainLog.Instance.Verbose("Grid owner: " + this.GridOwner); | ||
136 | |||
137 | // Asset Settings | ||
138 | MainLog.Instance.Verbose("Default asset server: " + this.DefaultAssetServer); | ||
139 | MainLog.Instance.Verbose("Key to send to asset server: " + this.AssetSendKey); | ||
140 | MainLog.Instance.Verbose("Key to expect from asset server: " + this.AssetRecvKey); | ||
141 | |||
142 | // User Settings | ||
143 | MainLog.Instance.Verbose("Default user server: " + this.DefaultUserServer); | ||
144 | MainLog.Instance.Verbose("Key to send to user server: " + this.UserSendKey); | ||
145 | MainLog.Instance.Verbose("Key to expect from user server: " + this.UserRecvKey); | ||
146 | |||
147 | // Region Settings | ||
148 | MainLog.Instance.Verbose("Key to send to sims: " + this.SimSendKey); | ||
149 | MainLog.Instance.Verbose("Key to expect from sims: " + this.SimRecvKey); | ||
150 | } | ||
151 | |||
152 | /// <summary> | ||
153 | /// Closes down the database and releases filesystem locks | ||
154 | /// </summary> | ||
155 | public void Shutdown() { | ||
156 | db.Close(); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | } | ||