diff options
author | Diva Canto | 2010-01-10 19:19:34 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-10 19:19:34 -0800 |
commit | 49618dc102c42b7125303511d826f76f0ebaab4c (patch) | |
tree | fba3817eb6ee8547914892dbae45c955d78734e8 /OpenSim/Framework/Communications | |
parent | Removed refs to OpenIdService in UserServer. (diff) | |
download | opensim-SC_OLD-49618dc102c42b7125303511d826f76f0ebaab4c.zip opensim-SC_OLD-49618dc102c42b7125303511d826f76f0ebaab4c.tar.gz opensim-SC_OLD-49618dc102c42b7125303511d826f76f0ebaab4c.tar.bz2 opensim-SC_OLD-49618dc102c42b7125303511d826f76f0ebaab4c.tar.xz |
Moved GridInfo service from where it was to Handlers/Grid
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Services/GridInfoService.cs | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs deleted file mode 100644 index cd2a152..0000000 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | |||
39 | namespace OpenSim.Framework.Communications.Services | ||
40 | { | ||
41 | public class GridInfoService | ||
42 | { | ||
43 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private Hashtable _info = new Hashtable(); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Instantiate a GridInfoService object. | ||
49 | /// </summary> | ||
50 | /// <param name="configPath">path to config path containing | ||
51 | /// grid information</param> | ||
52 | /// <remarks> | ||
53 | /// GridInfoService uses the [GridInfo] section of the | ||
54 | /// standard OpenSim.ini file --- which is not optimal, but | ||
55 | /// anything else requires a general redesign of the config | ||
56 | /// system. | ||
57 | /// </remarks> | ||
58 | public GridInfoService(IConfigSource configSource) | ||
59 | { | ||
60 | loadGridInfo(configSource); | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Default constructor, uses OpenSim.ini. | ||
65 | /// </summary> | ||
66 | public GridInfoService() | ||
67 | { | ||
68 | try | ||
69 | { | ||
70 | IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); | ||
71 | loadGridInfo(configSource); | ||
72 | } | ||
73 | catch (FileNotFoundException) | ||
74 | { | ||
75 | _log.Warn( | ||
76 | "[GRID INFO SERVICE]: No OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | private void loadGridInfo(IConfigSource configSource) | ||
81 | { | ||
82 | _info["platform"] = "OpenSim"; | ||
83 | try | ||
84 | { | ||
85 | IConfig startupCfg = configSource.Configs["Startup"]; | ||
86 | IConfig gridCfg = configSource.Configs["GridInfo"]; | ||
87 | IConfig netCfg = configSource.Configs["Network"]; | ||
88 | |||
89 | bool grid = startupCfg.GetBoolean("gridmode", false); | ||
90 | |||
91 | if (grid) | ||
92 | _info["mode"] = "grid"; | ||
93 | else | ||
94 | _info["mode"] = "standalone"; | ||
95 | |||
96 | |||
97 | if (null != gridCfg) | ||
98 | { | ||
99 | foreach (string k in gridCfg.GetKeys()) | ||
100 | { | ||
101 | _info[k] = gridCfg.GetString(k); | ||
102 | } | ||
103 | } | ||
104 | else if (null != netCfg) | ||
105 | { | ||
106 | if (grid) | ||
107 | _info["login"] | ||
108 | = netCfg.GetString( | ||
109 | "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()); | ||
110 | else | ||
111 | _info["login"] | ||
112 | = String.Format( | ||
113 | "http://127.0.0.1:{0}/", | ||
114 | netCfg.GetString( | ||
115 | "http_listener_port", ConfigSettings.DefaultRegionHttpPort.ToString())); | ||
116 | |||
117 | IssueWarning(); | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | _info["login"] = "http://127.0.0.1:9000/"; | ||
122 | IssueWarning(); | ||
123 | } | ||
124 | } | ||
125 | catch (Exception) | ||
126 | { | ||
127 | _log.Debug("[GRID INFO SERVICE]: Cannot get grid info from config source, using minimal defaults"); | ||
128 | } | ||
129 | |||
130 | _log.DebugFormat("[GRID INFO SERVICE]: Grid info service initialized with {0} keys", _info.Count); | ||
131 | |||
132 | } | ||
133 | |||
134 | private void IssueWarning() | ||
135 | { | ||
136 | _log.Warn("[GRID INFO SERVICE]: found no [GridInfo] section in your OpenSim.ini"); | ||
137 | _log.Warn("[GRID INFO SERVICE]: trying to guess sensible defaults, you might want to provide better ones:"); | ||
138 | |||
139 | foreach (string k in _info.Keys) | ||
140 | { | ||
141 | _log.WarnFormat("[GRID INFO SERVICE]: {0}: {1}", k, _info[k]); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
146 | { | ||
147 | XmlRpcResponse response = new XmlRpcResponse(); | ||
148 | Hashtable responseData = new Hashtable(); | ||
149 | |||
150 | _log.Info("[GRID INFO SERVICE]: Request for grid info"); | ||
151 | |||
152 | foreach (string k in _info.Keys) | ||
153 | { | ||
154 | responseData[k] = _info[k]; | ||
155 | } | ||
156 | response.Value = responseData; | ||
157 | |||
158 | return response; | ||
159 | } | ||
160 | |||
161 | public string RestGetGridInfoMethod(string request, string path, string param, | ||
162 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
163 | { | ||
164 | StringBuilder sb = new StringBuilder(); | ||
165 | |||
166 | sb.Append("<gridinfo>\n"); | ||
167 | foreach (string k in _info.Keys) | ||
168 | { | ||
169 | sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]); | ||
170 | } | ||
171 | sb.Append("</gridinfo>\n"); | ||
172 | |||
173 | return sb.ToString(); | ||
174 | } | ||
175 | } | ||
176 | } | ||