aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer/GridServerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/GridServer/GridServerBase.cs')
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs170
1 files changed, 0 insertions, 170 deletions
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
deleted file mode 100644
index 9b0d7ea..0000000
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Grid.Framework;
39
40namespace OpenSim.Grid.GridServer
41{
42 /// <summary>
43 /// </summary>
44 public class GridServerBase : BaseOpenSimServer, IGridServiceCore
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 protected GridConfig m_config;
49 public string m_consoleType = "local";
50 public IConfigSource m_configSource = null;
51 public string m_configFile = "GridServer_Config.xml";
52
53 public GridConfig Config
54 {
55 get { return m_config; }
56 }
57
58 public string Version
59 {
60 get { return m_version; }
61 }
62
63 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
64
65 public void Work()
66 {
67 m_console.Output("Enter help for a list of commands\n");
68
69 while (true)
70 {
71 m_console.Prompt();
72 }
73 }
74
75 public GridServerBase()
76 {
77 }
78
79 protected override void StartupSpecific()
80 {
81 switch (m_consoleType)
82 {
83 case "rest":
84 m_console = new RemoteConsole("Grid");
85 break;
86 case "basic":
87 m_console = new CommandConsole("Grid");
88 break;
89 default:
90 m_console = new LocalConsole("Grid");
91 break;
92 }
93 MainConsole.Instance = m_console;
94 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), m_configFile)));
95
96 m_log.Info("[GRID]: Starting HTTP process");
97 m_httpServer = new BaseHttpServer(m_config.HttpPort);
98 if (m_console is RemoteConsole)
99 {
100 RemoteConsole c = (RemoteConsole)m_console;
101 c.SetServer(m_httpServer);
102 IConfig netConfig = m_configSource.AddConfig("Network");
103 netConfig.Set("ConsoleUser", m_config.ConsoleUser);
104 netConfig.Set("ConsolePass", m_config.ConsolePass);
105 c.ReadConfig(m_configSource);
106 }
107
108 LoadPlugins();
109
110 m_httpServer.Start();
111
112 base.StartupSpecific();
113 }
114
115 protected virtual void LoadPlugins()
116 {
117 using (PluginLoader<IGridPlugin> loader = new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this)))
118 {
119 loader.Load("/OpenSim/GridServer");
120 m_plugins = loader.Plugins;
121 }
122 }
123
124 public override void ShutdownSpecific()
125 {
126 foreach (IGridPlugin plugin in m_plugins) plugin.Dispose();
127 }
128
129 #region IServiceCore
130 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
131
132 /// <summary>
133 /// Register an Module interface.
134 /// </summary>
135 /// <typeparam name="T"></typeparam>
136 /// <param name="iface"></param>
137 public void RegisterInterface<T>(T iface)
138 {
139 lock (m_moduleInterfaces)
140 {
141 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
142 {
143 m_moduleInterfaces.Add(typeof(T), iface);
144 }
145 }
146 }
147
148 public bool TryGet<T>(out T iface)
149 {
150 if (m_moduleInterfaces.ContainsKey(typeof(T)))
151 {
152 iface = (T)m_moduleInterfaces[typeof(T)];
153 return true;
154 }
155 iface = default(T);
156 return false;
157 }
158
159 public T Get<T>()
160 {
161 return (T)m_moduleInterfaces[typeof(T)];
162 }
163
164 public BaseHttpServer GetHttpServer()
165 {
166 return m_httpServer;
167 }
168 #endregion
169 }
170}