From bc0bedf75d219e1ceda337cade1d47a5c7b18712 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 24 Feb 2009 19:00:36 +0000 Subject: More work on modulising the User Server. --- OpenSim/Grid/UserServer/Main.cs | 64 ++++++++++++---------- OpenSim/Grid/UserServer/UserServerCommandModule.cs | 27 +++++++-- 2 files changed, 56 insertions(+), 35 deletions(-) (limited to 'OpenSim/Grid/UserServer') diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 10235ab..e174b2d 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -97,24 +97,40 @@ namespace OpenSim.Grid.UserServer protected override void StartupSpecific() { - Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); + IInterServiceInventoryServices inventoryService = SetupRegisterCoreComponents(); m_stats = StatsManager.StartCollectingUserStats(); m_log.Info("[STARTUP]: Establishing data connection"); - - IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); - //setup database access service - m_userDataBaseService = new UserDataBaseService(inventoryService); - m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); - - //Register the database access service so modules can fetch it - // RegisterInterface(m_userDataBaseService); + m_userDataBaseService = new UserDataBaseService(); + m_userDataBaseService.Initialise(this); //setup services/modules StartupUserServerModules(); + StartOtherComponents(inventoryService); + + m_consoleCommandModule = new UserServerCommandModule(m_loginService); + m_consoleCommandModule.Initialise(this); + + //register event handlers + RegisterEventHandlers(); + + //PostInitialise the modules + m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here + m_userDataBaseService.PostInitialise(); + + //register http handlers and start http server + m_log.Info("[STARTUP]: Starting HTTP process"); + RegisterHttpHandlers(); + m_httpServer.Start(); + + base.StartupSpecific(); + } + + private void StartOtherComponents(IInterServiceInventoryServices inventoryService) + { m_gridInfoService = new GridInfoService(); StartupLoginService(inventoryService); @@ -124,26 +140,21 @@ namespace OpenSim.Grid.UserServer m_loginService.setloginlevel((int)Cfg.DefaultUserLevel); m_messagesService = new MessageServersConnector(); + } - m_consoleCommandModule = new UserServerCommandModule(Cfg, m_userDataBaseService, m_loginService); - m_consoleCommandModule.Initialise(this); - - //PostInitialise the modules - m_consoleCommandModule.PostInitialise(); + private IInterServiceInventoryServices SetupRegisterCoreComponents() + { + Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); - //register event handlers - RegisterEventHandlers(); + IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); - //register http handlers and start http server - m_log.Info("[STARTUP]: Starting HTTP process"); m_httpServer = new BaseHttpServer(Cfg.HttpPort); - RegisterHttpHandlers(); - m_httpServer.Start(); - - base.StartupSpecific(); - //register Console command handlers - RegisterConsoleCommands(); + RegisterInterface(m_console); + RegisterInterface(Cfg); + RegisterInterface(inventoryService); + + return inventoryService; } /// @@ -178,11 +189,6 @@ namespace OpenSim.Grid.UserServer m_messagesService.OnRegionShutdown += HandleRegionShutdown; } - protected virtual void RegisterConsoleCommands() - { - m_consoleCommandModule.RegisterConsoleCommands(m_console); - } - protected virtual void RegisterHttpHandlers() { m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); diff --git a/OpenSim/Grid/UserServer/UserServerCommandModule.cs b/OpenSim/Grid/UserServer/UserServerCommandModule.cs index d923c9a..41a7eed 100644 --- a/OpenSim/Grid/UserServer/UserServerCommandModule.cs +++ b/OpenSim/Grid/UserServer/UserServerCommandModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Grid.UserServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected ConsoleBase m_console; - protected UserConfig Cfg; + protected UserConfig m_cfg; protected UserDataBaseService m_userDataBaseService; protected UserLoginService m_loginService; @@ -59,10 +59,8 @@ namespace OpenSim.Grid.UserServer protected IUGAIMCore m_core; - public UserServerCommandModule(UserConfig cfg, UserDataBaseService userDBservice, UserLoginService loginService) + public UserServerCommandModule( UserLoginService loginService) { - Cfg = cfg; - m_userDataBaseService = userDBservice; m_loginService = loginService; } @@ -73,6 +71,23 @@ namespace OpenSim.Grid.UserServer public void PostInitialise() { + UserConfig cfg; + if (m_core.TryGet(out cfg)) + { + m_cfg = cfg; + } + + UserDataBaseService userDBservice; + if (m_core.TryGet(out userDBservice)) + { + m_userDataBaseService = userDBservice; + } + + ConsoleBase console; + if ((m_core.TryGet(out console)) && (m_cfg != null) && (m_userDataBaseService != null)) + { + RegisterConsoleCommands(console); + } } public void RegisterHandlers(BaseHttpServer httpServer) @@ -80,7 +95,7 @@ namespace OpenSim.Grid.UserServer } - public void RegisterConsoleCommands(ConsoleBase console) + private void RegisterConsoleCommands(ConsoleBase console) { m_console = console; m_console.Commands.AddCommand("userserver", false, "create user", @@ -279,7 +294,7 @@ namespace OpenSim.Grid.UserServer // requester.ReturnResponseVal = TestResponse; // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); SynchronousRestObjectPoster.BeginPostObject>( - "POST", Cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser); + "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser); break; case "logoff-user": -- cgit v1.1