From 744100821d3af92f812b9f9e5545563f0130c65f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 May 2009 00:36:06 +0000 Subject: Refactor RegionAssetService to load the service connector rather than duplicating it's functionality --- OpenSim/SimulatorServices/RegionAssetService.cs | 74 +++++++++---------------- 1 file changed, 26 insertions(+), 48 deletions(-) (limited to 'OpenSim/SimulatorServices') diff --git a/OpenSim/SimulatorServices/RegionAssetService.cs b/OpenSim/SimulatorServices/RegionAssetService.cs index 3a7ccc8..06f42d3 100644 --- a/OpenSim/SimulatorServices/RegionAssetService.cs +++ b/OpenSim/SimulatorServices/RegionAssetService.cs @@ -25,51 +25,40 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Reflection; +using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; -using OpenSim.Server.Handlers.Asset; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; namespace OpenSim.Region.SimulatorServices { - public class RegionAssetService : IRegionModule + public class RegionAssetService : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; private static bool enabled = false; - private bool m_gridMode = false; - Scene m_scene; + private IConfigSource m_Config; + bool m_Registered = false; #region IRegionModule interface - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones in hypergrid mode - enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && - config.Configs["Startup"].GetBoolean("hypergrid", true)) || - ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); - m_gridMode = config.Configs["Startup"].GetBoolean("gridmode", true); - } + // This module is only on for standalones in hypergrid mode + enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && + config.Configs["Startup"].GetBoolean("hypergrid", true)) || + ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); } public void PostInitialise() { - if (enabled) - { - m_log.Info("[RegionAssetService]: Starting..."); - - new AssetService(m_scene,m_gridMode); - } } public void Close() @@ -81,43 +70,32 @@ namespace OpenSim.Region.SimulatorServices get { return "RegionAssetService"; } } - public bool IsSharedModule + public void AddRegion(Scene scene) { - get { return true; } - } + if (!enabled) + return; - #endregion + if (!m_Registered) + { + m_Registered = true; - } + m_log.Info("[RegionAssetService]: Starting..."); - public class AssetService - { - private bool m_doLookup = false; - private bool m_gridMode = false; + Object[] args = new Object[] { m_Config, scene.CommsManager.HttpServer }; - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } + ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); + } } -// private static readonly ILog m_log -// = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public AssetService(Scene m_scene, bool gridMode) + public void RemoveRegion(Scene scene) { - m_gridMode = gridMode; - AddHttpHandlers(m_scene); } - protected void AddHttpHandlers(Scene m_scene) + public void RegionLoaded(Scene scene) { - IHttpServer httpServer = m_scene.CommsManager.HttpServer; - - httpServer.AddStreamHandler(new AssetServerGetHandler(m_scene.AssetService)); - httpServer.AddStreamHandler(new AssetServerPostHandler(m_scene.AssetService)); - httpServer.AddStreamHandler(new AssetServerDeleteHandler(m_scene.AssetService)); + } + #endregion - } } } -- cgit v1.1