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/Grid/GridServer/GridServerBase.cs | 27 +++++++++------------------ OpenSim/Grid/GridServer/IGridPlugin.cs | 3 ++- 2 files changed, 11 insertions(+), 19 deletions(-) (limited to 'OpenSim/Grid/GridServer') diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 7891c29..010c250 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -116,26 +116,17 @@ namespace OpenSim.Grid.GridServer m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod)); } - protected void LoadGridPlugins() + protected void grid_plugin_initialiser_ (IPlugin plugin) { - // Temporary hack to stop mono-addins scanning warnings from coming out on 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); + IGridPlugin p = plugin as IGridPlugin; + p.Initialise (this); + } - ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/GridServer"); - foreach (TypeExtensionNode node in nodes) - { - m_log.Info("[GRID PLUGINS]: Loading OpenSim plugin " + node.Path); - IGridPlugin plugin = (IGridPlugin)node.CreateInstance(); - plugin.Initialise(this); - m_plugins.Add(plugin); - } + protected void LoadGridPlugins() + { + PluginLoader loader = new PluginLoader ("."); + loader.Load ("/OpenSim/GridServer", grid_plugin_initialiser_); + m_plugins = loader.Plugins; } protected virtual void SetupGridManager() diff --git a/OpenSim/Grid/GridServer/IGridPlugin.cs b/OpenSim/Grid/GridServer/IGridPlugin.cs index 47273a2..d51deb3 100644 --- a/OpenSim/Grid/GridServer/IGridPlugin.cs +++ b/OpenSim/Grid/GridServer/IGridPlugin.cs @@ -27,13 +27,14 @@ */ using Mono.Addins; +using OpenSim.Framework; [assembly : AddinRoot("OpenSim", "0.5")] namespace OpenSim.Grid.GridServer { [TypeExtensionPoint("/OpenSim/GridServer")] - public interface IGridPlugin + public interface IGridPlugin : IPlugin { void Initialise(GridServerBase gridServer); void Close(); -- cgit v1.1