Refactoring of CreateCommsManagerPlugin.

Plus some general cleanup of a few other files (deleting excess blank lines etc)
0.6.4-rc1
MW 2009-03-03 12:51:54 +00:00
parent 8ebd5b409a
commit 76133d0763
4 changed files with 34 additions and 70 deletions

View File

@ -176,10 +176,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
LocalBackEndServices backendService = new LocalBackEndServices(); LocalBackEndServices backendService = new LocalBackEndServices();
LocalLoginService loginService = LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
new LocalLoginService(
userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo,
m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
m_commsManager m_commsManager
= new CommunicationsLocal( = new CommunicationsLocal(
@ -187,20 +184,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
inventoryService, backendService, userService, inventoryService, backendService, userService,
libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
// set up XMLRPC handler for client's initial login request message CreateGridInfoService();
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
// provides the web form login
m_httpServer.AddHTTPHandler("login", loginService.ProcessHTMLLogin);
// Provides the LLSD login
m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod);
// provide grid info
// m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini")));
m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source);
m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
} }
protected virtual void InitialiseGridServices(LibraryRootFolder libraryRootFolder) protected virtual void InitialiseGridServices(LibraryRootFolder libraryRootFolder)
@ -226,11 +210,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
//LocalBackEndServices backendService = new LocalBackEndServices(); //LocalBackEndServices backendService = new LocalBackEndServices();
HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager);
LocalLoginService loginService = LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, gridService.LocalBackend);
new LocalLoginService(
userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, gridService.LocalBackend, m_openSim.NetServersInfo,
m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
userService, userService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); userService, userService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
@ -238,6 +218,26 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
inventoryService.UserProfileCache = m_commsManager.UserProfileCacheService; inventoryService.UserProfileCache = m_commsManager.UserProfileCacheService;
HGServices = gridService; HGServices = gridService;
CreateGridInfoService();
}
protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
{
m_commsManager = new HGCommunicationsGridMode(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager, libraryRootFolder);
HGServices = ((HGCommunicationsGridMode)m_commsManager).HGServices;
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
}
private LocalLoginService CreateLoginService(LibraryRootFolder libraryRootFolder, IInterServiceInventoryServices inventoryService, LocalUserServices userService, LocalBackEndServices backendService)
{
LocalLoginService loginService =
new LocalLoginService(
userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo,
m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder);
// set up XMLRPC handler for client's initial login request message // set up XMLRPC handler for client's initial login request message
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
@ -247,20 +247,16 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// Provides the LLSD login // Provides the LLSD login
m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod); m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod);
return loginService;
}
private void CreateGridInfoService()
{
// provide grid info // provide grid info
// m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini"))); // m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini")));
m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source); m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source);
m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod)); m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
} }
protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
{
m_commsManager = new HGCommunicationsGridMode(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager, libraryRootFolder);
HGServices = ((HGCommunicationsGridMode)m_commsManager).HGServices;
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
}
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
@ -47,11 +48,13 @@ namespace OpenSim.Client.Linden
if ((m_scene != null) && (m_createClientStack)) if ((m_scene != null) && (m_createClientStack))
{ {
m_log.Info("[LLClientStackModule] Starting up LLClientStack."); m_log.Info("[LLClientStackModule] Starting up LLClientStack.");
uint port = (uint)m_scene.RegionInfo.InternalEndPoint.Port; IPEndPoint endPoint = m_scene.RegionInfo.InternalEndPoint;
uint port = (uint)endPoint.Port;
m_clientStackManager = new ClientStackManager(m_clientStackDll); m_clientStackManager = new ClientStackManager(m_clientStackDll);
m_clientServer m_clientServer
= m_clientStackManager.CreateServer(m_scene.RegionInfo.InternalEndPoint.Address, = m_clientStackManager.CreateServer(endPoint.Address,
ref port, m_scene.RegionInfo.ProxyOffset, m_scene.RegionInfo.m_allow_alternate_ports, m_source, ref port, m_scene.RegionInfo.ProxyOffset, m_scene.RegionInfo.m_allow_alternate_ports, m_source,
m_scene.CommsManager.AssetCache, m_scene.AuthenticateHandler); m_scene.CommsManager.AssetCache, m_scene.AuthenticateHandler);

View File

@ -766,8 +766,7 @@ namespace OpenSim.Framework
} }
memory.Position = 0; memory.Position = 0;
// MemoryStream outStream = new MemoryStream();
byte[] compressed = new byte[memory.Length]; byte[] compressed = new byte[memory.Length];
memory.Read(compressed, 0, compressed.Length); memory.Read(compressed, 0, compressed.Length);

View File

