diff options
author | Charles Krinke | 2008-06-27 02:15:57 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-27 02:15:57 +0000 |
commit | ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03 (patch) | |
tree | 97f8cce96ea2e98b96b36e523c59361bf00f63b8 | |
parent | Mantis#1610. Thank you, Melanie for a patch that: (diff) | |
download | opensim-SC_OLD-ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03.zip opensim-SC_OLD-ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03.tar.gz opensim-SC_OLD-ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03.tar.bz2 opensim-SC_OLD-ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03.tar.xz |
Mantis#1591. Thank you graciously, Sempuki for a patch that:
Currently module loading is done ad-hoc. I propose creating a simple
loader class that leverages Mono.Addins (and perhaps the new .NET
addins when they become available in mono). Attached is a basic
patch for review that compiles into HEAD, but doesn't yet replace
any existing ad-hoc loaders.
19 files changed, 244 insertions, 64 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 4b11fd4..6743fb4 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs | |||
@@ -46,6 +46,19 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
46 | 46 | ||
47 | #region IApplicationPlugin Members | 47 | #region IApplicationPlugin Members |
48 | 48 | ||
49 | // TODO: required by IPlugin, but likely not at all right | ||
50 | string m_name = "LoadRegionsPlugin"; | ||
51 | string m_version = "0.0"; | ||
52 | |||
53 | public string Version { get { return m_version; } } | ||
54 | public string Name { get { return m_name; } } | ||
55 | |||
56 | public void Initialise() | ||
57 | { | ||
58 | m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); | ||
59 | throw new PluginNotInitialisedException (Name); | ||
60 | } | ||
61 | |||
49 | public void Initialise(OpenSimBase openSim) | 62 | public void Initialise(OpenSimBase openSim) |
50 | { | 63 | { |
51 | m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); | 64 | m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); |
@@ -78,7 +91,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
78 | openSim.ModuleLoader.ClearCache(); | 91 | openSim.ModuleLoader.ClearCache(); |
79 | } | 92 | } |
80 | 93 | ||
81 | public void Close() | 94 | public void Dispose() |
82 | { | 95 | { |
83 | } | 96 | } |
84 | 97 | ||
@@ -113,4 +126,4 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
113 | } | 126 | } |
114 | } | 127 | } |
115 | } | 128 | } |
116 | } \ No newline at end of file | 129 | } |
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 5063375..d3fe0e0 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -54,6 +54,19 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
54 | private BaseHttpServer m_httpd; | 54 | private BaseHttpServer m_httpd; |
55 | private string requiredPassword = String.Empty; | 55 | private string requiredPassword = String.Empty; |
56 | 56 | ||
57 | // TODO: required by IPlugin, but likely not at all right | ||
58 | string m_name = "RemoteAdminPlugin"; | ||
59 | string m_version = "0.0"; | ||
60 | |||
61 | public string Version { get { return m_version; } } | ||
62 | public string Name { get { return m_name; } } | ||
63 | |||
64 | public void Initialise() | ||
65 | { | ||
66 | m_log.Info("[RADMIN]: " + Name + " cannot be default-initialized!"); | ||
67 | throw new PluginNotInitialisedException (Name); | ||
68 | } | ||
69 | |||
57 | public void Initialise(OpenSimBase openSim) | 70 | public void Initialise(OpenSimBase openSim) |
58 | { | 71 | { |
59 | try | 72 | try |
@@ -607,8 +620,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
607 | return response; | 620 | return response; |
608 | } | 621 | } |
609 | 622 | ||
610 | public void Close() | 623 | public void Dispose() |
611 | { | 624 | { |
612 | } | 625 | } |
613 | } | 626 | } |
614 | } \ No newline at end of file | 627 | } |
diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index 4558d4d..78e0e66 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | |||
@@ -188,6 +188,17 @@ namespace OpenSim.ApplicationPlugins.Rest | |||
188 | 188 | ||
189 | 189 | ||
190 | #region methods | 190 | #region methods |
191 | // TODO: required by IPlugin, but likely not at all right | ||
192 | string m_version = "0.0"; | ||
193 | |||
194 | public string Version { get { return m_version; } } | ||
195 | |||
196 | public void Initialise() | ||
197 | { | ||
198 | m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!"); | ||
199 | throw new PluginNotInitialisedException (Name); | ||
200 | } | ||
201 | |||
191 | /// <summary> | 202 | /// <summary> |
192 | /// This method is called by OpenSimMain immediately after loading the | 203 | /// This method is called by OpenSimMain immediately after loading the |
193 | /// plugin and after basic server setup, but before running any server commands. | 204 | /// plugin and after basic server setup, but before running any server commands. |
@@ -357,6 +368,11 @@ namespace OpenSim.ApplicationPlugins.Rest | |||
357 | _agents = null; | 368 | _agents = null; |
358 | } | 369 | } |
359 | 370 | ||
371 | public virtual void Dispose() | ||
372 | { | ||
373 | Close(); | ||
374 | } | ||
375 | |||
360 | /// <summary> | 376 | /// <summary> |
361 | /// Return a failure message. | 377 | /// Return a failure message. |
362 | /// </summary> | 378 | /// </summary> |
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index e3b5c25..ca1de5a 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs | |||
@@ -42,5 +42,6 @@ namespace OpenSim.Data | |||
42 | public abstract string Name { get; } | 42 | public abstract string Name { get; } |
43 | public abstract void Initialise(string connect); | 43 | public abstract void Initialise(string connect); |
44 | public abstract void Initialise(); | 44 | public abstract void Initialise(); |
45 | public abstract void Dispose(); | ||
45 | } | 46 | } |
46 | } | 47 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 50e2e3a..44d78ed 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -218,6 +218,8 @@ namespace OpenSim.Data.MSSQL | |||
218 | 218 | ||
219 | #region IPlugin Members | 219 | #region IPlugin Members |
220 | 220 | ||
221 | override public void Dispose() { } | ||
222 | |||
221 | /// <summary> | 223 | /// <summary> |
222 | /// <para>Initialises asset interface</para> | 224 | /// <para>Initialises asset interface</para> |
223 | /// <para> | 225 | /// <para> |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a64a256..ac7fa1d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL | |||
39 | /// <summary> | 39 | /// <summary> |
40 | /// A MySQL Interface for the Asset Server | 40 | /// A MySQL Interface for the Asset Server |
41 | /// </summary> | 41 | /// </summary> |
42 | internal class MySQLAssetData : AssetDataBase, IPlugin | 42 | internal class MySQLAssetData : AssetDataBase |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
@@ -109,6 +109,8 @@ namespace OpenSim.Data.MySQL | |||
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | override public void Dispose() { } | ||
113 | |||
112 | #region IAssetProvider Members | 114 | #region IAssetProvider Members |
113 | 115 | ||
114 | /// <summary> | 116 | /// <summary> |
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index 89f907f..a339ee3 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs | |||
@@ -43,7 +43,7 @@ namespace OpenSim.Data.NHibernate | |||
43 | /// <summary> | 43 | /// <summary> |
44 | /// A User storage interface for the DB4o database system | 44 | /// A User storage interface for the DB4o database system |
45 | /// </summary> | 45 | /// </summary> |
46 | public class NHibernateAssetData : AssetDataBase, IDisposable | 46 | public class NHibernateAssetData : AssetDataBase |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
@@ -51,6 +51,8 @@ namespace OpenSim.Data.NHibernate | |||
51 | private ISessionFactory factory; | 51 | private ISessionFactory factory; |
52 | private ISession session; | 52 | private ISession session; |
53 | 53 | ||
54 | override public void Dispose() { } | ||
55 | |||
54 | public override void Initialise() | 56 | public override void Initialise() |
55 | { | 57 | { |
56 | Initialise("SQLiteDialect;SqliteClientDriver;URI=file:Asset.db,version=3"); | 58 | Initialise("SQLiteDialect;SqliteClientDriver;URI=file:Asset.db,version=3"); |
@@ -173,9 +175,5 @@ namespace OpenSim.Data.NHibernate | |||
173 | get { return "0.1"; } | 175 | get { return "0.1"; } |
174 | } | 176 | } |
175 | 177 | ||
176 | public void Dispose() | ||
177 | { | ||
178 | |||
179 | } | ||
180 | } | 178 | } |
181 | } | 179 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index f560b9e..018501f 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -56,6 +56,8 @@ namespace OpenSim.Data.SQLite | |||
56 | 56 | ||
57 | private SqliteConnection m_conn; | 57 | private SqliteConnection m_conn; |
58 | 58 | ||
59 | override public void Dispose() { } | ||
60 | |||
59 | /// <summary> | 61 | /// <summary> |
60 | /// <list type="bullet"> | 62 | /// <list type="bullet"> |
61 | /// <item>Initialises AssetData interface</item> | 63 | /// <item>Initialises AssetData interface</item> |
diff --git a/OpenSim/Framework/IAssetProvider.cs b/OpenSim/Framework/IAssetProvider.cs index 5c02ff1..dcb79ea 100644 --- a/OpenSim/Framework/IAssetProvider.cs +++ b/OpenSim/Framework/IAssetProvider.cs | |||
@@ -38,4 +38,4 @@ namespace OpenSim.Framework | |||
38 | void CommitAssets(); // force a sync to the database | 38 | void CommitAssets(); // force a sync to the database |
39 | void Initialise(string connect); | 39 | void Initialise(string connect); |
40 | } | 40 | } |
41 | } \ No newline at end of file | 41 | } |
diff --git a/OpenSim/Framework/IPlugin.cs b/OpenSim/Framework/IPlugin.cs index 8a0b2b1..342918c 100644 --- a/OpenSim/Framework/IPlugin.cs +++ b/OpenSim/Framework/IPlugin.cs | |||
@@ -25,12 +25,24 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | |||
28 | namespace OpenSim.Framework | 30 | namespace OpenSim.Framework |
29 | { | 31 | { |
30 | /// <summary> | 32 | /// <summary> |
33 | /// Exception thrown if Initialise has been called, but failed. | ||
34 | /// </summary> | ||
35 | public class PluginNotInitialisedException : Exception | ||
36 | { | ||
37 | public PluginNotInitialisedException () : base() {} | ||
38 | public PluginNotInitialisedException (string msg) : base(msg) {} | ||
39 | public PluginNotInitialisedException (string msg, Exception e) : base(msg, e) {} | ||
40 | } | ||
41 | |||
42 | /// <summary> | ||
31 | /// This interface, describes a generic plugin | 43 | /// This interface, describes a generic plugin |
32 | /// </summary> | 44 | /// </summary> |
33 | public interface IPlugin | 45 | public interface IPlugin : System.IDisposable |
34 | { | 46 | { |
35 | /// <summary> | 47 | /// <summary> |
36 | /// Returns the plugin version | 48 | /// Returns the plugin version |
@@ -45,8 +57,8 @@ namespace OpenSim.Framework | |||
45 | string Name { get; } | 57 | string Name { get; } |
46 | 58 | ||
47 | /// <summary> | 59 | /// <summary> |
48 | /// Initialises the plugin (artificial constructor) | 60 | /// Default-initialises the plugin |
49 | /// </summary> | 61 | /// </summary> |
50 | void Initialise(); | 62 | void Initialise(); |
51 | } | 63 | } |
52 | } \ No newline at end of file | 64 | } |
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs new file mode 100644 index 0000000..26df3d1 --- /dev/null +++ b/OpenSim/Framework/PluginLoader.cs | |||
@@ -0,0 +1,115 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | |||
35 | namespace OpenSim.Framework | ||
36 | { | ||
37 | public class PluginLoader <T> : IDisposable where T : IPlugin | ||
38 | { | ||
39 | private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | private List<T> loaded = new List<T>(); | ||
41 | |||
42 | public PluginLoader (string dir) | ||
43 | { | ||
44 | AddPluginDir (dir); | ||
45 | } | ||
46 | |||
47 | public void AddPluginDir (string dir) | ||
48 | { | ||
49 | suppress_console_output_ (true); | ||
50 | AddinManager.Initialize (dir); | ||
51 | suppress_console_output_ (false); | ||
52 | } | ||
53 | |||
54 | public delegate void Initialiser (IPlugin p); | ||
55 | private void default_initialiser_ (IPlugin p) { p.Initialise(); } | ||
56 | |||
57 | public void Load (string extpoint) | ||
58 | { | ||
59 | Load (extpoint, default_initialiser_); | ||
60 | } | ||
61 | |||
62 | public void Load (string extpoint, Initialiser initialize) | ||
63 | { | ||
64 | AddinManager.Registry.Update (null); | ||
65 | |||
66 | ExtensionNodeList ns = AddinManager.GetExtensionNodes(extpoint); | ||
67 | foreach (TypeExtensionNode n in ns) | ||
68 | { | ||
69 | T p = (T) n.CreateInstance(); | ||
70 | initialize (p); | ||
71 | Plugins.Add (p); | ||
72 | |||
73 | log.Info("[PLUGINS]: Loading plugin " + n.Path + "/" + p.Name); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public List<T> Plugins | ||
78 | { | ||
79 | get { return loaded; } | ||
80 | } | ||
81 | |||
82 | public void Dispose () | ||
83 | { | ||
84 | foreach (T p in Plugins) | ||
85 | p.Dispose (); | ||
86 | } | ||
87 | |||
88 | public void ClearCache() | ||
89 | { | ||
90 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache | ||
91 | // Hence, as a temporary solution we'll remove it before each startup | ||
92 | if (Directory.Exists("addin-db-000")) | ||
93 | Directory.Delete("addin-db-000", true); | ||
94 | |||
95 | if (Directory.Exists("addin-db-001")) | ||
96 | Directory.Delete("addin-db-001", true); | ||
97 | } | ||
98 | |||
99 | private static TextWriter prev_console_; | ||
100 | public void suppress_console_output_ (bool save) | ||
101 | { | ||
102 | if (save) | ||
103 | { | ||
104 | prev_console_ = System.Console.Out; | ||
105 | System.Console.SetOut(new StreamWriter(Stream.Null)); | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | if (prev_console_ != null) | ||
110 | System.Console.SetOut(prev_console_); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | } | ||
115 | } | ||
diff --git a/OpenSim/Framework/Servers/OSHttpRequestPump.cs b/OpenSim/Framework/Servers/OSHttpRequestPump.cs index 06e41e4..6214ab0 100644 --- a/OpenSim/Framework/Servers/OSHttpRequestPump.cs +++ b/OpenSim/Framework/Servers/OSHttpRequestPump.cs | |||
@@ -58,4 +58,4 @@ namespace OpenSim.Framework.Servers | |||
58 | return pumps; | 58 | return pumps; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } \ No newline at end of file | 61 | } |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 7891c29..010c250 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -116,26 +116,17 @@ namespace OpenSim.Grid.GridServer | |||
116 | m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod)); | 116 | m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod)); |
117 | } | 117 | } |
118 | 118 | ||
119 | protected void LoadGridPlugins() | 119 | protected void grid_plugin_initialiser_ (IPlugin plugin) |
120 | { | 120 | { |
121 | // Temporary hack to stop mono-addins scanning warnings from coming out on the console | 121 | IGridPlugin p = plugin as IGridPlugin; |
122 | TextWriter oldOutput = Console.Out; | 122 | p.Initialise (this); |
123 | Console.SetOut(new StreamWriter(Stream.Null)); | 123 | } |
124 | |||
125 | AddinManager.Initialize("."); | ||
126 | AddinManager.Registry.Update(null); | ||
127 | |||
128 | // Returns the console.writelines back to the console's stream | ||
129 | Console.SetOut(oldOutput); | ||
130 | 124 | ||
131 | ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/GridServer"); | 125 | protected void LoadGridPlugins() |
132 | foreach (TypeExtensionNode node in nodes) | 126 | { |
133 | { | 127 | PluginLoader<IGridPlugin> loader = new PluginLoader<IGridPlugin> ("."); |
134 | m_log.Info("[GRID PLUGINS]: Loading OpenSim plugin " + node.Path); | 128 | loader.Load ("/OpenSim/GridServer", grid_plugin_initialiser_); |
135 | IGridPlugin plugin = (IGridPlugin)node.CreateInstance(); | 129 | m_plugins = loader.Plugins; |
136 | plugin.Initialise(this); | ||
137 | m_plugins.Add(plugin); | ||
138 | } | ||
139 | } | 130 | } |
140 | 131 | ||
141 | protected virtual void SetupGridManager() | 132 | protected virtual void SetupGridManager() |
diff --git a/OpenSim/Grid/GridServer/IGridPlugin.cs b/OpenSim/Grid/GridServer/IGridPlugin.cs index 47273a2..d51deb3 100644 --- a/OpenSim/Grid/GridServer/IGridPlugin.cs +++ b/OpenSim/Grid/GridServer/IGridPlugin.cs | |||
@@ -27,13 +27,14 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using Mono.Addins; | 29 | using Mono.Addins; |
30 | using OpenSim.Framework; | ||
30 | 31 | ||
31 | [assembly : AddinRoot("OpenSim", "0.5")] | 32 | [assembly : AddinRoot("OpenSim", "0.5")] |
32 | 33 | ||
33 | namespace OpenSim.Grid.GridServer | 34 | namespace OpenSim.Grid.GridServer |
34 | { | 35 | { |
35 | [TypeExtensionPoint("/OpenSim/GridServer")] | 36 | [TypeExtensionPoint("/OpenSim/GridServer")] |
36 | public interface IGridPlugin | 37 | public interface IGridPlugin : IPlugin |
37 | { | 38 | { |
38 | void Initialise(GridServerBase gridServer); | 39 | void Initialise(GridServerBase gridServer); |
39 | void Close(); | 40 | void Close(); |
diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 7ca4383..e1187ae 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs | |||
@@ -26,15 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using Mono.Addins; | 28 | using Mono.Addins; |
29 | using OpenSim.Framework; | ||
29 | 30 | ||
30 | [assembly : AddinRoot("OpenSim", "0.5")] | 31 | [assembly : AddinRoot("OpenSim", "0.5")] |
31 | 32 | ||
32 | namespace OpenSim | 33 | namespace OpenSim |
33 | { | 34 | { |
34 | [TypeExtensionPoint("/OpenSim/Startup")] | 35 | [TypeExtensionPoint("/OpenSim/Startup")] |
35 | public interface IApplicationPlugin | 36 | public interface IApplicationPlugin : IPlugin |
36 | { | 37 | { |
37 | void Initialise(OpenSimBase openSim); | 38 | void Initialise(OpenSimBase openSim); |
38 | void Close(); | ||
39 | } | 39 | } |
40 | } | 40 | } |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 49e1da3..d0d5378 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -149,24 +149,6 @@ namespace OpenSim | |||
149 | { | 149 | { |
150 | IConfig startupConfig = configSource.Configs["Startup"]; | 150 | IConfig startupConfig = configSource.Configs["Startup"]; |
151 | 151 | ||
152 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache | ||
153 | // Hence, as a temporary solution we'll remove it before each startup | ||
154 | if (Directory.Exists("addin-db-000")) | ||
155 | Directory.Delete("addin-db-000", true); | ||
156 | |||
157 | if (Directory.Exists("addin-db-001")) | ||
158 | Directory.Delete("addin-db-001", true); | ||
159 | |||
160 | // This blocks the scanning warnings from outputing to the console. | ||
161 | TextWriter oldOutput = Console.Out; | ||
162 | Console.SetOut(new StreamWriter(Stream.Null)); | ||
163 | |||
164 | AddinManager.Initialize("."); | ||
165 | AddinManager.Registry.Update(null); | ||
166 | |||
167 | // Returns the console.writelines back to the console's stream | ||
168 | Console.SetOut(oldOutput); | ||
169 | |||
170 | Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); | 152 | Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); |
171 | 153 | ||
172 | m_config = new OpenSimConfigSource(); | 154 | m_config = new OpenSimConfigSource(); |
@@ -347,6 +329,19 @@ namespace OpenSim | |||
347 | m_networkServersInfo.loadFromConfiguration(m_config.Source); | 329 | m_networkServersInfo.loadFromConfiguration(m_config.Source); |
348 | } | 330 | } |
349 | 331 | ||
332 | protected void plugin_initialiser_ (IPlugin plugin) | ||
333 | { | ||
334 | IApplicationPlugin p = plugin as IApplicationPlugin; | ||
335 | p.Initialise (this); | ||
336 | } | ||
337 | |||
338 | protected void LoadPlugins() | ||
339 | { | ||
340 | PluginLoader<IApplicationPlugin> loader = new PluginLoader<IApplicationPlugin> ("."); | ||
341 | loader.Load ("/OpenSim/Startup", plugin_initialiser_); | ||
342 | m_plugins = loader.Plugins; | ||
343 | } | ||
344 | |||
350 | /// <summary> | 345 | /// <summary> |
351 | /// Performs initialisation of the scene, such as loading configuration from disk. | 346 | /// Performs initialisation of the scene, such as loading configuration from disk. |
352 | /// </summary> | 347 | /// </summary> |
@@ -403,14 +398,7 @@ namespace OpenSim | |||
403 | // Create a ModuleLoader instance | 398 | // Create a ModuleLoader instance |
404 | m_moduleLoader = new ModuleLoader(m_config.Source); | 399 | m_moduleLoader = new ModuleLoader(m_config.Source); |
405 | 400 | ||
406 | ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); | 401 | LoadPlugins(); |
407 | foreach (TypeExtensionNode node in nodes) | ||
408 | { | ||
409 | m_log.InfoFormat("[PLUGINS]: Loading OpenSim application plugin {0}", node.Path); | ||
410 | IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); | ||
411 | plugin.Initialise(this); | ||
412 | m_plugins.Add(plugin); | ||
413 | } | ||
414 | } | 402 | } |
415 | 403 | ||
416 | protected override void Initialize() | 404 | protected override void Initialize() |
@@ -740,3 +728,4 @@ namespace OpenSim | |||
740 | } | 728 | } |
741 | } | 729 | } |
742 | 730 | ||
731 | |||
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index 2aa2398..625e3c5 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | |||
@@ -74,6 +74,18 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
74 | private List<IClientNetworkServer> m_clientServers; | 74 | private List<IClientNetworkServer> m_clientServers; |
75 | 75 | ||
76 | #region IApplicationPlugin Members | 76 | #region IApplicationPlugin Members |
77 | // TODO: required by IPlugin, but likely not at all right | ||
78 | string m_name = "LoadBalancerPlugin"; | ||
79 | string m_version = "0.0"; | ||
80 | |||
81 | public string Version { get { return m_version; } } | ||
82 | public string Name { get { return m_name; } } | ||
83 | |||
84 | public void Initialise() | ||
85 | { | ||
86 | m_log.Info("[BALANCER]: " + Name + " cannot be default-initialized!"); | ||
87 | throw new PluginNotInitialisedException (Name); | ||
88 | } | ||
77 | 89 | ||
78 | public void Initialise(OpenSimBase openSim) | 90 | public void Initialise(OpenSimBase openSim) |
79 | { | 91 | { |
@@ -109,7 +121,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
109 | m_log.Info("[BALANCER] " + "Exiting Initialize()"); | 121 | m_log.Info("[BALANCER] " + "Exiting Initialize()"); |
110 | } | 122 | } |
111 | 123 | ||
112 | public void Close() | 124 | public void Dispose() |
113 | { | 125 | { |
114 | } | 126 | } |
115 | 127 | ||
diff --git a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs index 9bb883e..a3108f6 100644 --- a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs +++ b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs | |||
@@ -68,6 +68,18 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
68 | private ProxyServer proxy; | 68 | private ProxyServer proxy; |
69 | 69 | ||
70 | #region IApplicationPlugin Members | 70 | #region IApplicationPlugin Members |
71 | // TODO: required by IPlugin, but likely not at all right | ||
72 | string m_name = "RegionProxyPlugin"; | ||
73 | string m_version = "0.0"; | ||
74 | |||
75 | public string Version { get { return m_version; } } | ||
76 | public string Name { get { return m_name; } } | ||
77 | |||
78 | public void Initialise() | ||
79 | { | ||
80 | m_log.Info("[PROXY]: " + Name + " cannot be default-initialized!"); | ||
81 | throw new PluginNotInitialisedException (Name); | ||
82 | } | ||
71 | 83 | ||
72 | public void Initialise(OpenSimBase openSim) | 84 | public void Initialise(OpenSimBase openSim) |
73 | { | 85 | { |
@@ -89,7 +101,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
89 | proxy = new ProxyServer(m_log); | 101 | proxy = new ProxyServer(m_log); |
90 | } | 102 | } |
91 | 103 | ||
92 | public void Close() | 104 | public void Dispose() |
93 | { | 105 | { |
94 | } | 106 | } |
95 | 107 | ||
diff --git a/prebuild.xml b/prebuild.xml index 2c2dc01..fdc9eee 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -95,6 +95,7 @@ | |||
95 | <Reference name="OpenSim.Framework.Console"/> | 95 | <Reference name="OpenSim.Framework.Console"/> |
96 | <Reference name="Nini.dll" /> | 96 | <Reference name="Nini.dll" /> |
97 | <Reference name="log4net.dll"/> | 97 | <Reference name="log4net.dll"/> |
98 | <Reference name="Mono.Addins.dll" /> | ||
98 | <Files> | 99 | <Files> |
99 | <Match pattern="*.cs" recurse="false"/> | 100 | <Match pattern="*.cs" recurse="false"/> |
100 | </Files> | 101 | </Files> |