Another bit of refactoring to try to make sense of OpenSim.Framework.Communications. Everything that looks like a service, with service handlers, moved to .Services -- i.e. LoginService and Response, and GridInfoService. The rest of the changes were to adapt to the new locations of those files.

0.6.5-rc1
diva 2009-03-29 22:04:45 +00:00
parent 08732b65be
commit f7eac63e01
12 changed files with 2114 additions and 2087 deletions

View File

@ -30,6 +30,7 @@ using System.Reflection;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Services;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Region.Communications.Hypergrid; using OpenSim.Region.Communications.Hypergrid;
@ -210,7 +211,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
{ {
// Standalone mode // Standalone mode
HGInventoryService inventoryService = new HGInventoryService(m_openSim.NetServersInfo.InventoryURL, null, false); HGInventoryServiceClient inventoryService = new HGInventoryServiceClient(m_openSim.NetServersInfo.InventoryURL, null, false);
inventoryService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneInventoryPlugin, m_openSim.ConfigurationSettings.StandaloneInventorySource); inventoryService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneInventoryPlugin, m_openSim.ConfigurationSettings.StandaloneInventorySource);
LocalUserServices userService = LocalUserServices userService =

View File

@ -36,6 +36,7 @@ using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Services;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Capabilities; using OpenSim.Framework.Communications.Capabilities;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;

View File

@ -1,172 +1,172 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the * * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications namespace OpenSim.Framework.Communications.Services
{ {
public class GridInfoService public class GridInfoService
{ {
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Hashtable _info = new Hashtable(); private Hashtable _info = new Hashtable();
/// <summary> /// <summary>
/// Instantiate a GridInfoService object. /// Instantiate a GridInfoService object.
/// </summary> /// </summary>
/// <param name="configPath">path to config path containing /// <param name="configPath">path to config path containing
/// grid information</param> /// grid information</param>
/// <remarks> /// <remarks>
/// GridInfoService uses the [GridInfo] section of the /// GridInfoService uses the [GridInfo] section of the
/// standard OpenSim.ini file --- which is not optimal, but /// standard OpenSim.ini file --- which is not optimal, but
/// anything else requires a general redesign of the config /// anything else requires a general redesign of the config
/// system. /// system.
/// </remarks> /// </remarks>
public GridInfoService(IConfigSource configSource) public GridInfoService(IConfigSource configSource)
{ {
loadGridInfo(configSource); loadGridInfo(configSource);
} }
/// <summary> /// <summary>
/// Default constructor, uses OpenSim.ini. /// Default constructor, uses OpenSim.ini.
/// </summary> /// </summary>
public GridInfoService() public GridInfoService()
{ {
try try
{ {
IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini"));
loadGridInfo(configSource); loadGridInfo(configSource);
} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
_log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users");
} }
} }
private void loadGridInfo(IConfigSource configSource) private void loadGridInfo(IConfigSource configSource)
{ {
_info["platform"] = "OpenSim"; _info["platform"] = "OpenSim";
try try
{ {
IConfig startupCfg = configSource.Configs["Startup"]; IConfig startupCfg = configSource.Configs["Startup"];
IConfig gridCfg = configSource.Configs["GridInfo"]; IConfig gridCfg = configSource.Configs["GridInfo"];
IConfig netCfg = configSource.Configs["Network"]; IConfig netCfg = configSource.Configs["Network"];
bool grid = startupCfg.GetBoolean("gridmode", false); bool grid = startupCfg.GetBoolean("gridmode", false);
if (grid) if (grid)
_info["mode"] = "grid"; _info["mode"] = "grid";
else else
_info["mode"] = "standalone"; _info["mode"] = "standalone";
if (null != gridCfg) if (null != gridCfg)
{ {
foreach (string k in gridCfg.GetKeys()) foreach (string k in gridCfg.GetKeys())
{ {
_info[k] = gridCfg.GetString(k); _info[k] = gridCfg.GetString(k);
} }
} }
else if (null != netCfg) else if (null != netCfg)
{ {
if (grid) if (grid)
_info["login"] _info["login"]
= netCfg.GetString( = netCfg.GetString(
"user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
else else
_info["login"] _info["login"]
= String.Format( = String.Format(
"http://127.0.0.1:{0}/", "http://127.0.0.1:{0}/",
netCfg.GetString( netCfg.GetString(
"http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString()));
IssueWarning(); IssueWarning();
} }
else else
{ {
_info["login"] = "http://127.0.0.1:9000/"; _info["login"] = "http://127.0.0.1:9000/";
IssueWarning(); IssueWarning();
} }
} }
catch (Exception) catch (Exception)
{ {
_log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults");
} }
_log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count);
} }
private void IssueWarning() private void IssueWarning()
{ {
_log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini");
_log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:");
foreach (string k in _info.Keys) foreach (string k in _info.Keys)
{ {
_log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]);
} }
} }
public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request)
{ {
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
_log.Info("[GridInfo]: Request for grid info"); _log.Info("[GridInfo]: Request for grid info");
foreach (string k in _info.Keys) foreach (string k in _info.Keys)
{ {
responseData[k] = _info[k]; responseData[k] = _info[k];
} }
response.Value = responseData; response.Value = responseData;
return response; return response;
} }
public string RestGetGridInfoMethod(string request, string path, string param, public string RestGetGridInfoMethod(string request, string path, string param,
OSHttpRequest httpRequest, OSHttpResponse httpResponse) OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append("<gridinfo>\n"); sb.Append("<gridinfo>\n");
foreach (string k in _info.Keys) foreach (string k in _info.Keys)
{ {
sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]); sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]);
} }
sb.Append("</gridinfo>\n"); sb.Append("</gridinfo>\n");
return sb.ToString(); return sb.ToString();
} }
} }
} }

