From 2486d96d062067f77151d516abe99f87b378ddad Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 00:56:53 +0000 Subject: [PATCH 1/8] minor: correction to logging category --- OpenSim/Region/Application/OpenSimBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 36d5e51058..eee2300774 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -352,13 +352,13 @@ namespace OpenSim m_moduleLoader.InitialiseSharedModules(scene); // Use this in the future, the line above will be deprecated soon - m_log.Info("[REGIONMODULE]: Loading Region's modules (new style)"); + m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); IRegionModulesController controller; if (ApplicationRegistry.TryGet(out controller)) { controller.AddRegionToModules(scene); } - else m_log.Error("[REGIONMODULE]: The new RegionModulesController is missing..."); + else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing..."); scene.SetModuleInterfaces(); From 0ab774d484a58a73b2aa26b9f10d9df9aea1777a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 01:06:29 +0000 Subject: [PATCH 2/8] add warning decals and information to RegionModule.cs in probably non-functional OpenSim.Region.Examples.SimpleModule project --- OpenSim/Region/Examples/SimpleModule/RegionModule.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index 6da41db45a..9bcda74088 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -34,6 +34,15 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.Examples.SimpleModule { + /// + /// Example region module. + /// + /// + /// This is an old and unmaintained region module which uses the old style module interface. It is not loaded into + /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project. + /// Please see the README.txt in this project on the filesystem for some more information. + /// Nonetheless, it may contain some useful example code so has been left here for now. + /// public class RegionModule : IRegionModule { #region IRegionModule Members From a06032d96eec260f3cda48131e99c5dfb485aa28 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 01:36:35 +0000 Subject: [PATCH 3/8] Add the most bare bones non-shared region module example. Not active unless the correct line is uncommented. --- .../BareBonesNonSharedModule.cs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs new file mode 100644 index 0000000000..a2a6b50227 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -0,0 +1,83 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared +{ + /// + /// Simplest possible example of a non-shared region module. + /// + /// + /// This module is the simplest possible example of a non-shared region module (a module where each scene/region + /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then + /// please create a separate example. + /// + /// This module is not active by default. If you want to see it in action, + /// then just uncomment the line below starting with [Extension(Path... + /// + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] + public class BareBonesNonSharedModule : INonSharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "Bare Bones Non Shared Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { + m_log.DebugFormat("[BARE BONES]: INITIALIZED MODULE"); + } + + public void Close() + { + m_log.DebugFormat("[BARE BONES]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + } +} \ No newline at end of file From c010491d340ed66fd5b6044f708669e3aac609b4 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 01:38:32 +0000 Subject: [PATCH 4/8] correct the id of the example module --- .../Example/BareBonesNonShared/BareBonesNonSharedModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs index a2a6b50227..5ece77dd07 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared /// This module is not active by default. If you want to see it in action, /// then just uncomment the line below starting with [Extension(Path... /// - //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")] public class BareBonesNonSharedModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); From 510b55c7f08e01b1d7ff14cbfdea367b9744dc23 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 02:38:26 +0000 Subject: [PATCH 5/8] refactor some common code in RegionModulesControllerPlugin also some minor doc changes in BareBonesNonSharedModule --- .../RegionModulesControllerPlugin.cs | 100 ++++++++---------- .../BareBonesNonSharedModule.cs | 15 +-- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 9d79b3ade8..49bd911baf 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -62,7 +62,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController new List(); #region IApplicationPlugin implementation - + public void Initialise (OpenSimBase openSim) { m_openSim = openSim; @@ -91,66 +91,24 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) { - // Get the config string - string moduleString = - modulesConfig.GetString("Setup_" + node.Id, String.Empty); - - // We have a selector - if (moduleString != String.Empty) + if (CheckModuleEnabled(node, modulesConfig)) { - // Allow disabling modules even if they don't have - // support for it - if (moduleString == "disabled") - continue; - - // Split off port, if present - string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); - // Format is [port/][class] - string className = moduleParts[0]; - if (moduleParts.Length > 1) - className = moduleParts[1]; - - // Match the class name if given - if (className != String.Empty && - node.Type.ToString() != className) - continue; + m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); + m_sharedModules.Add(node); } - - m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); - m_sharedModules.Add(node); } else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) { - // Get the config string - string moduleString = - modulesConfig.GetString("Setup_" + node.Id, String.Empty); - - // We have a selector - if (moduleString != String.Empty) + if (CheckModuleEnabled(node, modulesConfig)) { - // Allow disabling modules even if they don't have - // support for it - if (moduleString == "disabled") - continue; - - // Split off port, if present - string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); - // Format is [port/][class] - string className = moduleParts[0]; - if (moduleParts.Length > 1) - className = moduleParts[1]; - - // Match the class name if given - if (className != String.Empty && - node.Type.ToString() != className) - continue; + m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); + m_nonSharedModules.Add(node); } - - m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); - m_nonSharedModules.Add(node); } else + { m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); + } } // Load and init the module. We try a constructor with a port @@ -197,8 +155,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController m_sharedInstances.Add(module); module.Initialise(m_openSim.ConfigSource.Source); } - - } public void PostInitialise () @@ -210,7 +166,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { module.PostInitialise(); } - } #endregion @@ -244,7 +199,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController #endregion - public string Version { get @@ -262,6 +216,42 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController } #region IRegionModulesController implementation + + /// + /// Check that the given module is no disabled in the [Modules] section of the config files. + /// + /// + /// The config section + /// true if the module is enabled, false if it is disabled + protected bool CheckModuleEnabled(TypeExtensionNode node, IConfig modulesConfig) + { + // Get the config string + string moduleString = + modulesConfig.GetString("Setup_" + node.Id, String.Empty); + + // We have a selector + if (moduleString != String.Empty) + { + // Allow disabling modules even if they don't have + // support for it + if (moduleString == "disabled") + return false; + + // Split off port, if present + string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); + // Format is [port/][class] + string className = moduleParts[0]; + if (moduleParts.Length > 1) + className = moduleParts[1]; + + // Match the class name if given + if (className != String.Empty && + node.Type.ToString() != className) + return false; + } + + return true; + } // The root of all evil. // This is where we handle adding the modules to scenes when they diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs index 5ece77dd07..7d37135fd6 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -41,10 +41,13 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared /// /// This module is the simplest possible example of a non-shared region module (a module where each scene/region /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then - /// please create a separate example. + /// please create a separate class. /// /// This module is not active by default. If you want to see it in action, /// then just uncomment the line below starting with [Extension(Path... + /// + /// When the module is enabled it will print messages when it receives certain events to the screen and the log + /// file. /// //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")] public class BareBonesNonSharedModule : INonSharedRegionModule @@ -57,27 +60,27 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared public void Initialise(IConfigSource source) { - m_log.DebugFormat("[BARE BONES]: INITIALIZED MODULE"); + m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE"); } public void Close() { - m_log.DebugFormat("[BARE BONES]: CLOSED MODULE"); + m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE"); } public void AddRegion(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} ADDED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} LOADED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); } } } \ No newline at end of file From 57b5263ecf9b78534d71e147a7dc152d19cbc4a4 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 02:46:59 +0000 Subject: [PATCH 6/8] add bare bones shared example module --- .../BareBonesShared/BareBonesSharedModule.cs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs new file mode 100644 index 0000000000..aa40c25a07 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs @@ -0,0 +1,91 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Example.BareBonesShared +{ + /// + /// Simplest possible example of a shared region module. + /// + /// + /// This module is the simplest possible example of a shared region module (a module which is shared by every + /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then + /// please create a separate class. + /// + /// This module is not active by default. If you want to see it in action, + /// then just uncomment the line below starting with [Extension(Path... + /// + /// When the module is enabled it will print messages when it receives certain events to the screen and the log + /// file. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] + public class BareBonesSharedModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "Bare Bones Shared Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { + m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { + m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE"); + } + + public void Close() + { + m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + } +} \ No newline at end of file From f268cd7c53591a320c7b02d56af1566e7571c2aa Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 02:47:29 +0000 Subject: [PATCH 7/8] comment out the extension attribute --- .../Example/BareBonesShared/BareBonesSharedModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs index aa40c25a07..781fe952d2 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesShared /// When the module is enabled it will print messages when it receives certain events to the screen and the log /// file. /// - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] public class BareBonesSharedModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); From 7b6b4501b7177d43e1ec11b29ba9ba6c55af9c64 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 4 Dec 2010 02:49:41 +0000 Subject: [PATCH 8/8] minor: add class doc line to older region module example code pointing towards newer --- OpenSim/Region/Examples/SimpleModule/RegionModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index 9bcda74088..088b81876a 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -42,6 +42,8 @@ namespace OpenSim.Region.Examples.SimpleModule /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project. /// Please see the README.txt in this project on the filesystem for some more information. /// Nonetheless, it may contain some useful example code so has been left here for now. + /// + /// You can see bare bones examples of the more modern region module system in OpenSim/Region/OptionalModules/Example /// public class RegionModule : IRegionModule {