diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Base/CommandManager.cs | 359 | ||||
-rw-r--r-- | OpenSim/Server/Base/Properties/AssemblyInfo.cs | 4 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 222 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 14 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Base/ServerConnector.cs | 67 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 21 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Properties/AssemblyInfo.cs | 4 | ||||
-rw-r--r-- | OpenSim/Server/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Server/ServerMain.cs | 10 |
9 files changed, 678 insertions, 25 deletions
diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs new file mode 100644 index 0000000..bd18485 --- /dev/null +++ b/OpenSim/Server/Base/CommandManager.cs | |||
@@ -0,0 +1,359 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 | |||
29 | using System; | ||
30 | using System.Text; | ||
31 | using System.Linq; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using System.Collections.ObjectModel; | ||
35 | using Mono.Addins.Setup; | ||
36 | using Mono.Addins; | ||
37 | using Mono.Addins.Description; | ||
38 | using OpenSim.Framework; | ||
39 | |||
40 | namespace OpenSim.Server.Base | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Command manager - | ||
44 | /// Wrapper for OpenSim.Framework.PluginManager to allow | ||
45 | /// us to add commands to the console to perform operations | ||
46 | /// on our repos and plugins | ||
47 | /// </summary> | ||
48 | public class CommandManager | ||
49 | { | ||
50 | public AddinRegistry PluginRegistry; | ||
51 | protected PluginManager PluginManager; | ||
52 | |||
53 | public CommandManager(AddinRegistry registry) | ||
54 | { | ||
55 | PluginRegistry = registry; | ||
56 | PluginManager = new PluginManager(PluginRegistry); | ||
57 | AddManagementCommands(); | ||
58 | } | ||
59 | |||
60 | private void AddManagementCommands() | ||
61 | { | ||
62 | // add plugin | ||
63 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
64 | "plugin add", "plugin add \"plugin index\"", | ||
65 | "Install plugin from repository.", | ||
66 | HandleConsoleInstallPlugin); | ||
67 | |||
68 | // remove plugin | ||
69 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
70 | "plugin remove", "plugin remove \"plugin index\"", | ||
71 | "Remove plugin from repository", | ||
72 | HandleConsoleUnInstallPlugin); | ||
73 | |||
74 | // list installed plugins | ||
75 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
76 | "plugin list installed", | ||
77 | "plugin list installed","List install plugins", | ||
78 | HandleConsoleListInstalledPlugin); | ||
79 | |||
80 | // list plugins available from registered repositories | ||
81 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
82 | "plugin list available", | ||
83 | "plugin list available","List available plugins", | ||
84 | HandleConsoleListAvailablePlugin); | ||
85 | // List available updates | ||
86 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
87 | "plugin updates", "plugin updates","List availble updates", | ||
88 | HandleConsoleListUpdates); | ||
89 | |||
90 | // Update plugin | ||
91 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
92 | "plugin update", "plugin update \"plugin index\"","Update the plugin", | ||
93 | HandleConsoleUpdatePlugin); | ||
94 | |||
95 | // Add repository | ||
96 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
97 | "repo add", "repo add \"url\"","Add repository", | ||
98 | HandleConsoleAddRepo); | ||
99 | |||
100 | // Refresh repo | ||
101 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
102 | "repo refresh", "repo refresh \"url\"", "Sync with a registered repository", | ||
103 | HandleConsoleGetRepo); | ||
104 | |||
105 | // Remove repository from registry | ||
106 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
107 | "repo remove", | ||
108 | "repo remove \"[url | index]\"", | ||
109 | "Remove repository from registry", | ||
110 | HandleConsoleRemoveRepo); | ||
111 | |||
112 | // Enable repo | ||
113 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
114 | "repo enable", "repo enable \"[url | index]\"", | ||
115 | "Enable registered repository", | ||
116 | HandleConsoleEnableRepo); | ||
117 | |||
118 | // Disable repo | ||
119 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
120 | "repo disable", "repo disable\"[url | index]\"", | ||
121 | "Disable registered repository", | ||
122 | HandleConsoleDisableRepo); | ||
123 | |||
124 | // List registered repositories | ||
125 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
126 | "repo list", "repo list", | ||
127 | "List registered repositories", | ||
128 | HandleConsoleListRepos); | ||
129 | |||
130 | // * | ||
131 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
132 | "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin", | ||
133 | HandleConsoleShowAddinInfo); | ||
134 | |||
135 | // Plugin disable | ||
136 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
137 | "plugin disable", "plugin disable \"plugin index\"", | ||
138 | "Disable a plugin", | ||
139 | HandleConsoleDisablePlugin); | ||
140 | |||
141 | // Enable plugin | ||
142 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
143 | "plugin enable", "plugin enable \"plugin index\"", | ||
144 | "Enable the selected plugin plugin", | ||
145 | HandleConsoleEnablePlugin); | ||
146 | } | ||
147 | |||
148 | #region console handlers | ||
149 | // Handle our console commands | ||
150 | // | ||
151 | // Install plugin from registered repository | ||
152 | /// <summary> | ||
153 | /// Handles the console install plugin command. Attempts to install the selected plugin | ||
154 | /// and | ||
155 | /// </summary> | ||
156 | /// <param name='module'> | ||
157 | /// Module. | ||
158 | /// </param> | ||
159 | /// <param name='cmd'> | ||
160 | /// Cmd. | ||
161 | /// </param> | ||
162 | private void HandleConsoleInstallPlugin(string module, string[] cmd) | ||
163 | { | ||
164 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
165 | |||
166 | if (cmd.Length == 3) | ||
167 | { | ||
168 | int ndx = Convert.ToInt16(cmd[2]); | ||
169 | if (PluginManager.InstallPlugin(ndx, out result) == true) | ||
170 | { | ||
171 | ArrayList s = new ArrayList(); | ||
172 | s.AddRange(result.Keys); | ||
173 | s.Sort(); | ||
174 | |||
175 | var list = result.Keys.ToList(); | ||
176 | list.Sort(); | ||
177 | foreach (var k in list) | ||
178 | { | ||
179 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
180 | bool enabled = (bool)plugin["enabled"]; | ||
181 | MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", | ||
182 | k, | ||
183 | enabled == true ? "[ ]" : "[X]", | ||
184 | plugin["name"], plugin["version"]); | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | // Remove installed plugin | ||
192 | private void HandleConsoleUnInstallPlugin(string module, string[] cmd) | ||
193 | { | ||
194 | if (cmd.Length == 3) | ||
195 | { | ||
196 | int ndx = Convert.ToInt16(cmd[2]); | ||
197 | PluginManager.UnInstall(ndx); | ||
198 | } | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | // List installed plugins | ||
203 | private void HandleConsoleListInstalledPlugin(string module, string[] cmd) | ||
204 | { | ||
205 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
206 | PluginManager.ListInstalledAddins(out result); | ||
207 | |||
208 | ArrayList s = new ArrayList(); | ||
209 | s.AddRange(result.Keys); | ||
210 | s.Sort(); | ||
211 | |||
212 | var list = result.Keys.ToList(); | ||
213 | list.Sort(); | ||
214 | foreach (var k in list) | ||
215 | { | ||
216 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
217 | bool enabled = (bool)plugin["enabled"]; | ||
218 | MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", | ||
219 | k, | ||
220 | enabled == true ? "[ ]" : "[X]", | ||
221 | plugin["name"], plugin["version"]); | ||
222 | } | ||
223 | return; | ||
224 | } | ||
225 | |||
226 | // List available plugins on registered repositories | ||
227 | private void HandleConsoleListAvailablePlugin(string module, string[] cmd) | ||
228 | { | ||
229 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
230 | PluginManager.ListAvailable(out result); | ||
231 | |||
232 | var list = result.Keys.ToList(); | ||
233 | list.Sort(); | ||
234 | foreach (var k in list) | ||
235 | { | ||
236 | // name, version, repository | ||
237 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
238 | MainConsole.Instance.OutputFormat("{0}) {1} rev. {2} {3}", | ||
239 | k, | ||
240 | plugin["name"], | ||
241 | plugin["version"], | ||
242 | plugin["repository"]); | ||
243 | } | ||
244 | return; | ||
245 | } | ||
246 | |||
247 | // List available updates **not ready | ||
248 | private void HandleConsoleListUpdates(string module, string[] cmd) | ||
249 | { | ||
250 | PluginManager.ListUpdates(); | ||
251 | return; | ||
252 | } | ||
253 | |||
254 | // Update plugin **not ready | ||
255 | private void HandleConsoleUpdatePlugin(string module, string[] cmd) | ||
256 | { | ||
257 | MainConsole.Instance.Output(PluginManager.Update()); | ||
258 | return; | ||
259 | } | ||
260 | |||
261 | // Register repository | ||
262 | private void HandleConsoleAddRepo(string module, string[] cmd) | ||
263 | { | ||
264 | if ( cmd.Length == 3) | ||
265 | { | ||
266 | PluginManager.AddRepository(cmd[2]); | ||
267 | } | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | // Get repository status **not working | ||
272 | private void HandleConsoleGetRepo(string module, string[] cmd) | ||
273 | { | ||
274 | PluginManager.GetRepository(); | ||
275 | return; | ||
276 | } | ||
277 | |||
278 | // Remove registered repository | ||
279 | private void HandleConsoleRemoveRepo(string module, string[] cmd) | ||
280 | { | ||
281 | if (cmd.Length == 3) | ||
282 | PluginManager.RemoveRepository(cmd); | ||
283 | return; | ||
284 | } | ||
285 | |||
286 | // Enable repository | ||
287 | private void HandleConsoleEnableRepo(string module, string[] cmd) | ||
288 | { | ||
289 | PluginManager.EnableRepository(cmd); | ||
290 | return; | ||
291 | } | ||
292 | |||
293 | // Disable repository | ||
294 | private void HandleConsoleDisableRepo(string module, string[] cmd) | ||
295 | { | ||
296 | PluginManager.DisableRepository(cmd); | ||
297 | return; | ||
298 | } | ||
299 | |||
300 | // List repositories | ||
301 | private void HandleConsoleListRepos(string module, string[] cmd) | ||
302 | { | ||
303 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
304 | PluginManager.ListRepositories(out result); | ||
305 | |||
306 | var list = result.Keys.ToList(); | ||
307 | list.Sort(); | ||
308 | foreach (var k in list) | ||
309 | { | ||
310 | Dictionary<string, object> repo = (Dictionary<string, object>)result[k]; | ||
311 | bool enabled = (bool)repo["enabled"]; | ||
312 | MainConsole.Instance.OutputFormat("{0}) {1} {2}", | ||
313 | k, | ||
314 | enabled == true ? "[ ]" : "[X]", | ||
315 | repo["name"], repo["url"]); | ||
316 | } | ||
317 | |||
318 | return; | ||
319 | } | ||
320 | |||
321 | // Show description information | ||
322 | private void HandleConsoleShowAddinInfo(string module, string[] cmd) | ||
323 | { | ||
324 | if (cmd.Length >= 3) | ||
325 | { | ||
326 | |||
327 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
328 | |||
329 | int ndx = Convert.ToInt16(cmd[2]); | ||
330 | PluginManager.AddinInfo(ndx, out result); | ||
331 | |||
332 | MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}", | ||
333 | result["name"], | ||
334 | result["url"], | ||
335 | result["file_name"], | ||
336 | result["author"], | ||
337 | result["category"], | ||
338 | result["description"]); | ||
339 | |||
340 | return; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | // Disable plugin | ||
345 | private void HandleConsoleDisablePlugin(string module, string[] cmd) | ||
346 | { | ||
347 | PluginManager.DisablePlugin(cmd); | ||
348 | return; | ||
349 | } | ||
350 | |||
351 | // Enable plugin | ||
352 | private void HandleConsoleEnablePlugin(string module, string[] cmd) | ||
353 | { | ||
354 | PluginManager.EnablePlugin(cmd); | ||
355 | return; | ||
356 | } | ||
357 | #endregion | ||
358 | } | ||
359 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Base/Properties/AssemblyInfo.cs b/OpenSim/Server/Base/Properties/AssemblyInfo.cs index 4bbe358..b4732b8 100644 --- a/OpenSim/Server/Base/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Base/Properties/AssemblyInfo.cs | |||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices; | |||
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.7.5.*")] | 32 | [assembly: AssemblyVersion("0.7.6.*")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 42c82cf..2e6d279 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -33,11 +33,163 @@ using System.Xml.Serialization; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using Mono.Addins; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Framework.Servers; | ||
38 | 42 | ||
43 | |||
44 | [assembly:AddinRoot("Robust", "0.1")] | ||
39 | namespace OpenSim.Server.Base | 45 | namespace OpenSim.Server.Base |
40 | { | 46 | { |
47 | [TypeExtensionPoint(Path="/Robust/Connector", Name="RobustConnector")] | ||
48 | public interface IRobustConnector | ||
49 | { | ||
50 | string ConfigName | ||
51 | { | ||
52 | get; | ||
53 | } | ||
54 | |||
55 | bool Enabled | ||
56 | { | ||
57 | get; | ||
58 | } | ||
59 | |||
60 | string PluginPath | ||
61 | { | ||
62 | get; | ||
63 | set; | ||
64 | } | ||
65 | |||
66 | uint Configure(IConfigSource config); | ||
67 | void Initialize(IHttpServer server); | ||
68 | void Unload(); | ||
69 | } | ||
70 | |||
71 | public class PluginLoader | ||
72 | { | ||
73 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
74 | |||
75 | public AddinRegistry Registry | ||
76 | { | ||
77 | get; | ||
78 | private set; | ||
79 | } | ||
80 | |||
81 | public IConfigSource Config | ||
82 | { | ||
83 | get; | ||
84 | private set; | ||
85 | } | ||
86 | |||
87 | public PluginLoader(IConfigSource config, string registryPath) | ||
88 | { | ||
89 | Config = config; | ||
90 | |||
91 | Registry = new AddinRegistry(registryPath, "."); | ||
92 | suppress_console_output_(true); | ||
93 | AddinManager.Initialize(registryPath); | ||
94 | suppress_console_output_(false); | ||
95 | AddinManager.Registry.Update(); | ||
96 | CommandManager commandmanager = new CommandManager(Registry); | ||
97 | AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged); | ||
98 | } | ||
99 | |||
100 | private static TextWriter prev_console_; | ||
101 | // Temporarily masking the errors reported on start | ||
102 | // This is caused by a non-managed dll in the ./bin dir | ||
103 | // when the registry is initialized. The dll belongs to | ||
104 | // libomv, which has a hard-coded path to "." for pinvoke | ||
105 | // to load the openjpeg dll | ||
106 | // | ||
107 | // Will look for a way to fix, but for now this keeps the | ||
108 | // confusion to a minimum. this was copied from our region | ||
109 | // plugin loader, we have been doing this in there for a long time. | ||
110 | // | ||
111 | public void suppress_console_output_(bool save) | ||
112 | { | ||
113 | if (save) | ||
114 | { | ||
115 | prev_console_ = System.Console.Out; | ||
116 | System.Console.SetOut(new StreamWriter(Stream.Null)); | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | if (prev_console_ != null) | ||
121 | System.Console.SetOut(prev_console_); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | private void OnExtensionChanged(object s, ExtensionNodeEventArgs args) | ||
126 | { | ||
127 | IRobustConnector connector = (IRobustConnector)args.ExtensionObject; | ||
128 | Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id); | ||
129 | |||
130 | if(a == null) | ||
131 | { | ||
132 | Registry.Rebuild(null); | ||
133 | a = Registry.GetAddin(args.ExtensionNode.Addin.Id); | ||
134 | } | ||
135 | |||
136 | switch(args.Change) | ||
137 | { | ||
138 | case ExtensionChange.Add: | ||
139 | if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) | ||
140 | { | ||
141 | m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name); | ||
142 | connector.PluginPath = System.IO.Path.Combine(Registry.DefaultAddinsFolder,a.Name.Replace(',', '.')); } | ||
143 | else | ||
144 | { | ||
145 | m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name); | ||
146 | connector.PluginPath = a.AddinFile; | ||
147 | } | ||
148 | LoadPlugin(connector); | ||
149 | break; | ||
150 | case ExtensionChange.Remove: | ||
151 | m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); | ||
152 | UnloadPlugin(connector); | ||
153 | break; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | private void LoadPlugin(IRobustConnector connector) | ||
158 | { | ||
159 | IHttpServer server = null; | ||
160 | uint port = connector.Configure(Config); | ||
161 | |||
162 | if(connector.Enabled) | ||
163 | { | ||
164 | server = GetServer(connector, port); | ||
165 | connector.Initialize(server); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | private void UnloadPlugin(IRobustConnector connector) | ||
174 | { | ||
175 | m_log.InfoFormat("[Server]: Unloading {0}", connector.ConfigName); | ||
176 | |||
177 | connector.Unload(); | ||
178 | } | ||
179 | |||
180 | private IHttpServer GetServer(IRobustConnector connector, uint port) | ||
181 | { | ||
182 | IHttpServer server; | ||
183 | |||
184 | if(port != 0) | ||
185 | server = MainServer.GetHttpServer(port); | ||
186 | else | ||
187 | server = MainServer.Instance; | ||
188 | |||
189 | return server; | ||
190 | } | ||
191 | } | ||
192 | |||
41 | public static class ServerUtils | 193 | public static class ServerUtils |
42 | { | 194 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 195 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -63,20 +215,30 @@ namespace OpenSim.Server.Base | |||
63 | /// <param name="dllName"></param> | 215 | /// <param name="dllName"></param> |
64 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> | 216 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> |
65 | /// <returns></returns> | 217 | /// <returns></returns> |
66 | public static T LoadPlugin<T>(string dllName, Object[] args) where T:class | 218 | public static T LoadPlugin<T> (string dllName, Object[] args) where T:class |
67 | { | 219 | { |
68 | // This is good to debug configuration problems | 220 | // This is good to debug configuration problems |
69 | //if (dllName == string.Empty) | 221 | //if (dllName == string.Empty) |
70 | // Util.PrintCallStack(); | 222 | // Util.PrintCallStack(); |
71 | 223 | ||
72 | string[] parts = dllName.Split(new char[] {':'}); | ||
73 | |||
74 | dllName = parts[0]; | ||
75 | |||
76 | string className = String.Empty; | 224 | string className = String.Empty; |
77 | 225 | ||
78 | if (parts.Length > 1) | 226 | // The path for a dynamic plugin will contain ":" on Windows |
79 | className = parts[1]; | 227 | string[] parts = dllName.Split (new char[] {':'}); |
228 | |||
229 | if (parts [0].Length > 1) | ||
230 | { | ||
231 | dllName = parts [0]; | ||
232 | if (parts.Length > 1) | ||
233 | className = parts[1]; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | // This is Windows - we must replace the ":" in the path | ||
238 | dllName = String.Format ("{0}:{1}", parts [0], parts [1]); | ||
239 | if (parts.Length > 2) | ||
240 | className = parts[2]; | ||
241 | } | ||
80 | 242 | ||
81 | return LoadPlugin<T>(dllName, className, args); | 243 | return LoadPlugin<T>(dllName, className, args); |
82 | } | 244 | } |
@@ -118,8 +280,11 @@ namespace OpenSim.Server.Base | |||
118 | { | 280 | { |
119 | if (!(e is System.MissingMethodException)) | 281 | if (!(e is System.MissingMethodException)) |
120 | { | 282 | { |
121 | m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}", | 283 | m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}, {3}", |
122 | interfaceName, dllName, e.InnerException == null ? e.Message : e.InnerException.Message); | 284 | interfaceName, |
285 | dllName, | ||
286 | e.InnerException == null ? e.Message : e.InnerException.Message, | ||
287 | e.StackTrace); | ||
123 | } | 288 | } |
124 | return null; | 289 | return null; |
125 | } | 290 | } |
@@ -333,5 +498,42 @@ namespace OpenSim.Server.Base | |||
333 | 498 | ||
334 | return ret; | 499 | return ret; |
335 | } | 500 | } |
501 | |||
502 | public static IConfig GetConfig(string configFile, string configName) | ||
503 | { | ||
504 | IConfig config; | ||
505 | |||
506 | if (File.Exists(configFile)) | ||
507 | { | ||
508 | IConfigSource configsource = new IniConfigSource(configFile); | ||
509 | config = configsource.Configs[configName]; | ||
510 | } | ||
511 | else | ||
512 | config = null; | ||
513 | |||
514 | return config; | ||
515 | } | ||
516 | |||
517 | public static IConfigSource LoadInitialConfig(string url) | ||
518 | { | ||
519 | IConfigSource source = new XmlConfigSource(); | ||
520 | m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); | ||
521 | |||
522 | // The ini file path is a http URI | ||
523 | // Try to read it | ||
524 | try | ||
525 | { | ||
526 | XmlReader r = XmlReader.Create(url); | ||
527 | IConfigSource cs = new XmlConfigSource(r); | ||
528 | source.Merge(cs); | ||
529 | } | ||
530 | catch (Exception e) | ||
531 | { | ||
532 | m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); | ||
533 | Environment.Exit(1); | ||
534 | } | ||
535 | |||
536 | return source; | ||
537 | } | ||
336 | } | 538 | } |
337 | } | 539 | } |
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 5b23149..5aff72a 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -56,6 +56,12 @@ namespace OpenSim.Server.Base | |||
56 | // | 56 | // |
57 | protected string[] m_Arguments; | 57 | protected string[] m_Arguments; |
58 | 58 | ||
59 | public string ConfigDirectory | ||
60 | { | ||
61 | get; | ||
62 | private set; | ||
63 | } | ||
64 | |||
59 | // Run flag | 65 | // Run flag |
60 | // | 66 | // |
61 | private bool m_Running = true; | 67 | private bool m_Running = true; |
@@ -134,6 +140,8 @@ namespace OpenSim.Server.Base | |||
134 | startupConfig = Config.Configs["Startup"]; | 140 | startupConfig = Config.Configs["Startup"]; |
135 | } | 141 | } |
136 | 142 | ||
143 | ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); | ||
144 | |||
137 | prompt = startupConfig.GetString("Prompt", prompt); | 145 | prompt = startupConfig.GetString("Prompt", prompt); |
138 | 146 | ||
139 | // Allow derived classes to load config before the console is | 147 | // Allow derived classes to load config before the console is |
@@ -178,6 +186,10 @@ namespace OpenSim.Server.Base | |||
178 | XmlConfigurator.Configure(); | 186 | XmlConfigurator.Configure(); |
179 | } | 187 | } |
180 | 188 | ||
189 | // FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net | ||
190 | // XmlConfigurator calls first accross servers. | ||
191 | m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory); | ||
192 | |||
181 | RegisterCommonAppenders(startupConfig); | 193 | RegisterCommonAppenders(startupConfig); |
182 | 194 | ||
183 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) | 195 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) |
@@ -242,4 +254,4 @@ namespace OpenSim.Server.Base | |||
242 | { | 254 | { |
243 | } | 255 | } |
244 | } | 256 | } |
245 | } \ No newline at end of file | 257 | } |
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs index 71876da..72014db 100644 --- a/OpenSim/Server/Handlers/Base/ServerConnector.cs +++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs | |||
@@ -39,8 +39,75 @@ namespace OpenSim.Server.Handlers.Base | |||
39 | 39 | ||
40 | public class ServiceConnector : IServiceConnector | 40 | public class ServiceConnector : IServiceConnector |
41 | { | 41 | { |
42 | public virtual string ConfigURL | ||
43 | { | ||
44 | get { return String.Empty; } | ||
45 | } | ||
46 | |||
47 | public virtual string ConfigName | ||
48 | { | ||
49 | get; | ||
50 | protected set; | ||
51 | } | ||
52 | |||
53 | public virtual string ConfigFile | ||
54 | { | ||
55 | get; | ||
56 | protected set; | ||
57 | } | ||
58 | |||
59 | public virtual IConfigSource Config | ||
60 | { | ||
61 | get; | ||
62 | protected set; | ||
63 | } | ||
64 | |||
65 | public ServiceConnector() | ||
66 | { | ||
67 | } | ||
68 | |||
42 | public ServiceConnector(IConfigSource config, IHttpServer server, string configName) | 69 | public ServiceConnector(IConfigSource config, IHttpServer server, string configName) |
43 | { | 70 | { |
44 | } | 71 | } |
72 | |||
73 | // We call this from our plugin module to get our configuration | ||
74 | public IConfig GetConfig() | ||
75 | { | ||
76 | IConfig config = null; | ||
77 | config = ServerUtils.GetConfig(ConfigFile, ConfigName); | ||
78 | |||
79 | // Our file is not here? We can get one to bootstrap our plugin module | ||
80 | if ( config == null ) | ||
81 | { | ||
82 | IConfigSource remotesource = GetConfigSource(); | ||
83 | |||
84 | if (remotesource != null) | ||
85 | { | ||
86 | IniConfigSource initialconfig = new IniConfigSource(); | ||
87 | initialconfig.Merge (remotesource); | ||
88 | initialconfig.Save(ConfigFile); | ||
89 | } | ||
90 | |||
91 | config = remotesource.Configs[ConfigName]; | ||
92 | } | ||
93 | |||
94 | return config; | ||
95 | } | ||
96 | |||
97 | // We get our remote initial configuration for bootstrapping in case | ||
98 | // we have no configuration in our main file or in an existing | ||
99 | // modular config file. This is the last resort to bootstrap the | ||
100 | // configuration, likely a new plugin loading for the first time. | ||
101 | private IConfigSource GetConfigSource() | ||
102 | { | ||
103 | IConfigSource source = null; | ||
104 | |||
105 | source = ServerUtils.LoadInitialConfig(ConfigURL); | ||
106 | |||
107 | if (source == null) | ||
108 | System.Console.WriteLine(String.Format ("Config Url: {0} Not found!", ConfigURL)); | ||
109 | |||
110 | return source; | ||
111 | } | ||
45 | } | 112 | } |
46 | } | 113 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 965a54e..346af32 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -170,14 +170,6 @@ namespace OpenSim.Server.Handlers.Grid | |||
170 | public string JsonGetGridInfoMethod(string request, string path, string param, | 170 | public string JsonGetGridInfoMethod(string request, string path, string param, |
171 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 171 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
172 | { | 172 | { |
173 | string HomeURI = String.Empty; | ||
174 | IConfig cfg = m_Config.Configs["LoginService"]; | ||
175 | |||
176 | if (null != cfg) | ||
177 | { | ||
178 | HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); | ||
179 | } | ||
180 | |||
181 | OSDMap map = new OSDMap(); | 173 | OSDMap map = new OSDMap(); |
182 | 174 | ||
183 | foreach (string k in _info.Keys) | 175 | foreach (string k in _info.Keys) |
@@ -185,9 +177,20 @@ namespace OpenSim.Server.Handlers.Grid | |||
185 | map[k] = OSD.FromString(_info[k].ToString()); | 177 | map[k] = OSD.FromString(_info[k].ToString()); |
186 | } | 178 | } |
187 | 179 | ||
180 | string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", | ||
181 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
182 | |||
188 | if (!String.IsNullOrEmpty(HomeURI)) | 183 | if (!String.IsNullOrEmpty(HomeURI)) |
184 | map["home"] = OSD.FromString(HomeURI); | ||
185 | else // Legacy. Remove soon! | ||
189 | { | 186 | { |
190 | map["home"] = OSD.FromString(HomeURI); | 187 | IConfig cfg = m_Config.Configs["LoginService"]; |
188 | |||
189 | if (null != cfg) | ||
190 | HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); | ||
191 | |||
192 | if (!String.IsNullOrEmpty(HomeURI)) | ||
193 | map["home"] = OSD.FromString(HomeURI); | ||
191 | } | 194 | } |
192 | 195 | ||
193 | return OSDParser.SerializeJsonString(map).ToString(); | 196 | return OSDParser.SerializeJsonString(map).ToString(); |
diff --git a/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs index 53e9737..3295ffd 100644 --- a/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs | |||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices; | |||
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.7.5.*")] | 32 | [assembly: AssemblyVersion("0.7.6.*")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | |
diff --git a/OpenSim/Server/Properties/AssemblyInfo.cs b/OpenSim/Server/Properties/AssemblyInfo.cs index ebc10fb..ee45e10 100644 --- a/OpenSim/Server/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Properties/AssemblyInfo.cs | |||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices; | |||
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.7.5.*")] | 32 | [assembly: AssemblyVersion("0.7.6.*")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | [assembly: AssemblyFileVersion("1.0.0.0")] |
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index 45c13fb..8be69a9 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Framework.Servers; | |||
34 | using OpenSim.Framework.Servers.HttpServer; | 34 | using OpenSim.Framework.Servers.HttpServer; |
35 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
36 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
37 | using Mono.Addins; | ||
37 | 38 | ||
38 | namespace OpenSim.Server | 39 | namespace OpenSim.Server |
39 | { | 40 | { |
@@ -48,9 +49,13 @@ namespace OpenSim.Server | |||
48 | protected static List<IServiceConnector> m_ServiceConnectors = | 49 | protected static List<IServiceConnector> m_ServiceConnectors = |
49 | new List<IServiceConnector>(); | 50 | new List<IServiceConnector>(); |
50 | 51 | ||
52 | protected static PluginLoader loader; | ||
53 | |||
51 | public static int Main(string[] args) | 54 | public static int Main(string[] args) |
52 | { | 55 | { |
53 | m_Server = new HttpServerBase("R.O.B.U.S.T.", args); | 56 | m_Server = new HttpServerBase("R.O.B.U.S.T.", args); |
57 | |||
58 | string registryLocation; | ||
54 | 59 | ||
55 | IConfig serverConfig = m_Server.Config.Configs["Startup"]; | 60 | IConfig serverConfig = m_Server.Config.Configs["Startup"]; |
56 | if (serverConfig == null) | 61 | if (serverConfig == null) |
@@ -60,6 +65,8 @@ namespace OpenSim.Server | |||
60 | } | 65 | } |
61 | 66 | ||
62 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); | 67 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); |
68 | |||
69 | registryLocation = serverConfig.GetString("RegistryLocation","."); | ||
63 | 70 | ||
64 | IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; | 71 | IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; |
65 | if (servicesConfig != null) | 72 | if (servicesConfig != null) |
@@ -141,6 +148,9 @@ namespace OpenSim.Server | |||
141 | m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); | 148 | m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); |
142 | } | 149 | } |
143 | } | 150 | } |
151 | |||
152 | loader = new PluginLoader(m_Server.Config, registryLocation); | ||
153 | |||
144 | int res = m_Server.Run(); | 154 | int res = m_Server.Run(); |
145 | 155 | ||
146 | Environment.Exit(res); | 156 | Environment.Exit(res); |