View File

@ -52,19 +52,41 @@ namespace OpenSim.Framework.Communications.Services
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private InventoryServiceBase m_inventoryService; private InventoryServiceBase m_inventoryService;
private UserManagerBase m_userService;
IAssetDataPlugin m_assetProvider;
IHttpServer httpServer; IHttpServer httpServer;
private string m_thisInventoryUrl = "http://localhost:9000"; private string m_thisInventoryUrl = "http://localhost:9000";
private string m_thisHostname = "127.0.0.1"; private string m_thisHostname = "127.0.0.1";
private uint m_thisPort = 9000; private uint m_thisPort = 9000;
// These two used for local access, standalone mode
private UserManagerBase m_userService = null;
IAssetDataPlugin m_assetProvider = null;
public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string url) // These two used for remote access
string m_UserServerURL = string.Empty;
string m_AssetServerURL = string.Empty;
// Constructor for grid inventory server
public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl)
{
m_UserServerURL = userServiceURL;
m_AssetServerURL = assetServiceURL;
Init(invService, thisurl, httpserver);
}
// Constructor for standalone mode
public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl)
{
m_userService = userService;
m_assetProvider = assetService;
Init(invService, thisurl, httpserver);
}
private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver)
{ {
m_inventoryService = invService; m_inventoryService = invService;
m_userService = userService; m_thisInventoryUrl = thisurl;
m_thisInventoryUrl = url;
if (!m_thisInventoryUrl.EndsWith("/")) if (!m_thisInventoryUrl.EndsWith("/"))
m_thisInventoryUrl += "/"; m_thisInventoryUrl += "/";
@ -75,7 +97,6 @@ namespace OpenSim.Framework.Communications.Services
m_thisPort = (uint)uri.Port; m_thisPort = (uint)uri.Port;
} }
m_assetProvider = assetService;
httpServer = httpserver; httpServer = httpserver;
AddHttpHandlers(); AddHttpHandlers();

View File

@ -34,6 +34,7 @@ using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers; using NUnit.Framework.SyntaxHelpers;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Services;
using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.Local;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
using OpenSim.Client.Linden; using OpenSim.Client.Linden;

View File

@ -34,6 +34,7 @@ using log4net.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Services;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Grid.Communications.OGS1; using OpenSim.Grid.Communications.OGS1;

View File

@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Services;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Capabilities; using OpenSim.Framework.Communications.Capabilities;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;

View File

@ -36,6 +36,7 @@ using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Services;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;

View File

@ -59,7 +59,7 @@ namespace OpenSim.Region.Communications.Hypergrid
m_osw = gridInterComms; m_osw = gridInterComms;
// The HG InventoryService always uses secure handlers // The HG InventoryService always uses secure handlers
HGInventoryService invService = new HGInventoryService(serversInfo.InventoryURL, this.m_userProfileCacheService, true); HGInventoryServiceClient invService = new HGInventoryServiceClient(serversInfo.InventoryURL, this.m_userProfileCacheService, true);
AddSecureInventoryService(invService); AddSecureInventoryService(invService);
m_defaultInventoryHost = invService.Host; m_defaultInventoryHost = invService.Host;
if (SecureInventoryService != null) if (SecureInventoryService != null)

View File

@ -40,7 +40,7 @@ using OpenSim.Region.Communications.Local;
namespace OpenSim.Region.Communications.Hypergrid namespace OpenSim.Region.Communications.Hypergrid
{ {
public class HGInventoryService : LocalInventoryService, ISecureInventoryService public class HGInventoryServiceClient : LocalInventoryService, ISecureInventoryService
{ {
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -58,7 +58,7 @@ namespace OpenSim.Region.Communications.Hypergrid
set { m_userProfileCache = value; } set { m_userProfileCache = value; }
} }
public HGInventoryService(string inventoryServerUrl, UserProfileCacheService userProfileCacheService, bool gridmode) public HGInventoryServiceClient(string inventoryServerUrl, UserProfileCacheService userProfileCacheService, bool gridmode)
{ {
_inventoryServerUrl = HGNetworkServersInfo.ServerURI(inventoryServerUrl); _inventoryServerUrl = HGNetworkServersInfo.ServerURI(inventoryServerUrl);
//m_Uri = new Uri(_inventoryServerUrl); //m_Uri = new Uri(_inventoryServerUrl);