More refactoring of the Grid/user/messaging servers.

GenericGridServerConcept
MW 2009-02-24 17:57:26 +00:00
parent 98178b4e9f
commit 1e2835a10c
5 changed files with 61 additions and 17 deletions

View File

@ -30,11 +30,14 @@ using OpenSim.Framework.Servers;
namespace OpenSim.Grid.Framework
{
public delegate void ShowHelpDelegate(string[] helpArgs);
public interface IUGAIMCore
{
T Get<T>();
void RegisterInterface<T>(T iface);
bool TryGet<T>(out T iface);
BaseHttpServer GetHttpServer();
void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp);
}
}

View File

@ -217,7 +217,7 @@ namespace OpenSim.Grid.GridServer
}
#region IUGAIMCore
private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
/// <summary>
/// Register an Module interface.
@ -255,6 +255,11 @@ namespace OpenSim.Grid.GridServer
{
return m_httpServer;
}
public void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp)
{
}
#endregion
}
}

View File

@ -207,7 +207,7 @@ namespace OpenSim.Grid.MessagingServer
}
#region IUGAIMCore
private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
/// <summary>
/// Register an Module interface.
@ -245,6 +245,11 @@ namespace OpenSim.Grid.MessagingServer
{
return m_httpServer;
}
public void RegisterConsoleHelpDelegate(ShowHelpDelegate showHelp)
{
}
#endregion
}
}

View File

@ -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<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
protected List<ShowHelpDelegate> m_showHelpDelegates = new List<ShowHelpDelegate>();
/// <summary>
/// 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

View File

@ -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 [<first> [<last> [<x> <y> [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 <first> <last> <message>",
"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 <firstname> <lastname> <message> - logs off the specified user from the grid");