aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base/ServerUtils.cs
diff options
context:
space:
mode:
authorBlueWall2012-10-06 11:48:21 -0400
committerBlueWall2012-10-06 11:48:21 -0400
commit440726250cc2a523463f575b682a6ddb6242408c (patch)
treef782c828486b4de6eb978f4c9664e6936b734899 /OpenSim/Server/Base/ServerUtils.cs
parentRemove duplicate files (diff)
downloadopensim-SC_OLD-440726250cc2a523463f575b682a6ddb6242408c.zip
opensim-SC_OLD-440726250cc2a523463f575b682a6ddb6242408c.tar.gz
opensim-SC_OLD-440726250cc2a523463f575b682a6ddb6242408c.tar.bz2
opensim-SC_OLD-440726250cc2a523463f575b682a6ddb6242408c.tar.xz
Added parts to manage repositories and plugin management
This is working - more testing to follow, then soem documentation
Diffstat (limited to 'OpenSim/Server/Base/ServerUtils.cs')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs106
1 files changed, 106 insertions, 0 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 4a696c4..6c6af62 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -36,9 +36,115 @@ using log4net;
36using Nini.Config; 36using Nini.Config;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenMetaverse; 38using OpenMetaverse;
39using Mono.Addins;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Framework.Servers;
39 42
43
44[assembly:AddinRoot("Robust", "0.1")]
40namespace OpenSim.Server.Base 45namespace OpenSim.Server.Base
41{ 46{
47 [TypeExtensionPoint(Path="/Robust/Connector", Name="RobustConnector")]
48 public interface IRobustConnector
49 {
50 string ConfigName
51 {
52 get;
53 }
54
55 bool Enabled
56 {
57 get;
58 }
59
60 string PluginPath
61 {
62 get;
63 set;
64 }
65
66 uint Configure(IConfigSource config);
67 void Initialize(IHttpServer server);
68 }
69
70 public class PluginLoader
71 {
72 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
73
74 public AddinRegistry Registry
75 {
76 get;
77 private set;
78 }
79
80 public IConfigSource Config
81 {
82 get;
83 private set;
84 }
85
86 public PluginLoader(IConfigSource config, string registryPath)
87 {
88 Config = config;
89
90 Registry = new AddinRegistry(registryPath, ".");
91 AddinManager.Initialize(registryPath);
92 AddinManager.Registry.Update();
93 CommandManager commandmanager = new CommandManager(Registry);
94 AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged);
95 }
96
97 private void OnExtensionChanged(object s, ExtensionNodeEventArgs args)
98 {
99 IRobustConnector connector = (IRobustConnector)args.ExtensionObject;
100
101 Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id);
102 m_log.InfoFormat("[SERVER]: Extension Change: {0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.'));
103
104 switch(args.Change)
105 {
106 case ExtensionChange.Add:
107 connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.'));
108 LoadPlugin(connector);
109 break;
110 case ExtensionChange.Remove:
111 UnloadPlugin(connector);
112 break;
113 }
114 }
115
116 private void LoadPlugin(IRobustConnector connector)
117 {
118 IHttpServer server = null;
119 uint port = connector.Configure(Config);
120
121 if(connector.Enabled)
122 {
123 server = GetServer(connector, port);
124 m_log.InfoFormat("[SERVER]: Path is {0}", connector.PluginPath);
125 connector.Initialize(server);
126 }
127 else
128 m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName);
129 }
130
131 private void UnloadPlugin(IRobustConnector connector)
132 {
133 }
134
135 private IHttpServer GetServer(IRobustConnector connector, uint port)
136 {
137 IHttpServer server;
138
139 if(port != 0)
140 server = MainServer.GetHttpServer(port);
141 else
142 server = MainServer.Instance;
143
144 return server;
145 }
146 }
147
42 public static class ServerUtils 148 public static class ServerUtils
43 { 149 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 150 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);