From 3e71c71cbffb0de454759e2bbd0ff840dfa480bc Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 3 Oct 2012 16:07:11 -0400 Subject: Add modular configuration for Robust connectors We can provide modular ini for connectors... look for our configuration in the following places... 1) in the default ini/-inifile 2) in the named file (ConfigName) located in the configured directory (see Robust[.HG].ini [Start] section for ConfigDirectory) 3) in the repository named in the connector (ConfigURL) In this case, the file will be written into the configured directory with the specified See example connector/service @ https://github.com/BlueWall/SlipStream for testing. --- OpenSim/Server/Base/ServerUtils.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 42c82cf..4a696c4 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -33,6 +33,7 @@ using System.Xml.Serialization; using System.Text; using System.Collections.Generic; using log4net; +using Nini.Config; using OpenSim.Framework; using OpenMetaverse; @@ -333,5 +334,42 @@ namespace OpenSim.Server.Base return ret; } + + public static IConfig GetConfig(string configFile, string configName) + { + IConfig config; + + if (File.Exists(configFile)) + { + IConfigSource configsource = new IniConfigSource(configFile); + config = configsource.Configs[configName]; + } + else + config = null; + + return config; + } + + public static IConfigSource LoadInitialConfig(string url) + { + IConfigSource source = new XmlConfigSource(); + m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); + + // The ini file path is a http URI + // Try to read it + try + { + XmlReader r = XmlReader.Create(url); + IConfigSource cs = new XmlConfigSource(r); + source.Merge(cs); + } + catch (Exception e) + { + m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); + Environment.Exit(1); + } + + return source; + } } } -- cgit v1.1 From 440726250cc2a523463f575b682a6ddb6242408c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 6 Oct 2012 11:48:21 -0400 Subject: Added parts to manage repositories and plugin management This is working - more testing to follow, then soem documentation --- OpenSim/Server/Base/ServerUtils.cs | 106 +++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 4a696c4..6c6af62 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -36,9 +36,115 @@ using log4net; using Nini.Config; using OpenSim.Framework; using OpenMetaverse; +using Mono.Addins; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.Servers; + +[assembly:AddinRoot("Robust", "0.1")] namespace OpenSim.Server.Base { + [TypeExtensionPoint(Path="/Robust/Connector", Name="RobustConnector")] + public interface IRobustConnector + { + string ConfigName + { + get; + } + + bool Enabled + { + get; + } + + string PluginPath + { + get; + set; + } + + uint Configure(IConfigSource config); + void Initialize(IHttpServer server); + } + + public class PluginLoader + { + static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public AddinRegistry Registry + { + get; + private set; + } + + public IConfigSource Config + { + get; + private set; + } + + public PluginLoader(IConfigSource config, string registryPath) + { + Config = config; + + Registry = new AddinRegistry(registryPath, "."); + AddinManager.Initialize(registryPath); + AddinManager.Registry.Update(); + CommandManager commandmanager = new CommandManager(Registry); + AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged); + } + + private void OnExtensionChanged(object s, ExtensionNodeEventArgs args) + { + IRobustConnector connector = (IRobustConnector)args.ExtensionObject; + + Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id); + m_log.InfoFormat("[SERVER]: Extension Change: {0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); + + switch(args.Change) + { + case ExtensionChange.Add: + connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); + LoadPlugin(connector); + break; + case ExtensionChange.Remove: + UnloadPlugin(connector); + break; + } + } + + private void LoadPlugin(IRobustConnector connector) + { + IHttpServer server = null; + uint port = connector.Configure(Config); + + if(connector.Enabled) + { + server = GetServer(connector, port); + m_log.InfoFormat("[SERVER]: Path is {0}", connector.PluginPath); + connector.Initialize(server); + } + else + m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); + } + + private void UnloadPlugin(IRobustConnector connector) + { + } + + private IHttpServer GetServer(IRobustConnector connector, uint port) + { + IHttpServer server; + + if(port != 0) + server = MainServer.GetHttpServer(port); + else + server = MainServer.Instance; + + return server; + } + } + public static class ServerUtils { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From a960efeabaf00563fef551fd3b4f6d215306c3ea Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 9 Oct 2012 08:00:02 -0400 Subject: Fix registry issue Rebuild registry if loading from a local dll to give access to the addin data for it on the first pass. --- OpenSim/Server/Base/ServerUtils.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 6c6af62..d0b6c81 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -97,8 +97,14 @@ namespace OpenSim.Server.Base private void OnExtensionChanged(object s, ExtensionNodeEventArgs args) { IRobustConnector connector = (IRobustConnector)args.ExtensionObject; - Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id); + + if(a == null) + { + Registry.Rebuild(null); + a = Registry.GetAddin(args.ExtensionNode.Addin.Id); + } + m_log.InfoFormat("[SERVER]: Extension Change: {0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); switch(args.Change) -- cgit v1.1 From 83073ebd03e46789b3509af2c4e37ef3b3428174 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 10 Oct 2012 09:35:08 -0400 Subject: Implement plugin unloading Plugin may be enabled and disabled on the fly. --- OpenSim/Server/Base/ServerUtils.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index d0b6c81..6cbf332 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -65,6 +65,7 @@ namespace OpenSim.Server.Base uint Configure(IConfigSource config); void Initialize(IHttpServer server); + void Unload(); } public class PluginLoader @@ -105,12 +106,17 @@ namespace OpenSim.Server.Base a = Registry.GetAddin(args.ExtensionNode.Addin.Id); } - m_log.InfoFormat("[SERVER]: Extension Change: {0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); - switch(args.Change) { case ExtensionChange.Add: - connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); + if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) + { + connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); + } + else + { + connector.PluginPath = a.AddinFile; + } LoadPlugin(connector); break; case ExtensionChange.Remove: @@ -127,15 +133,19 @@ namespace OpenSim.Server.Base if(connector.Enabled) { server = GetServer(connector, port); - m_log.InfoFormat("[SERVER]: Path is {0}", connector.PluginPath); connector.Initialize(server); } else + { m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); + } } private void UnloadPlugin(IRobustConnector connector) { + m_log.InfoFormat("[Server]: Unloading {0}", connector.ConfigName); + + connector.Unload(); } private IHttpServer GetServer(IRobustConnector connector, uint port) -- cgit v1.1 From c8393dd0bedfa88c32c940249d86cb7781c1e815 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 11 Oct 2012 07:38:15 -0400 Subject: Add logging to help track sequence of events --- OpenSim/Server/Base/ServerUtils.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 6cbf332..8ecf3d3 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -111,10 +111,12 @@ namespace OpenSim.Server.Base case ExtensionChange.Add: if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) { + m_log.InfoFormat("[SERVER]: Adding {0}", a.Name); connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); } else { + m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); connector.PluginPath = a.AddinFile; } LoadPlugin(connector); -- cgit v1.1 From 99bb6c930479fedee4e55a662fa715702f6110b7 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 19 Oct 2012 07:38:36 -0400 Subject: Move PluginManager Move PluginManager out to OpenSimFramework for general use --- OpenSim/Server/Base/ServerUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Base/ServerUtils.cs') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 8ecf3d3..31b0446 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -111,17 +111,18 @@ namespace OpenSim.Server.Base case ExtensionChange.Add: if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) { - m_log.InfoFormat("[SERVER]: Adding {0}", a.Name); + m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name); connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); } else { - m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); + m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name); connector.PluginPath = a.AddinFile; } LoadPlugin(connector); break; case ExtensionChange.Remove: + m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); UnloadPlugin(connector); break; } -- cgit v1.1