diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | 103 |
1 files changed, 102 insertions, 1 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 9f7abd0..6331519 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | |||
@@ -149,21 +149,68 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
149 | 149 | ||
150 | public void AddRegionToModules (Scene scene) | 150 | public void AddRegionToModules (Scene scene) |
151 | { | 151 | { |
152 | Dictionary<Type, ISharedRegionModule> deferredSharedModules = | ||
153 | new Dictionary<Type, ISharedRegionModule>(); | ||
154 | Dictionary<Type, INonSharedRegionModule> deferredNonSharedModules = | ||
155 | new Dictionary<Type, INonSharedRegionModule>(); | ||
156 | |||
157 | Type s = scene.GetType(); | ||
158 | MethodInfo mi = s.GetMethod("RequestModuleInterface"); | ||
159 | |||
160 | List<ISharedRegionModule> sharedlist = new List<ISharedRegionModule>(); | ||
152 | foreach (ISharedRegionModule module in m_sharedInstances) | 161 | foreach (ISharedRegionModule module in m_sharedInstances) |
153 | { | 162 | { |
163 | Type replaceableInterface = module.ReplacableInterface; | ||
164 | if (replaceableInterface != null) | ||
165 | { | ||
166 | MethodInfo mii = mi.MakeGenericMethod(replaceableInterface); | ||
167 | |||
168 | if (mii.Invoke(scene, new object[0]) != null) | ||
169 | { | ||
170 | m_log.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}", module.Name, replaceableInterface.ToString()); | ||
171 | continue; | ||
172 | } | ||
173 | |||
174 | deferredSharedModules[replaceableInterface] = module; | ||
175 | m_log.DebugFormat("[REGIONMODULE]: Deferred load of {0}", module.Name); | ||
176 | continue; | ||
177 | } | ||
178 | |||
154 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to shared module {1}", | 179 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to shared module {1}", |
155 | scene.RegionInfo.RegionName, module.Name); | 180 | scene.RegionInfo.RegionName, module.Name); |
181 | |||
156 | module.AddRegion(scene); | 182 | module.AddRegion(scene); |
157 | scene.AddRegionModule(module.Name, module); | 183 | scene.AddRegionModule(module.Name, module); |
184 | |||
185 | sharedlist.Add(module); | ||
158 | } | 186 | } |
159 | 187 | ||
160 | List<INonSharedRegionModule> list = new List<INonSharedRegionModule>(); | 188 | List<INonSharedRegionModule> list = new List<INonSharedRegionModule>(); |
161 | foreach (Type type in m_nonSharedModules) | 189 | foreach (Type type in m_nonSharedModules) |
162 | { | 190 | { |
163 | INonSharedRegionModule module = (INonSharedRegionModule)Activator.CreateInstance(type); | 191 | INonSharedRegionModule module = (INonSharedRegionModule)Activator.CreateInstance(type); |
192 | |||
193 | Type replaceableInterface = module.ReplacableInterface; | ||
194 | if (replaceableInterface != null) | ||
195 | { | ||
196 | MethodInfo mii = mi.MakeGenericMethod(replaceableInterface); | ||
197 | |||
198 | if (mii.Invoke(scene, new object[0]) != null) | ||
199 | { | ||
200 | m_log.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}", module.Name, replaceableInterface.ToString()); | ||
201 | continue; | ||
202 | } | ||
203 | |||
204 | deferredNonSharedModules[replaceableInterface] = module; | ||
205 | m_log.DebugFormat("[REGIONMODULE]: Deferred load of {0}", module.Name); | ||
206 | continue; | ||
207 | } | ||
208 | |||
164 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to non-shared module {1}", | 209 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to non-shared module {1}", |
165 | scene.RegionInfo.RegionName, module.Name); | 210 | scene.RegionInfo.RegionName, module.Name); |
211 | |||
166 | module.Initialise(m_openSim.ConfigSource.Source); | 212 | module.Initialise(m_openSim.ConfigSource.Source); |
213 | |||
167 | list.Add(module); | 214 | list.Add(module); |
168 | } | 215 | } |
169 | 216 | ||
@@ -173,6 +220,60 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
173 | scene.AddRegionModule(module.Name, module); | 220 | scene.AddRegionModule(module.Name, module); |
174 | } | 221 | } |
175 | 222 | ||
223 | // Now all modules without a replaceable base interface are loaded | ||
224 | // Replaceable modules have either been skipped, or omitted. | ||
225 | // Now scan the deferred modules here | ||
226 | |||
227 | foreach (ISharedRegionModule module in deferredSharedModules.Values) | ||
228 | { | ||
229 | Type replaceableInterface = module.ReplacableInterface; | ||
230 | MethodInfo mii = mi.MakeGenericMethod(replaceableInterface); | ||
231 | |||
232 | if (mii.Invoke(scene, new object[0]) != null) | ||
233 | { | ||
234 | m_log.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}", module.Name, replaceableInterface.ToString()); | ||
235 | continue; | ||
236 | } | ||
237 | |||
238 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to shared module {1} (deferred)", | ||
239 | scene.RegionInfo.RegionName, module.Name); | ||
240 | |||
241 | module.AddRegion(scene); | ||
242 | scene.AddRegionModule(module.Name, module); | ||
243 | |||
244 | sharedlist.Add(module); | ||
245 | } | ||
246 | |||
247 | List<INonSharedRegionModule> deferredlist = new List<INonSharedRegionModule>(); | ||
248 | foreach (INonSharedRegionModule module in deferredNonSharedModules.Values) | ||
249 | { | ||
250 | Type replaceableInterface = module.ReplacableInterface; | ||
251 | if (replaceableInterface != null) | ||
252 | { | ||
253 | MethodInfo mii = mi.MakeGenericMethod(replaceableInterface); | ||
254 | |||
255 | if (mii.Invoke(scene, new object[0]) != null) | ||
256 | { | ||
257 | m_log.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}", module.Name, replaceableInterface.ToString()); | ||
258 | continue; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | m_log.DebugFormat("[REGIONMODULE]: Adding scene {0} to non-shared module {1} (deferred)", | ||
263 | scene.RegionInfo.RegionName, module.Name); | ||
264 | |||
265 | module.Initialise(m_openSim.ConfigSource.Source); | ||
266 | |||
267 | list.Add(module); | ||
268 | deferredlist.Add(module); | ||
269 | } | ||
270 | |||
271 | foreach (INonSharedRegionModule module in deferredlist) | ||
272 | { | ||
273 | module.AddRegion(scene); | ||
274 | scene.AddRegionModule(module.Name, module); | ||
275 | } | ||
276 | |||
176 | // This is needed for all module types. Modules will register | 277 | // This is needed for all module types. Modules will register |
177 | // Interfaces with scene in AddScene, and will also need a means | 278 | // Interfaces with scene in AddScene, and will also need a means |
178 | // to access interfaces registered by other modules. Without | 279 | // to access interfaces registered by other modules. Without |
@@ -183,7 +284,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
183 | // and unneccessary caching logic repeated in all modules. | 284 | // and unneccessary caching logic repeated in all modules. |
184 | // The extra function stub is just that much cleaner | 285 | // The extra function stub is just that much cleaner |
185 | // | 286 | // |
186 | foreach (ISharedRegionModule module in m_sharedInstances) | 287 | foreach (ISharedRegionModule module in sharedlist) |
187 | { | 288 | { |
188 | module.RegionLoaded(scene); | 289 | module.RegionLoaded(scene); |
189 | } | 290 | } |