From 1e2835a10c104b049c5552c64f77309b88f5650e Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 24 Feb 2009 17:57:26 +0000 Subject: More refactoring of the Grid/user/messaging servers. --- OpenSim/Grid/Framework/IUGAIMCore.cs | 3 +++ OpenSim/Grid/GridServer/GridServerBase.cs | 7 ++++- OpenSim/Grid/MessagingServer/Main.cs | 7 ++++- OpenSim/Grid/UserServer/Main.cs | 30 ++++++++++++++++----- OpenSim/Grid/UserServer/UserServerCommandModule.cs | 31 +++++++++++++++------- 5 files changed, 61 insertions(+), 17 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/Framework/IUGAIMCore.cs b/OpenSim/Grid/Framework/IUGAIMCore.cs index a7df0d4..77245ce 100644 --- a/OpenSim/Grid/Framework/IUGAIMCore.cs +++ b/OpenSim/Grid/Framework/IUGAIMCore.cs @@ -30,11 +30,14 @@ using OpenSim.Framework.Servers; namespace OpenSim.Grid.Framework { + public delegate void ShowHelpDelegate(string[] helpArgs); + public interface IUGAIMCore { T Get(); void RegisterInterface(T iface); bool TryGet(out T iface); BaseHttpServer GetHttpServer(); + void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp); } } diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 3313591..70dd8a6 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -217,7 +217,7 @@ namespace OpenSim.Grid.GridServer } #region IUGAIMCore - private readonly Dictionary m_moduleInterfaces = new Dictionary(); + protected Dictionary m_moduleInterfaces = new Dictionary(); /// /// Register an Module interface. @@ -255,6 +255,11 @@ namespace OpenSim.Grid.GridServer { return m_httpServer; } + + public void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp) + { + + } #endregion } } diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 420e8d5..07d0580 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -207,7 +207,7 @@ namespace OpenSim.Grid.MessagingServer } #region IUGAIMCore - private readonly Dictionary m_moduleInterfaces = new Dictionary(); + protected Dictionary m_moduleInterfaces = new Dictionary(); /// /// Register an Module interface. @@ -245,6 +245,11 @@ namespace OpenSim.Grid.MessagingServer { return m_httpServer; } + + public void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp) + { + + } #endregion } } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 61f9800..49b0071 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -67,8 +67,6 @@ namespace OpenSim.Grid.UserServer protected UserServerCommandModule m_consoleCommandModule; - private UUID m_lastCreatedUser = UUID.Random(); - public static void Main(string[] args) { XmlConfigurator.Configure(); @@ -127,7 +125,11 @@ namespace OpenSim.Grid.UserServer m_messagesService = new MessageServersConnector(); - m_consoleCommandModule = new UserServerCommandModule(m_console, Cfg, m_userDataBaseService, m_loginService); + m_consoleCommandModule = new UserServerCommandModule(Cfg, m_userDataBaseService, m_loginService); + m_consoleCommandModule.Initialise(this); + + //PostInitialise the modules + m_consoleCommandModule.PostInitialise(); //register event handlers RegisterEventHandlers(); @@ -178,7 +180,7 @@ namespace OpenSim.Grid.UserServer protected virtual void RegisterConsoleCommands() { - m_consoleCommandModule.RegisterConsoleCommands(); + m_consoleCommandModule.RegisterConsoleCommands(m_console); } protected virtual void RegisterHttpHandlers() @@ -201,7 +203,9 @@ namespace OpenSim.Grid.UserServer } #region IUGAIMCore - private readonly Dictionary m_moduleInterfaces = new Dictionary(); + protected Dictionary m_moduleInterfaces = new Dictionary(); + protected List m_showHelpDelegates = new List(); + /// /// Register an Module interface. @@ -239,6 +243,14 @@ namespace OpenSim.Grid.UserServer { return m_httpServer; } + + public void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp) + { + lock (m_showHelpDelegates) + { + m_showHelpDelegates.Add(showHelp); + } + } #endregion #region Console Command Handlers @@ -247,7 +259,13 @@ namespace OpenSim.Grid.UserServer { base.ShowHelp(helpArgs); - m_consoleCommandModule.ShowHelp(helpArgs); + lock (m_showHelpDelegates) + { + foreach (ShowHelpDelegate d in m_showHelpDelegates) + { + d(helpArgs); + } + } } #endregion diff --git a/OpenSim/Grid/UserServer/UserServerCommandModule.cs b/OpenSim/Grid/UserServer/UserServerCommandModule.cs index fbdd73f..f3dfc23 100644 --- a/OpenSim/Grid/UserServer/UserServerCommandModule.cs +++ b/OpenSim/Grid/UserServer/UserServerCommandModule.cs @@ -55,18 +55,35 @@ namespace OpenSim.Grid.UserServer protected UserDataBaseService m_userDataBaseService; protected UserLoginService m_loginService; - private UUID m_lastCreatedUser = UUID.Random(); + protected UUID m_lastCreatedUser = UUID.Random(); - public UserServerCommandModule(ConsoleBase console, UserConfig cfg, UserDataBaseService userDBservice, UserLoginService loginService) + protected IUGAIMCore m_core; + + public UserServerCommandModule(UserConfig cfg, UserDataBaseService userDBservice, UserLoginService loginService) { - m_console = console; Cfg = cfg; m_userDataBaseService = userDBservice; m_loginService = loginService; } - public virtual void RegisterConsoleCommands() + public void Initialise(IUGAIMCore core) + { + m_core = core; + } + + public void PostInitialise() + { + m_core.RegisterConsoleHelpDelegate(ShowHelp); + } + + public void RegisterHandlers(BaseHttpServer httpServer) { + + } + + public void RegisterConsoleCommands(ConsoleBase console) + { + m_console = console; m_console.Commands.AddCommand("userserver", false, "create user", "create user [ [ [ [email]]]]", "Create a new user account", RunCommand); @@ -95,10 +112,6 @@ namespace OpenSim.Grid.UserServer m_console.Commands.AddCommand("userserver", false, "logoff-user", "logoff-user ", "Log off a named user", RunCommand); - - m_console.Commands.AddCommand("userserver", false, "test-command", - "test-command", - "test command", HandleTestCommand); } #region Console Command Handlers @@ -335,7 +348,7 @@ namespace OpenSim.Grid.UserServer } } - public virtual void ShowHelp(string[] helpArgs) + public void ShowHelp(string[] helpArgs) { m_console.Notice("create user - create a new user"); m_console.Notice("logoff-user - logs off the specified user from the grid"); -- cgit v1.1