aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2009-02-26 20:01:20 +0000
committerMW2009-02-26 20:01:20 +0000
commit33e7c09b7b894551b35fb8ab29133c96a5d7b037 (patch)
treea21839dc38477c2679b9c94fcebc96cca8bcc26d /OpenSim
parentAttempt to fix the "region starts but doesn't load anything" issue (diff)
downloadopensim-SC_OLD-33e7c09b7b894551b35fb8ab29133c96a5d7b037.zip
opensim-SC_OLD-33e7c09b7b894551b35fb8ab29133c96a5d7b037.tar.gz
opensim-SC_OLD-33e7c09b7b894551b35fb8ab29133c96a5d7b037.tar.bz2
opensim-SC_OLD-33e7c09b7b894551b35fb8ab29133c96a5d7b037.tar.xz
Added IRegistryCore and RegistryCore to OpenSim.Framework.
Added a ApplicationRegistry to OpenSimBase. Changed LoadRegionsPlugin so it registers itself to that application registry. Added a event to LoadRegionsPlugin, that is triggered when it creates a new scene ,although maybe this event should actually be in opensimBase incase other plugins are creating regions (like the RemoteAdminPlugin).
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs22
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs4
-rw-r--r--OpenSim/Framework/IRegistryCore.cs13
-rw-r--r--OpenSim/Framework/RegistryCore.cs44
-rw-r--r--OpenSim/Region/Application/HGOpenSimNode.cs2
-rw-r--r--OpenSim/Region/Application/OpenSim.cs67
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs34
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs15
8 files changed, 153 insertions, 48 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index 24372fe..962f7b3 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -38,13 +38,19 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
38using OpenSim.Region.CoreModules.Scripting.DynamicTexture; 38using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
39using OpenSim.Region.CoreModules.Scripting.LoadImageURL; 39using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
40using OpenSim.Region.CoreModules.Scripting.XMLRPC; 40using OpenSim.Region.CoreModules.Scripting.XMLRPC;
41using OpenSim.Framework.Servers;
41 42
42namespace OpenSim.ApplicationPlugins.LoadRegions 43namespace OpenSim.ApplicationPlugins.LoadRegions
43{ 44{
45 public delegate void NewRegionCreated(IScene scene);
46
44 public class LoadRegionsPlugin : IApplicationPlugin 47 public class LoadRegionsPlugin : IApplicationPlugin
45 { 48 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 50
51 public event NewRegionCreated OnNewRegionCreated;
52 private NewRegionCreated m_newRegionCreatedHandler;
53
48 #region IApplicationPlugin Members 54 #region IApplicationPlugin Members
49 55
50 // TODO: required by IPlugin, but likely not at all right 56 // TODO: required by IPlugin, but likely not at all right
@@ -56,6 +62,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
56 62
57 protected OpenSimBase m_openSim; 63 protected OpenSimBase m_openSim;
58 64
65
59 public void Initialise() 66 public void Initialise()
60 { 67 {
61 m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); 68 m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
@@ -65,6 +72,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
65 public void Initialise(OpenSimBase openSim) 72 public void Initialise(OpenSimBase openSim)
66 { 73 {
67 m_openSim = openSim; 74 m_openSim = openSim;
75 m_openSim.ApplicationRegistry.RegisterInterface<LoadRegionsPlugin>(this);
68 } 76 }
69 77
70 public void PostInitialise() 78 public void PostInitialise()
@@ -99,9 +107,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
99 107
100 for (int i = 0; i < regionsToLoad.Length; i++) 108 for (int i = 0; i < regionsToLoad.Length; i++)
101 { 109 {
110 IScene scene;
102 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + 111 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() +
103 ")"); 112 ")");
104 m_openSim.CreateRegion(regionsToLoad[i], true); 113 m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
114 if (scene != null)
115 {
116 m_newRegionCreatedHandler = OnNewRegionCreated;
117 if (m_newRegionCreatedHandler != null)
118 {
119 m_newRegionCreatedHandler(scene);
120 }
121 }
105 } 122 }
106 123
107 m_openSim.ModuleLoader.PostInitialise(); 124 m_openSim.ModuleLoader.PostInitialise();
@@ -182,9 +199,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
182 { 199 {
183 if (regionhandle == regionsToLoad[i].RegionHandle) 200 if (regionhandle == regionsToLoad[i].RegionHandle)
184 { 201 {
202 IScene scene;
185 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + 203 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
186 Thread.CurrentThread.ManagedThreadId.ToString() + ")"); 204 Thread.CurrentThread.ManagedThreadId.ToString() + ")");
187 openSim.CreateRegion(regionsToLoad[i], true); 205 openSim.CreateRegion(regionsToLoad[i], true, out scene);
188 } 206 }
189 } 207 }
190 } 208 }
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 7f6ca9a..fcc02d8 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -563,8 +563,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
563 region.RegionID, regionXmlPath); 563 region.RegionID, regionXmlPath);
564 region.SaveRegionToFile("dynamic region", regionXmlPath); 564 region.SaveRegionToFile("dynamic region", regionXmlPath);
565 } 565 }
566 566 IScene newscene;
567 m_app.CreateRegion(region); 567 m_app.CreateRegion(region, out newscene);
568 568
569 responseData["success"] = "true"; 569 responseData["success"] = "true";
570 responseData["region_name"] = region.RegionName; 570 responseData["region_name"] = region.RegionName;
diff --git a/OpenSim/Framework/IRegistryCore.cs b/OpenSim/Framework/IRegistryCore.cs
new file mode 100644
index 0000000..486dee6
--- /dev/null
+++ b/OpenSim/Framework/IRegistryCore.cs
@@ -0,0 +1,13 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework
6{
7 public interface IRegistryCore
8 {
9 T Get<T>();
10 void RegisterInterface<T>(T iface);
11 bool TryGet<T>(out T iface);
12 }
13}
diff --git a/OpenSim/Framework/RegistryCore.cs b/OpenSim/Framework/RegistryCore.cs
new file mode 100644
index 0000000..06732f5
--- /dev/null
+++ b/OpenSim/Framework/RegistryCore.cs
@@ -0,0 +1,44 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework
6{
7 public class RegistryCore
8 {
9 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
10
11 /// <summary>
12 /// Register an Module interface.
13 /// </summary>
14 /// <typeparam name="T"></typeparam>
15 /// <param name="iface"></param>
16 public void RegisterInterface<T>(T iface)
17 {
18 lock (m_moduleInterfaces)
19 {
20 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
21 {
22 m_moduleInterfaces.Add(typeof(T), iface);
23 }
24 }
25 }
26
27 public bool TryGet<T>(out T iface)
28 {
29 if (m_moduleInterfaces.ContainsKey(typeof(T)))
30 {
31 iface = (T)m_moduleInterfaces[typeof(T)];
32 return true;
33 }
34 iface = default(T);
35 return false;
36 }
37
38 public T Get<T>()
39 {
40 return (T)m_moduleInterfaces[typeof(T)];
41 }
42
43 }
44}
diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs
index ded6443..1130c70 100644
--- a/OpenSim/Region/Application/HGOpenSimNode.cs
+++ b/OpenSim/Region/Application/HGOpenSimNode.cs
@@ -47,7 +47,7 @@ namespace OpenSim
47 public class HGOpenSimNode : OpenSim 47 public class HGOpenSimNode : OpenSim
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private IHyperlink HGServices = null; 50 public IHyperlink HGServices = null;
51 51
52 private uint m_autoMappingX = 0; 52 private uint m_autoMappingX = 0;
53 private uint m_autoMappingY = 0; 53 private uint m_autoMappingY = 0;
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index a17d92f..a8adf58 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -95,6 +95,40 @@ namespace OpenSim
95 m_console.SetGuiMode(m_gui); 95 m_console.SetGuiMode(m_gui);
96 MainConsole.Instance = m_console; 96 MainConsole.Instance = m_console;
97 97
98 RegisterConsoleCommands();
99
100 base.StartupSpecific();
101
102 //Run Startup Commands
103 if (String.IsNullOrEmpty( m_startupCommandsFile ))
104 {
105 m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
106 }
107 else
108 {
109 RunCommandScript(m_startupCommandsFile);
110 }
111
112 // Start timer script (run a script every xx seconds)
113 if (m_timedScript != "disabled")
114 {
115 m_scriptTimer = new Timer();
116 m_scriptTimer.Enabled = true;
117 m_scriptTimer.Interval = 1200 * 1000;
118 m_scriptTimer.Elapsed += RunAutoTimerScript;
119 }
120
121 PrintFileToConsole("startuplogo.txt");
122
123 // For now, start at the 'root' level by default
124 if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
125 ChangeSelectedRegion("region", new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
126 else
127 ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
128 }
129
130 private void RegisterConsoleCommands()
131 {
98 m_console.Commands.AddCommand("region", false, "clear assets", 132 m_console.Commands.AddCommand("region", false, "clear assets",
99 "clear assets", 133 "clear assets",
100 "Clear the asset cache", HandleClearAssets); 134 "Clear the asset cache", HandleClearAssets);
@@ -255,35 +289,6 @@ namespace OpenSim
255 "reset user password [<first> [<last> [<password>]]]", 289 "reset user password [<first> [<last> [<password>]]]",
256 "Reset a user password", HandleResetUserPassword); 290 "Reset a user password", HandleResetUserPassword);
257 } 291 }
258
259 base.StartupSpecific();
260
261 //Run Startup Commands
262 if (String.IsNullOrEmpty( m_startupCommandsFile ))
263 {
264 m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
265 }
266 else
267 {
268 RunCommandScript(m_startupCommandsFile);
269 }
270
271 // Start timer script (run a script every xx seconds)
272 if (m_timedScript != "disabled")
273 {
274 m_scriptTimer = new Timer();
275 m_scriptTimer.Enabled = true;
276 m_scriptTimer.Interval = 1200 * 1000;
277 m_scriptTimer.Elapsed += RunAutoTimerScript;
278 }
279
280 PrintFileToConsole("startuplogo.txt");
281
282 // For now, start at the 'root' level by default
283 if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
284 ChangeSelectedRegion("region", new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
285 else
286 ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
287 } 292 }
288 293
289 public override void ShutdownSpecific() 294 public override void ShutdownSpecific()
@@ -410,9 +415,9 @@ namespace OpenSim
410 { 415 {
411 m_console.Error("Usage: create region <region name> <region_file.xml>"); 416 m_console.Error("Usage: create region <region name> <region_file.xml>");
412 } 417 }
413
414 418
415 CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true); 419 IScene scene;
420 CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
416 } 421 }
417 422
418 private void HandleLoginEnable(string module, string[] cmd) 423 private void HandleLoginEnable(string module, string[] cmd)
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4d809b0..2b74aa3 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -120,7 +120,14 @@ namespace OpenSim
120 get { return m_moduleLoader; } 120 get { return m_moduleLoader; }
121 set { m_moduleLoader = value; } 121 set { m_moduleLoader = value; }
122 } 122 }
123 protected ModuleLoader m_moduleLoader; 123 protected ModuleLoader m_moduleLoader;
124
125 protected RegistryCore m_applicationRegistry = new RegistryCore();
126
127 public RegistryCore ApplicationRegistry
128 {
129 get { return m_applicationRegistry; }
130 }
124 131
125 /// <summary> 132 /// <summary>
126 /// Constructor. 133 /// Constructor.
@@ -176,7 +183,7 @@ namespace OpenSim
176 base.StartupSpecific(); 183 base.StartupSpecific();
177 184
178 m_stats = StatsManager.StartCollectingSimExtraStats(); 185 m_stats = StatsManager.StartCollectingSimExtraStats();
179 186
180 LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_configSettings.LibrariesXMLFile); 187 LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_configSettings.LibrariesXMLFile);
181 188
182 // Standalone mode is determined by !startupConfig.GetBoolean("gridmode", false) 189 // Standalone mode is determined by !startupConfig.GetBoolean("gridmode", false)
@@ -194,6 +201,7 @@ namespace OpenSim
194 m_moduleLoader = new ModuleLoader(m_config.Source); 201 m_moduleLoader = new ModuleLoader(m_config.Source);
195 202
196 LoadPlugins(); 203 LoadPlugins();
204
197 205
198 foreach (IApplicationPlugin plugin in m_plugins) 206 foreach (IApplicationPlugin plugin in m_plugins)
199 { 207 {
@@ -202,7 +210,10 @@ namespace OpenSim
202 210
203 211
204 // Only enable logins to the regions once we have completely finished starting up (apart from scripts) 212 // Only enable logins to the regions once we have completely finished starting up (apart from scripts)
205 m_commsManager.GridService.RegionLoginsEnabled = true; 213 if ((m_commsManager != null) && (m_commsManager.GridService != null))
214 {
215 m_commsManager.GridService.RegionLoginsEnabled = true;
216 }
206 217
207 // If console exists add plugin commands. 218 // If console exists add plugin commands.
208 if (m_console != null) 219 if (m_console != null)
@@ -541,9 +552,9 @@ namespace OpenSim
541 /// <param name="regionInfo"></param> 552 /// <param name="regionInfo"></param>
542 /// <param name="portadd_flag"></param> 553 /// <param name="portadd_flag"></param>
543 /// <returns></returns> 554 /// <returns></returns>
544 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag) 555 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
545 { 556 {
546 return CreateRegion(regionInfo, portadd_flag, false); 557 return CreateRegion(regionInfo, portadd_flag, false, out scene);
547 } 558 }
548 559
549 /// <summary> 560 /// <summary>
@@ -551,9 +562,9 @@ namespace OpenSim
551 /// </summary> 562 /// </summary>
552 /// <param name="regionInfo"></param> 563 /// <param name="regionInfo"></param>
553 /// <returns></returns> 564 /// <returns></returns>
554 public IClientNetworkServer CreateRegion(RegionInfo regionInfo) 565 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene)
555 { 566 {
556 return CreateRegion(regionInfo, false, true); 567 return CreateRegion(regionInfo, false, true, out scene);
557 } 568 }
558 569
559 /// <summary> 570 /// <summary>
@@ -563,7 +574,7 @@ namespace OpenSim
563 /// <param name="portadd_flag"></param> 574 /// <param name="portadd_flag"></param>
564 /// <param name="do_post_init"></param> 575 /// <param name="do_post_init"></param>
565 /// <returns></returns> 576 /// <returns></returns>
566 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init) 577 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
567 { 578 {
568 int port = regionInfo.InternalEndPoint.Port; 579 int port = regionInfo.InternalEndPoint.Port;
569 580
@@ -640,6 +651,7 @@ namespace OpenSim
640 } 651 }
641 } 652 }
642 653
654 mscene = scene;
643 return clientServer; 655 return clientServer;
644 } 656 }
645 657
@@ -722,8 +734,8 @@ namespace OpenSim
722 m_clientServers[clientServerElement].Server.Close(); 734 m_clientServers[clientServerElement].Server.Close();
723 m_clientServers.RemoveAt(clientServerElement); 735 m_clientServers.RemoveAt(clientServerElement);
724 } 736 }
725 737 IScene scene;
726 CreateRegion(whichRegion, true); 738 CreateRegion(whichRegion, true, out scene);
727 } 739 }
728 740
729 # region Setup methods 741 # region Setup methods
@@ -738,7 +750,7 @@ namespace OpenSim
738 /// Handler to supply the current status of this sim 750 /// Handler to supply the current status of this sim
739 /// </summary> 751 /// </summary>
740 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service 752 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service
741 protected class SimStatusHandler : IStreamedRequestHandler 753 public class SimStatusHandler : IStreamedRequestHandler
742 { 754 {
743 public byte[] Handle(string path, Stream request, 755 public byte[] Handle(string path, Stream request,
744 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 756 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 55cf1ae..731e0e5 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -45,16 +45,21 @@ namespace OpenSim.Region.ClientStack
45 private static readonly ILog m_log 45 private static readonly ILog m_log
46 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 protected IAssetCache m_assetCache;
49 protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>(); 48 protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
50 protected NetworkServersInfo m_networkServersInfo; 49 protected NetworkServersInfo m_networkServersInfo;
51 50
51 public NetworkServersInfo NetServersInfo
52 {
53 get { return m_networkServersInfo; }
54 }
55
52 protected BaseHttpServer m_httpServer; 56 protected BaseHttpServer m_httpServer;
53 protected uint m_httpServerPort; 57 protected uint m_httpServerPort;
54 58
55 public CommunicationsManager CommunicationsManager 59 public CommunicationsManager CommunicationsManager
56 { 60 {
57 get { return m_commsManager; } 61 get { return m_commsManager; }
62 set { m_commsManager = value; }
58 } 63 }
59 protected CommunicationsManager m_commsManager; 64 protected CommunicationsManager m_commsManager;
60 65
@@ -67,6 +72,14 @@ namespace OpenSim.Region.ClientStack
67 get { return m_sceneManager; } 72 get { return m_sceneManager; }
68 } 73 }
69 protected SceneManager m_sceneManager = new SceneManager(); 74 protected SceneManager m_sceneManager = new SceneManager();
75
76 protected IAssetCache m_assetCache;
77
78 public IAssetCache AssetCache
79 {
80 get { return m_assetCache; }
81 set { m_assetCache = value; }
82 }
70 83
71 protected abstract void Initialize(); 84 protected abstract void Initialize();
72 85