aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs147
-rw-r--r--OpenSim/Grid/GridServer.Modules/Resources/GridServer.Modules.addin.xml11
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs101
-rw-r--r--prebuild.xml3
4 files changed, 170 insertions, 92 deletions
diff --git a/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs b/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs
new file mode 100644
index 0000000..fd7f4c1
--- /dev/null
+++ b/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs
@@ -0,0 +1,147 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Text;
5using log4net;
6using OpenSim.Framework;
7using OpenSim.Framework.Console;
8using OpenSim.Grid.Framework;
9using OpenSim.Grid;
10
11namespace OpenSim.Grid.GridServer.Modules
12{
13 public class GridServerPlugin : IGridPlugin
14 {
15 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
16
17 protected GridXmlRpcModule m_gridXmlRpcModule;
18 protected GridMessagingModule m_gridMessageModule;
19 protected GridRestModule m_gridRestModule;
20
21 protected GridDBService m_gridDBService;
22
23 protected string m_version;
24
25 protected GridConfig m_config;
26
27 protected IGridServiceCore m_core;
28
29 protected ConsoleBase m_console;
30
31 #region IGridPlugin Members
32
33 public void Initialise(GridServerBase gridServer)
34 {
35 m_core = gridServer;
36 m_config = gridServer.Config;
37 m_version = gridServer.Version;
38 m_console = MainConsole.Instance;
39
40 AddConsoleCommands();
41
42 SetupGridServices();
43 }
44
45 #endregion
46
47 #region IPlugin Members
48
49 public string Version
50 {
51 get { return "0.0"; }
52 }
53
54 public string Name
55 {
56 get { return "GridServerPlugin"; }
57 }
58
59 public void Initialise()
60 {
61
62 }
63
64 #endregion
65
66 protected virtual void SetupGridServices()
67 {
68 // m_log.Info("[DATA]: Connecting to Storage Server");
69 m_gridDBService = new GridDBService();
70 m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
71
72 //Register the database access service so modules can fetch it
73 // RegisterInterface<GridDBService>(m_gridDBService);
74
75 m_gridMessageModule = new GridMessagingModule();
76 m_gridMessageModule.Initialise(m_version, m_gridDBService, m_core, m_config);
77
78 m_gridXmlRpcModule = new GridXmlRpcModule();
79 m_gridXmlRpcModule.Initialise(m_version, m_gridDBService, m_core, m_config);
80
81 m_gridRestModule = new GridRestModule();
82 m_gridRestModule.Initialise(m_version, m_gridDBService, m_core, m_config);
83
84 m_gridMessageModule.PostInitialise();
85 m_gridXmlRpcModule.PostInitialise();
86 m_gridRestModule.PostInitialise();
87 }
88
89 #region Console Command Handlers
90
91 protected virtual void AddConsoleCommands()
92 {
93 m_console.Commands.AddCommand("gridserver", false,
94 "enable registration",
95 "enable registration",
96 "Enable new regions to register", HandleRegistration);
97
98 m_console.Commands.AddCommand("gridserver", false,
99 "disable registration",
100 "disable registration",
101 "Disable registering new regions", HandleRegistration);
102
103 m_console.Commands.AddCommand("gridserver", false, "show status",
104 "show status",
105 "Show registration status", HandleShowStatus);
106 }
107
108 private void HandleRegistration(string module, string[] cmd)
109 {
110 switch (cmd[0])
111 {
112 case "enable":
113 m_config.AllowRegionRegistration = true;
114 m_log.Info("Region registration enabled");
115 break;
116 case "disable":
117 m_config.AllowRegionRegistration = false;
118 m_log.Info("Region registration disabled");
119 break;
120 }
121 }
122
123 private void HandleShowStatus(string module, string[] cmd)
124 {
125 if (m_config.AllowRegionRegistration)
126 {
127 m_log.Info("Region registration enabled.");
128 }
129 else
130 {
131 m_log.Info("Region registration disabled.");
132 }
133 }
134
135 #endregion
136
137
138
139 #region IDisposable Members
140
141 public void Dispose()
142 {
143 }
144
145 #endregion
146 }
147}
diff --git a/OpenSim/Grid/GridServer.Modules/Resources/GridServer.Modules.addin.xml b/OpenSim/Grid/GridServer.Modules/Resources/GridServer.Modules.addin.xml
new file mode 100644
index 0000000..c2c5ac3
--- /dev/null
+++ b/OpenSim/Grid/GridServer.Modules/Resources/GridServer.Modules.addin.xml
@@ -0,0 +1,11 @@
1<Addin id="OpenSim.Grid.GridServer.Modules" version="0.1">
2 <Runtime>
3 <Import assembly="OpenSim.Grid.GridServer.Modules.dll"/>
4 </Runtime>
5 <Dependencies>
6 <Addin id="OpenSim.Grid.GridServer" version="0.5" />
7 </Dependencies>
8 <Extension path = "/OpenSim/GridServer">
9 <Plugin id="GridServerModules" type="OpenSim.Grid.GridServer.Modules.GridServerPlugin" />
10 </Extension>
11</Addin>
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index 1ee97f4..a1170f8 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -35,7 +35,6 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Grid.Framework; 37using OpenSim.Grid.Framework;
38using OpenSim.Grid.GridServer.Modules;
39 38
40namespace OpenSim.Grid.GridServer 39namespace OpenSim.Grid.GridServer
41{ 40{
@@ -47,11 +46,15 @@ namespace OpenSim.Grid.GridServer
47 46
48 protected GridConfig m_config; 47 protected GridConfig m_config;
49 48
50 protected GridXmlRpcModule m_gridXmlRpcModule; 49 public GridConfig Config
51 protected GridMessagingModule m_gridMessageModule; 50 {
52 protected GridRestModule m_gridRestModule; 51 get { return m_config; }
52 }
53 53
54 protected GridDBService m_gridDBService; 54 public string Version
55 {
56 get { return m_version; }
57 }
55 58
56 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>(); 59 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
57 60
@@ -71,34 +74,6 @@ namespace OpenSim.Grid.GridServer
71 MainConsole.Instance = m_console; 74 MainConsole.Instance = m_console;
72 } 75 }
73 76
74 private void HandleRegistration(string module, string[] cmd)
75 {
76 switch (cmd[0])
77 {
78 case "enable":
79 m_config.AllowRegionRegistration = true;
80 m_log.Info("Region registration enabled");
81 break;
82 case "disable":
83 m_config.AllowRegionRegistration = false;
84 m_log.Info("Region registration disabled");
85 break;
86 }
87 }
88
89 private void HandleShowStatus(string module, string[] cmd)
90 {
91 if (m_config.AllowRegionRegistration)
92 {
93 m_log.Info("Region registration enabled.");
94 }
95 else
96 {
97 m_log.Info("Region registration disabled.");
98 }
99 }
100
101
102 protected override void StartupSpecific() 77 protected override void StartupSpecific()
103 { 78 {
104 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); 79 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
@@ -106,43 +81,14 @@ namespace OpenSim.Grid.GridServer
106 m_log.Info("[GRID]: Starting HTTP process"); 81 m_log.Info("[GRID]: Starting HTTP process");
107 m_httpServer = new BaseHttpServer(m_config.HttpPort); 82 m_httpServer = new BaseHttpServer(m_config.HttpPort);
108 83
109 SetupGridServices();
110
111 AddHttpHandlers();
112
113 LoadPlugins(); 84 LoadPlugins();
114 85
115 m_httpServer.Start(); 86 m_httpServer.Start();
116 87
117 // m_log.Info("[GRID]: Starting sim status checker");
118 //
119 // Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
120 // simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
121 // simCheckTimer.Enabled = true;
122
123 base.StartupSpecific(); 88 base.StartupSpecific();
124
125 m_console.Commands.AddCommand("gridserver", false,
126 "enable registration",
127 "enable registration",
128 "Enable new regions to register", HandleRegistration);
129
130 m_console.Commands.AddCommand("gridserver", false,
131 "disable registration",
132 "disable registration",
133 "Disable registering new regions", HandleRegistration);
134
135 m_console.Commands.AddCommand("gridserver", false, "show status",
136 "show status",
137 "Show registration status", HandleShowStatus);
138 } 89 }
139 90
140 protected void AddHttpHandlers() 91 protected virtual void LoadPlugins()
141 {
142 // Registering Handlers is now done in the components/modules
143 }
144
145 protected void LoadPlugins()
146 { 92 {
147 PluginLoader<IGridPlugin> loader = 93 PluginLoader<IGridPlugin> loader =
148 new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this)); 94 new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this));
@@ -151,39 +97,12 @@ namespace OpenSim.Grid.GridServer
151 m_plugins = loader.Plugins; 97 m_plugins = loader.Plugins;
152 } 98 }
153 99
154 protected virtual void SetupGridServices()
155 {
156 m_log.Info("[DATA]: Connecting to Storage Server");
157 m_gridDBService = new GridDBService();
158 m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
159
160 //Register the database access service so modules can fetch it
161 // RegisterInterface<GridDBService>(m_gridDBService);
162
163 m_gridMessageModule = new GridMessagingModule();
164 m_gridMessageModule.Initialise(m_version, m_gridDBService, this, m_config);
165
166 m_gridXmlRpcModule = new GridXmlRpcModule();
167 m_gridXmlRpcModule.Initialise(m_version, m_gridDBService, this, m_config);
168
169 m_gridRestModule = new GridRestModule();
170 m_gridRestModule.Initialise(m_version, m_gridDBService, this, m_config);
171
172 m_gridMessageModule.PostInitialise();
173 m_gridXmlRpcModule.PostInitialise();
174 m_gridRestModule.PostInitialise();
175 }
176
177 public void CheckSims(object sender, ElapsedEventArgs e)
178 {
179 }
180
181 public override void ShutdownSpecific() 100 public override void ShutdownSpecific()
182 { 101 {
183 foreach (IGridPlugin plugin in m_plugins) plugin.Dispose(); 102 foreach (IGridPlugin plugin in m_plugins) plugin.Dispose();
184 } 103 }
185 104
186 #region IUGAIMCore 105 #region IServiceCore
187 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>(); 106 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
188 107
189 /// <summary> 108 /// <summary>
diff --git a/prebuild.xml b/prebuild.xml
index 70d4fea..1bb0f8e 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -738,12 +738,14 @@
738 <Reference name="OpenSim.Data.MySQL"/> 738 <Reference name="OpenSim.Data.MySQL"/>
739 <Reference name="OpenSim.Grid.Framework"/> 739 <Reference name="OpenSim.Grid.Framework"/>
740 <Reference name="OpenMetaverseTypes.dll"/> 740 <Reference name="OpenMetaverseTypes.dll"/>
741 <Reference name="OpenSim.Grid.GridServer"/>
741 <Reference name="OpenMetaverse.dll"/> 742 <Reference name="OpenMetaverse.dll"/>
742 <Reference name="XMLRPC.dll"/> 743 <Reference name="XMLRPC.dll"/>
743 <Reference name="log4net.dll"/> 744 <Reference name="log4net.dll"/>
744 745
745 <Files> 746 <Files>
746 <Match pattern="*.cs" recurse="true"/> 747 <Match pattern="*.cs" recurse="true"/>
748 <Match pattern="*.addin.xml" path="Resources" buildAction="EmbeddedResource" recurse="true"/>
747 </Files> 749 </Files>
748 </Project> 750 </Project>
749 751
@@ -772,7 +774,6 @@
772 <Reference name="OpenSim.Data"/> 774 <Reference name="OpenSim.Data"/>
773 <Reference name="OpenSim.Data.MySQL"/> 775 <Reference name="OpenSim.Data.MySQL"/>
774 <Reference name="OpenSim.Grid.Framework"/> 776 <Reference name="OpenSim.Grid.Framework"/>
775 <Reference name="OpenSim.Grid.GridServer.Modules"/>
776 <Reference name="OpenMetaverseTypes.dll"/> 777 <Reference name="OpenMetaverseTypes.dll"/>
777 <Reference name="OpenMetaverse.dll"/> 778 <Reference name="OpenMetaverse.dll"/>
778 <Reference name="XMLRPC.dll"/> 779 <Reference name="XMLRPC.dll"/>