From ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 27 Jun 2008 02:15:57 +0000 Subject: Mantis#1591. Thank you graciously, Sempuki for a patch that: Currently module loading is done ad-hoc. I propose creating a simple loader class that leverages Mono.Addins (and perhaps the new .NET addins when they become available in mono). Attached is a basic patch for review that compiles into HEAD, but doesn't yet replace any existing ad-hoc loaders. --- OpenSim/Region/Application/IApplicationPlugin.cs | 4 +-- OpenSim/Region/Application/OpenSimBase.cs | 41 +++++++++--------------- 2 files changed, 17 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 7ca4383..e1187ae 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -26,15 +26,15 @@ */ using Mono.Addins; +using OpenSim.Framework; [assembly : AddinRoot("OpenSim", "0.5")] namespace OpenSim { [TypeExtensionPoint("/OpenSim/Startup")] - public interface IApplicationPlugin + public interface IApplicationPlugin : IPlugin { void Initialise(OpenSimBase openSim); - void Close(); } } diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 49e1da3..d0d5378 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -149,24 +149,6 @@ namespace OpenSim { IConfig startupConfig = configSource.Configs["Startup"]; - // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache - // Hence, as a temporary solution we'll remove it before each startup - if (Directory.Exists("addin-db-000")) - Directory.Delete("addin-db-000", true); - - if (Directory.Exists("addin-db-001")) - Directory.Delete("addin-db-001", true); - - // This blocks the scanning warnings from outputing to the console. - TextWriter oldOutput = Console.Out; - Console.SetOut(new StreamWriter(Stream.Null)); - - AddinManager.Initialize("."); - AddinManager.Registry.Update(null); - - // Returns the console.writelines back to the console's stream - Console.SetOut(oldOutput); - Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); m_config = new OpenSimConfigSource(); @@ -347,6 +329,19 @@ namespace OpenSim m_networkServersInfo.loadFromConfiguration(m_config.Source); } + protected void plugin_initialiser_ (IPlugin plugin) + { + IApplicationPlugin p = plugin as IApplicationPlugin; + p.Initialise (this); + } + + protected void LoadPlugins() + { + PluginLoader loader = new PluginLoader ("."); + loader.Load ("/OpenSim/Startup", plugin_initialiser_); + m_plugins = loader.Plugins; + } + /// /// Performs initialisation of the scene, such as loading configuration from disk. /// @@ -403,14 +398,7 @@ namespace OpenSim // Create a ModuleLoader instance m_moduleLoader = new ModuleLoader(m_config.Source); - ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); - foreach (TypeExtensionNode node in nodes) - { - m_log.InfoFormat("[PLUGINS]: Loading OpenSim application plugin {0}", node.Path); - IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); - plugin.Initialise(this); - m_plugins.Add(plugin); - } + LoadPlugins(); } protected override void Initialize() @@ -740,3 +728,4 @@ namespace OpenSim } } + -- cgit v1.1