From de82bf9eb53cdd3be94b5a730b81c70d1e244b70 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 26 Feb 2009 15:21:06 +0000 Subject: [PATCH] Added a PostInitialise method to IApplicationPlugin, this allows us to do work in there knowing that all other ApplicationPlugins have been initialised by that time. Moved the loadRegions code in LoadRegionsPlugin to the PostInitialise method. --- .../LoadRegions/LoadRegionsPlugin.cs | 27 +++++++++------ .../RemoteController/RemoteAdminPlugin.cs | 4 +++ OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 4 +++ .../ScriptEngine/ScriptEnginePlugin.cs | 4 +++ OpenSim/Grid/GridServer/GridServerBase.cs | 33 ------------------- OpenSim/Grid/UserServer/Main.cs | 4 +-- .../Region/Application/IApplicationPlugin.cs | 1 + 7 files changed, 32 insertions(+), 45 deletions(-) diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index c988ad88cb..24372fe219 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -54,6 +54,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public string Version { get { return m_version; } } public string Name { get { return m_name; } } + protected OpenSimBase m_openSim; + public void Initialise() { m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); @@ -61,11 +63,16 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } public void Initialise(OpenSimBase openSim) + { + m_openSim = openSim; + } + + public void PostInitialise() { m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); IRegionLoader regionLoader; - if (openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem") + if (m_openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem") { m_log.Info("[LOADREGIONS]: Loading Region Info from filesystem"); regionLoader = new RegionLoaderFileSystem(); @@ -76,14 +83,14 @@ namespace OpenSim.ApplicationPlugins.LoadRegions regionLoader = new RegionLoaderWebServer(); } - regionLoader.SetIniConfigSource(openSim.ConfigSource.Source); + regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source); RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); - openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); - openSim.ModuleLoader.LoadDefaultSharedModule(new InstantMessageModule()); - openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); - openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); - openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); + m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); + m_openSim.ModuleLoader.LoadDefaultSharedModule(new InstantMessageModule()); + m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); + m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); + m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); if (!CheckRegionsForSanity(regionsToLoad)) { m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations"); @@ -94,11 +101,11 @@ namespace OpenSim.ApplicationPlugins.LoadRegions { m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + ")"); - openSim.CreateRegion(regionsToLoad[i], true); + m_openSim.CreateRegion(regionsToLoad[i], true); } - openSim.ModuleLoader.PostInitialise(); - openSim.ModuleLoader.ClearCache(); + m_openSim.ModuleLoader.PostInitialise(); + m_openSim.ModuleLoader.ClearCache(); } public void Dispose() diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 065f1eda2f..7f6ca9a041 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -131,6 +131,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController } } + public void PostInitialise() + { + } + public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index aa70886b6c..a0d4209e1f 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -246,6 +246,10 @@ namespace OpenSim.ApplicationPlugins.Rest } } + public virtual void PostInitialise() + { + } + private List _handlers = new List(); private Dictionary _agents = new Dictionary(); diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs index b4b5d5b62a..39bb88ed2d 100644 --- a/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs +++ b/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs @@ -63,6 +63,10 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine //m_OpenSim.Shutdown(); } + public void PostInitialise() + { + } + #region IApplicationPlugin stuff /// diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 1bc39557af..1ee97f490b 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -176,39 +176,6 @@ namespace OpenSim.Grid.GridServer public void CheckSims(object sender, ElapsedEventArgs e) { - /* - foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values) - { - string SimResponse = String.Empty; - try - { - WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); - CheckSim.Method = "GET"; - CheckSim.ContentType = "text/plaintext"; - CheckSim.ContentLength = 0; - - StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); - stOut.Write(String.Empty); - stOut.Close(); - - StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); - SimResponse = stIn.ReadToEnd(); - stIn.Close(); - } - catch - { - } - - if (SimResponse == "OK") - { - m_simProfileManager.SimProfiles[sim.UUID].online = true; - } - else - { - m_simProfileManager.SimProfiles[sim.UUID].online = false; - } - } - */ } public override void ShutdownSpecific() diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index dc38a3fedf..5a1dfd1215 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -130,10 +130,10 @@ namespace OpenSim.Grid.UserServer //Should be in modules? IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); - // IRegionProfileService regionProfileService = new RegionProfileServiceProxy(); + // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy(); RegisterInterface(inventoryService); - // RegisterInterface(regionProfileService); + // RegisterInterface(regionProfileService); return inventoryService; } diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 4fd93e857f..09e33369fc 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -32,6 +32,7 @@ namespace OpenSim public interface IApplicationPlugin : IPlugin { void Initialise(OpenSimBase openSim); + void PostInitialise(); } public class ApplicationPluginInitialiser : PluginInitialiserBase