aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs
diff options
context:
space:
mode:
authorMW2009-02-27 15:57:09 +0000
committerMW2009-02-27 15:57:09 +0000
commitd45fa9c2df01286d35542665d65071deca0fbb07 (patch)
tree70518a46cbb08431a02128cb73784b2bda67e594 /OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs
parentApplied patch from Mantis# 3240, thanks tlaukkan/Tommil (diff)
downloadopensim-SC-d45fa9c2df01286d35542665d65071deca0fbb07.zip
opensim-SC-d45fa9c2df01286d35542665d65071deca0fbb07.tar.gz
opensim-SC-d45fa9c2df01286d35542665d65071deca0fbb07.tar.bz2
opensim-SC-d45fa9c2df01286d35542665d65071deca0fbb07.tar.xz
Added GridServerPlugin class (which implements IGridPlugin) to OpenSim.Grid.GridServer.Modules.
This class handles all the initialising of the grid server. And made GridServer into basically a generic server that just loads plugins. So this is a step towards having a generic server that loads service modules.
Diffstat (limited to 'OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs')
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs147
1 files changed, 147 insertions, 0 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}