More work on modulising the User Server.

GenericGridServerConcept
MW 2009-02-24 19:00:36 +00:00
parent 8645fa9215
commit bc0bedf75d
3 changed files with 99 additions and 35 deletions

View File

@ -35,11 +35,14 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
using OpenSim.Grid.Framework;
namespace OpenSim.Grid.UserServer.Modules
{
public class UserDataBaseService : UserManagerBase
{
protected IUGAIMCore m_core;
public UserDataBaseService()
: base(null)
{
@ -50,6 +53,46 @@ namespace OpenSim.Grid.UserServer.Modules
{
}
public void Initialise(IUGAIMCore core)
{
m_core = core;
//we only need core components so we can request them from here
IInterServiceInventoryServices inventoryService;
if (m_core.TryGet<IInterServiceInventoryServices>(out inventoryService))
{
m_interServiceInventoryService = inventoryService;
}
UserConfig cfg;
if (m_core.TryGet<UserConfig>(out cfg))
{
AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect);
}
m_core.RegisterInterface<UserDataBaseService>(this);
}
public void PostInitialise()
{
}
public void RegisterHandlers(BaseHttpServer httpServer)
{
}
public UserAgentData GetUserAgentData(UUID AgentID)
{
UserProfileData userProfile = GetUserProfile(AgentID);
if (userProfile != null)
{
return userProfile.CurrentAgent;
}
return null;
}
public override UserProfileData SetupMasterUser(string firstName, string lastName)
{
throw new Exception("The method or operation is not implemented.");

View File

@ -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<UserDataBaseService>(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);
private IInterServiceInventoryServices SetupRegisterCoreComponents()
{
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
//PostInitialise the modules
m_consoleCommandModule.PostInitialise();
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
//register event handlers
RegisterEventHandlers();
//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<ConsoleBase>(m_console);
RegisterInterface<UserConfig>(Cfg);
RegisterInterface<IInterServiceInventoryServices>(inventoryService);
return inventoryService;
}
/// <summary>
@ -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);

View File

@ -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<UserConfig>(out cfg))
{
m_cfg = cfg;
}
UserDataBaseService userDBservice;
if (m_core.TryGet<UserDataBaseService>(out userDBservice))
{
m_userDataBaseService = userDBservice;
}
ConsoleBase console;
if ((m_core.TryGet<ConsoleBase>(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<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
"POST", Cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
"POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
break;
case "logoff-user":