@ -206,7 +206,6 @@ namespace OpenSim
} }
AddPluginCommands(); AddPluginCommands();
} }
protected virtual void AddPluginCommands() protected virtual void AddPluginCommands()
@ -269,14 +268,10 @@ namespace OpenSim
protected override void Initialize() protected override void Initialize()
{ {
//
// Called from base.StartUp() // Called from base.StartUp()
//
m_httpServerPort = m_networkServersInfo.HttpListenerPort; m_httpServerPort = m_networkServersInfo.HttpListenerPort;
InitialiseAssetCache(); InitialiseAssetCache();
m_sceneManager.OnRestartSim += handleRestartRegion; m_sceneManager.OnRestartSim += handleRestartRegion;
} }
@ -291,10 +286,8 @@ namespace OpenSim
/// returns an IAssetCache implementation, if possible. This is a virtual /// returns an IAssetCache implementation, if possible. This is a virtual
/// method. /// method.
/// </summary> /// </summary>
protected virtual void InitialiseAssetCache() protected virtual void InitialiseAssetCache()
{ {
LegacyAssetClientPluginInitialiser linit = null; LegacyAssetClientPluginInitialiser linit = null;
CryptoAssetClientPluginInitialiser cinit = null; CryptoAssetClientPluginInitialiser cinit = null;
AssetClientPluginInitialiser init = null; AssetClientPluginInitialiser init = null;
@ -308,7 +301,6 @@ namespace OpenSim
// If "default" is specified, then the value is adjusted // If "default" is specified, then the value is adjusted
// according to whether or not the server is running in // according to whether or not the server is running in
// standalone mode. // standalone mode.
if (mode.ToLower() == "default") if (mode.ToLower() == "default")
{ {
if (m_configSettings.Standalone == false) if (m_configSettings.Standalone == false)
@ -319,19 +311,15 @@ namespace OpenSim
switch (mode.ToLower()) switch (mode.ToLower())
{ {
// If grid is specified then the grid server is chose regardless // If grid is specified then the grid server is chose regardless
// of whether the server is standalone. // of whether the server is standalone.
case "grid" : case "grid" :
linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("Grid", linit); assetServer = loadAssetServer("Grid", linit);
break; break;
// If cryptogrid is specified then the cryptogrid server is chose regardless // If cryptogrid is specified then the cryptogrid server is chose regardless
// of whether the server is standalone. // of whether the server is standalone.
case "cryptogrid" : case "cryptogrid" :
cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, true); Environment.CurrentDirectory, true);
@ -340,7 +328,6 @@ namespace OpenSim
// If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless
// of whether the server is standalone. // of whether the server is standalone.
case "cryptogrid_eou" : case "cryptogrid_eou" :
cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, false); Environment.CurrentDirectory, false);
@ -349,7 +336,6 @@ namespace OpenSim
// If file is specified then the file server is chose regardless // If file is specified then the file server is chose regardless
// of whether the server is standalone. // of whether the server is standalone.
case "file" : case "file" :
linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("File", linit); assetServer = loadAssetServer("File", linit);
@ -358,14 +344,12 @@ namespace OpenSim
// If local is specified then we're going to use the local SQL server // If local is specified then we're going to use the local SQL server
// implementation. We drop through, because that will be the fallback // implementation. We drop through, because that will be the fallback
// for the following default clause too. // for the following default clause too.
case "local" : case "local" :
break; break;
// If the asset_database value is none of the previously mentioned strings, then we // If the asset_database value is none of the previously mentioned strings, then we
// try to load a turnkey plugin that matches this value. If not we drop through to // try to load a turnkey plugin that matches this value. If not we drop through to
// a local default. // a local default.
default : default :
try try
{ {
@ -376,11 +360,9 @@ namespace OpenSim
catch {} catch {}
m_log.Info("[OPENSIMBASE] Default assetserver will be used"); m_log.Info("[OPENSIMBASE] Default assetserver will be used");
break; break;
} }
// Open the local SQL-based database asset server // Open the local SQL-based database asset server
if (assetServer == null) if (assetServer == null)
{ {
init = new AssetClientPluginInitialiser(m_configSettings); init = new AssetClientPluginInitialiser(m_configSettings);
@ -391,18 +373,14 @@ namespace OpenSim
// Initialize the asset cache, passing a reference to the selected // Initialize the asset cache, passing a reference to the selected
// asset server interface. // asset server interface.
m_assetCache = ResolveAssetCache(assetServer); m_assetCache = ResolveAssetCache(assetServer);
} }
// This method loads the identified asset server, passing an approrpiately // This method loads the identified asset server, passing an approrpiately
// initialized Initialise wrapper. There should to be exactly one match, // initialized Initialise wrapper. There should to be exactly one match,
// if not, then the first match is used. // if not, then the first match is used.
private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi) private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
{ {
if (id != null && id != String.Empty) if (id != null && id != String.Empty)
{ {
m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id); m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id);
@ -424,9 +402,7 @@ namespace OpenSim
m_log.DebugFormat("[OPENSIMBASE] Asset server {0} not loaded ({1})", id, e.Message); m_log.DebugFormat("[OPENSIMBASE] Asset server {0} not loaded ({1})", id, e.Message);
} }
} }
return null; return null;
} }
/// <summary> /// <summary>
@ -439,21 +415,14 @@ namespace OpenSim
/// The AssetCache value is obtained from the /// The AssetCache value is obtained from the
/// [StartUp]/AssetCache value in the configuration file. /// [StartUp]/AssetCache value in the configuration file.
/// </summary> /// </summary>
protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer)
{ {
IAssetCache assetCache = null; IAssetCache assetCache = null;
if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty) if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
{ {
m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache); m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache);
try try
{ {
PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer); PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init); PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init);
loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache)); loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache));
@ -461,7 +430,6 @@ namespace OpenSim
loader.Load(PLUGIN_ASSET_CACHE); loader.Load(PLUGIN_ASSET_CACHE);
if (loader.Plugins.Count > 0) if (loader.Plugins.Count > 0)
assetCache = (IAssetCache) loader.Plugins[0]; assetCache = (IAssetCache) loader.Plugins[0];
} }
catch (Exception e) catch (Exception e)
{ {
@ -471,9 +439,7 @@ namespace OpenSim
} }
// If everything else fails, we force load the built-in asset cache // If everything else fails, we force load the built-in asset cache
return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer)); return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer));
} }
public void ProcessLogin(bool LoginEnabled) public void ProcessLogin(bool LoginEnabled)