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).GenericGridServerConcept
parent
c0c1a31f61
commit
33e7c09b7b
OpenSim
ApplicationPlugins
LoadRegions
RemoteController
Framework
Region
Application
ClientStack
|
@ -38,13 +38,19 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
|
|||
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
|
||||
using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
|
||||
using OpenSim.Region.CoreModules.Scripting.XMLRPC;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
{
|
||||
public delegate void NewRegionCreated(IScene scene);
|
||||
|
||||
public class LoadRegionsPlugin : IApplicationPlugin
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public event NewRegionCreated OnNewRegionCreated;
|
||||
private NewRegionCreated m_newRegionCreatedHandler;
|
||||
|
||||
#region IApplicationPlugin Members
|
||||
|
||||
// TODO: required by IPlugin, but likely not at all right
|
||||
|
@ -56,6 +62,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
|
||||
protected OpenSimBase m_openSim;
|
||||
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
|
||||
|
@ -65,6 +72,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
public void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
m_openSim = openSim;
|
||||
m_openSim.ApplicationRegistry.RegisterInterface<LoadRegionsPlugin>(this);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
@ -99,9 +107,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
|
||||
for (int i = 0; i < regionsToLoad.Length; i++)
|
||||
{
|
||||
IScene scene;
|
||||
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() +
|
||||
")");
|
||||
m_openSim.CreateRegion(regionsToLoad[i], true);
|
||||
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||
if (scene != null)
|
||||
{
|
||||
m_newRegionCreatedHandler = OnNewRegionCreated;
|
||||
if (m_newRegionCreatedHandler != null)
|
||||
{
|
||||
m_newRegionCreatedHandler(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_openSim.ModuleLoader.PostInitialise();
|
||||
|
@ -182,9 +199,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
{
|
||||
if (regionhandle == regionsToLoad[i].RegionHandle)
|
||||
{
|
||||
IScene scene;
|
||||
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
|
||||
Thread.CurrentThread.ManagedThreadId.ToString() + ")");
|
||||
openSim.CreateRegion(regionsToLoad[i], true);
|
||||
openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,8 +563,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
region.RegionID, regionXmlPath);
|
||||
region.SaveRegionToFile("dynamic region", regionXmlPath);
|
||||
}
|
||||
|
||||
m_app.CreateRegion(region);
|
||||
IScene newscene;
|
||||
m_app.CreateRegion(region, out newscene);
|
||||
|
||||
responseData["success"] = "true";
|
||||
responseData["region_name"] = region.RegionName;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public interface IRegistryCore
|
||||
{
|
||||
T Get<T>();
|
||||
void RegisterInterface<T>(T iface);
|
||||
bool TryGet<T>(out T iface);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class RegistryCore
|
||||
{
|
||||
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Register an Module interface.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="iface"></param>
|
||||
public void RegisterInterface<T>(T iface)
|
||||
{
|
||||
lock (m_moduleInterfaces)
|
||||
{
|
||||
if (!m_moduleInterfaces.ContainsKey(typeof(T)))
|
||||
{
|
||||
m_moduleInterfaces.Add(typeof(T), iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGet<T>(out T iface)
|
||||
{
|
||||
if (m_moduleInterfaces.ContainsKey(typeof(T)))
|
||||
{
|
||||
iface = (T)m_moduleInterfaces[typeof(T)];
|
||||
return true;
|
||||
}
|
||||
iface = default(T);
|
||||
return false;
|
||||
}
|
||||
|
||||
public T Get<T>()
|
||||
{
|
||||
return (T)m_moduleInterfaces[typeof(T)];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ namespace OpenSim
|
|||
public class HGOpenSimNode : OpenSim
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private IHyperlink HGServices = null;
|
||||
public IHyperlink HGServices = null;
|
||||
|
||||
private uint m_autoMappingX = 0;
|
||||
private uint m_autoMappingY = 0;
|
||||
|
|
|
@ -95,6 +95,40 @@ namespace OpenSim
|
|||
m_console.SetGuiMode(m_gui);
|
||||
MainConsole.Instance = m_console;
|
||||
|
||||
RegisterConsoleCommands();
|
||||
|
||||
base.StartupSpecific();
|
||||
|
||||
//Run Startup Commands
|
||||
if (String.IsNullOrEmpty( m_startupCommandsFile ))
|
||||
{
|
||||
m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
|
||||
}
|
||||
else
|
||||
{
|
||||
RunCommandScript(m_startupCommandsFile);
|
||||
}
|
||||
|
||||
// Start timer script (run a script every xx seconds)
|
||||
if (m_timedScript != "disabled")
|
||||
{
|
||||
m_scriptTimer = new Timer();
|
||||
m_scriptTimer.Enabled = true;
|
||||
m_scriptTimer.Interval = 1200 * 1000;
|
||||
m_scriptTimer.Elapsed += RunAutoTimerScript;
|
||||
}
|
||||
|
||||
PrintFileToConsole("startuplogo.txt");
|
||||
|
||||
// For now, start at the 'root' level by default
|
||||
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
|
||||
ChangeSelectedRegion("region", new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
|
||||
else
|
||||
ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
|
||||
}
|
||||
|
||||
private void RegisterConsoleCommands()
|
||||
{
|
||||
m_console.Commands.AddCommand("region", false, "clear assets",
|
||||
"clear assets",
|
||||
"Clear the asset cache", HandleClearAssets);
|
||||
|
@ -255,35 +289,6 @@ namespace OpenSim
|
|||
"reset user password [<first> [<last> [<password>]]]",
|
||||
"Reset a user password", HandleResetUserPassword);
|
||||
}
|
||||
|
||||
base.StartupSpecific();
|
||||
|
||||
//Run Startup Commands
|
||||
if (String.IsNullOrEmpty( m_startupCommandsFile ))
|
||||
{
|
||||
m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
|
||||
}
|
||||
else
|
||||
{
|
||||
RunCommandScript(m_startupCommandsFile);
|
||||
}
|
||||
|
||||
// Start timer script (run a script every xx seconds)
|
||||
if (m_timedScript != "disabled")
|
||||
{
|
||||
m_scriptTimer = new Timer();
|
||||
m_scriptTimer.Enabled = true;
|
||||
m_scriptTimer.Interval = 1200 * 1000;
|
||||
m_scriptTimer.Elapsed += RunAutoTimerScript;
|
||||
}
|
||||
|
||||
PrintFileToConsole("startuplogo.txt");
|
||||
|
||||
// For now, start at the 'root' level by default
|
||||
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
|
||||
ChangeSelectedRegion("region", new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
|
||||
else
|
||||
ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
|
||||
}
|
||||
|
||||
public override void ShutdownSpecific()
|
||||
|
@ -410,9 +415,9 @@ namespace OpenSim
|
|||
{
|
||||
m_console.Error("Usage: create region <region name> <region_file.xml>");
|
||||
}
|
||||
|
||||
|
||||
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true);
|
||||
IScene scene;
|
||||
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
|
||||
}
|
||||
|
||||
private void HandleLoginEnable(string module, string[] cmd)
|
||||
|
|
|
@ -120,7 +120,14 @@ namespace OpenSim
|
|||
get { return m_moduleLoader; }
|
||||
set { m_moduleLoader = value; }
|
||||
}
|
||||
protected ModuleLoader m_moduleLoader;
|
||||
protected ModuleLoader m_moduleLoader;
|
||||
|
||||
protected RegistryCore m_applicationRegistry = new RegistryCore();
|
||||
|
||||
public RegistryCore ApplicationRegistry
|
||||
{
|
||||
get { return m_applicationRegistry; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
|
@ -176,7 +183,7 @@ namespace OpenSim
|
|||
base.StartupSpecific();
|
||||
|
||||
m_stats = StatsManager.StartCollectingSimExtraStats();
|
||||
|
||||
|
||||
LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_configSettings.LibrariesXMLFile);
|
||||
|
||||
// Standalone mode is determined by !startupConfig.GetBoolean("gridmode", false)
|
||||
|
@ -194,6 +201,7 @@ namespace OpenSim
|
|||
m_moduleLoader = new ModuleLoader(m_config.Source);
|
||||
|
||||
LoadPlugins();
|
||||
|
||||
|
||||
foreach (IApplicationPlugin plugin in m_plugins)
|
||||
{
|
||||
|
@ -202,7 +210,10 @@ namespace OpenSim
|
|||
|
||||
|
||||
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
|
||||
m_commsManager.GridService.RegionLoginsEnabled = true;
|
||||
if ((m_commsManager != null) && (m_commsManager.GridService != null))
|
||||
{
|
||||
m_commsManager.GridService.RegionLoginsEnabled = true;
|
||||
}
|
||||
|
||||
// If console exists add plugin commands.
|
||||
if (m_console != null)
|
||||
|
@ -541,9 +552,9 @@ namespace OpenSim
|
|||
/// <param name="regionInfo"></param>
|
||||
/// <param name="portadd_flag"></param>
|
||||
/// <returns></returns>
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag)
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
|
||||
{
|
||||
return CreateRegion(regionInfo, portadd_flag, false);
|
||||
return CreateRegion(regionInfo, portadd_flag, false, out scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -551,9 +562,9 @@ namespace OpenSim
|
|||
/// </summary>
|
||||
/// <param name="regionInfo"></param>
|
||||
/// <returns></returns>
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo)
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene)
|
||||
{
|
||||
return CreateRegion(regionInfo, false, true);
|
||||
return CreateRegion(regionInfo, false, true, out scene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -563,7 +574,7 @@ namespace OpenSim
|
|||
/// <param name="portadd_flag"></param>
|
||||
/// <param name="do_post_init"></param>
|
||||
/// <returns></returns>
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init)
|
||||
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
|
||||
{
|
||||
int port = regionInfo.InternalEndPoint.Port;
|
||||
|
||||
|
@ -640,6 +651,7 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
|
||||
mscene = scene;
|
||||
return clientServer;
|
||||
}
|
||||
|
||||
|
@ -722,8 +734,8 @@ namespace OpenSim
|
|||
m_clientServers[clientServerElement].Server.Close();
|
||||
m_clientServers.RemoveAt(clientServerElement);
|
||||
}
|
||||
|
||||
CreateRegion(whichRegion, true);
|
||||
IScene scene;
|
||||
CreateRegion(whichRegion, true, out scene);
|
||||
}
|
||||
|
||||
# region Setup methods
|
||||
|
@ -738,7 +750,7 @@ namespace OpenSim
|
|||
/// Handler to supply the current status of this sim
|
||||
/// </summary>
|
||||
/// Currently this is always OK if the simulator is still listening for connections on its HTTP service
|
||||
protected class SimStatusHandler : IStreamedRequestHandler
|
||||
public class SimStatusHandler : IStreamedRequestHandler
|
||||
{
|
||||
public byte[] Handle(string path, Stream request,
|
||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||
|
|
|
@ -45,16 +45,21 @@ namespace OpenSim.Region.ClientStack
|
|||
private static readonly ILog m_log
|
||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected IAssetCache m_assetCache;
|
||||
protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
|
||||
protected NetworkServersInfo m_networkServersInfo;
|
||||
|
||||
public NetworkServersInfo NetServersInfo
|
||||
{
|
||||
get { return m_networkServersInfo; }
|
||||
}
|
||||
|
||||
protected BaseHttpServer m_httpServer;
|
||||
protected uint m_httpServerPort;
|
||||
|
||||
public CommunicationsManager CommunicationsManager
|
||||
{
|
||||
get { return m_commsManager; }
|
||||
set { m_commsManager = value; }
|
||||
}
|
||||
protected CommunicationsManager m_commsManager;
|
||||
|
||||
|
@ -67,6 +72,14 @@ namespace OpenSim.Region.ClientStack
|
|||
get { return m_sceneManager; }
|
||||
}
|
||||
protected SceneManager m_sceneManager = new SceneManager();
|
||||
|
||||
protected IAssetCache m_assetCache;
|
||||
|
||||
public IAssetCache AssetCache
|
||||
{
|
||||
get { return m_assetCache; }
|
||||
set { m_assetCache = value; }
|
||||
}
|
||||
|
||||
protected abstract void Initialize();
|
||||
|
||||
|
|
Loading…
Reference in New Issue