aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs95
1 files changed, 73 insertions, 22 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
index 633d005..8f38a29 100644
--- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
@@ -32,11 +32,13 @@ using log4net;
32using Mono.Addins; 32using Mono.Addins;
33using Nini.Config; 33using Nini.Config;
34using OpenSim; 34using OpenSim;
35using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37 38
38namespace OpenSim.ApplicationPlugins.RegionModulesController 39namespace OpenSim.ApplicationPlugins.RegionModulesController
39{ 40{
41 [Extension(Path = "/OpenSim/Startup", Id = "LoadRegions", NodeName = "Plugin")]
40 public class RegionModulesControllerPlugin : IRegionModulesController, 42 public class RegionModulesControllerPlugin : IRegionModulesController,
41 IApplicationPlugin 43 IApplicationPlugin
42 { 44 {
@@ -45,6 +47,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
45 LogManager.GetLogger( 47 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType); 48 MethodBase.GetCurrentMethod().DeclaringType);
47 49
50 /// <summary>
51 /// Controls whether we load modules from Mono.Addins.
52 /// </summary>
53 /// <remarks>For debug purposes. Defaults to true.</remarks>
54 public bool LoadModulesFromAddins { get; set; }
55
48 // Config access 56 // Config access
49 private OpenSimBase m_openSim; 57 private OpenSimBase m_openSim;
50 58
@@ -61,6 +69,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
61 private List<ISharedRegionModule> m_sharedInstances = 69 private List<ISharedRegionModule> m_sharedInstances =
62 new List<ISharedRegionModule>(); 70 new List<ISharedRegionModule>();
63 71
72 public RegionModulesControllerPlugin()
73 {
74 LoadModulesFromAddins = true;
75 }
76
64#region IApplicationPlugin implementation 77#region IApplicationPlugin implementation
65 78
66 public void Initialise (OpenSimBase openSim) 79 public void Initialise (OpenSimBase openSim)
@@ -69,6 +82,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
69 m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); 82 m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
70 m_log.DebugFormat("[REGIONMODULES]: Initializing..."); 83 m_log.DebugFormat("[REGIONMODULES]: Initializing...");
71 84
85 if (!LoadModulesFromAddins)
86 return;
87
72 // Who we are 88 // Who we are
73 string id = AddinManager.CurrentAddin.Id; 89 string id = AddinManager.CurrentAddin.Id;
74 90
@@ -85,30 +101,20 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
85 if (modulesConfig == null) 101 if (modulesConfig == null)
86 modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); 102 modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules");
87 103
104 Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();
105
88 // Scan modules and load all that aren't disabled 106 // Scan modules and load all that aren't disabled
89 foreach (TypeExtensionNode node in 107 foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
90 AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) 108 AddNode(node, modulesConfig, loadedModules);
109
110 foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
91 { 111 {
92 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) 112 m_log.InfoFormat(
93 { 113 "[REGIONMODULES]: From plugin {0}, (version {1}), loaded {2} modules, {3} shared, {4} non-shared {5} unknown",
94 if (CheckModuleEnabled(node, modulesConfig)) 114 loadedModuleData.Key.Id,
95 { 115 loadedModuleData.Key.Version,
96 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); 116 loadedModuleData.Value[0] + loadedModuleData.Value[1] + loadedModuleData.Value[2],
97 m_sharedModules.Add(node); 117 loadedModuleData.Value[0], loadedModuleData.Value[1], loadedModuleData.Value[2]);
98 }
99 }
100 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
101 {
102 if (CheckModuleEnabled(node, modulesConfig))
103 {
104 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
105 m_nonSharedModules.Add(node);
106 }
107 }
108 else
109 {
110 m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
111 }
112 } 118 }
113 119
114 // Load and init the module. We try a constructor with a port 120 // Load and init the module. We try a constructor with a port
@@ -125,6 +131,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
125 // Read the config again 131 // Read the config again
126 string moduleString = 132 string moduleString =
127 modulesConfig.GetString("Setup_" + node.Id, String.Empty); 133 modulesConfig.GetString("Setup_" + node.Id, String.Empty);
134 // Test to see if we want this module
135 if (moduleString == "disabled")
136 continue;
128 137
129 // Get the port number, if there is one 138 // Get the port number, if there is one
130 if (moduleString != String.Empty) 139 if (moduleString != String.Empty)
@@ -172,6 +181,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
172 181
173#region IPlugin implementation 182#region IPlugin implementation
174 183
184 private void AddNode(
185 TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules)
186 {
187 IList<int> loadedModuleData;
188
189 if (!loadedModules.ContainsKey(node.Addin))
190 loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
191
192 loadedModuleData = loadedModules[node.Addin];
193
194 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
195 {
196 if (CheckModuleEnabled(node, modulesConfig))
197 {
198 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
199 m_sharedModules.Add(node);
200 loadedModuleData[0]++;
201 }
202 }
203 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
204 {
205 if (CheckModuleEnabled(node, modulesConfig))
206 {
207 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
208 m_nonSharedModules.Add(node);
209 loadedModuleData[1]++;
210 }
211 }
212 else
213 {
214 m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
215 loadedModuleData[2]++;
216 }
217 }
218
175 // We don't do that here 219 // We don't do that here
176 // 220 //
177 public void Initialise () 221 public void Initialise ()
@@ -193,6 +237,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
193 m_sharedInstances[0].Close(); 237 m_sharedInstances[0].Close();
194 m_sharedInstances.RemoveAt(0); 238 m_sharedInstances.RemoveAt(0);
195 } 239 }
240
196 m_sharedModules.Clear(); 241 m_sharedModules.Clear();
197 m_nonSharedModules.Clear(); 242 m_nonSharedModules.Clear();
198 } 243 }
@@ -323,6 +368,10 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
323 string moduleString = 368 string moduleString =
324 modulesConfig.GetString("Setup_" + node.Id, String.Empty); 369 modulesConfig.GetString("Setup_" + node.Id, String.Empty);
325 370
371 // We may not want to load this at all
372 if (moduleString == "disabled")
373 continue;
374
326 // Get the port number, if there is one 375 // Get the port number, if there is one
327 if (moduleString != String.Empty) 376 if (moduleString != String.Empty)
328 { 377 {
@@ -460,6 +509,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
460 { 509 {
461 module.RegionLoaded(scene); 510 module.RegionLoaded(scene);
462 } 511 }
512
513 scene.AllModulesLoaded();
463 } 514 }
464 515
465 public void RemoveRegionFromModules (Scene scene) 516 public void RemoveRegionFromModules (Scene scene)