diff options
author | Mike Mazur | 2008-07-18 04:51:41 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-18 04:51:41 +0000 |
commit | e0e0db366061eae148364e3d5670f275b1ab25b7 (patch) | |
tree | cbd4890958aa28a3ff98a917909ec77247a80d00 | |
parent | Make scripts LSL compliant. (diff) | |
download | opensim-SC-e0e0db366061eae148364e3d5670f275b1ab25b7.zip opensim-SC-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.gz opensim-SC-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.bz2 opensim-SC-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.xz |
Thanks, sempuki, for a patch that moves all grid plugins to new PluginLoader (issue 1763).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/GridDataBase.cs | 12 | ||||
-rw-r--r-- | OpenSim/Data/IGridData.cs | 45 | ||||
-rw-r--r-- | OpenSim/Data/ILogData.cs | 34 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridData.cs | 22 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLLogData.cs | 30 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAssetData.cs | 1 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLGridData.cs | 22 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLLogData.cs | 26 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGridData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Framework/PluginLoader.cs | 170 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 120 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridServerBase.cs | 3 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/IGridPlugin.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 3 | ||||
-rw-r--r-- | prebuild.xml | 4 |
16 files changed, 314 insertions, 208 deletions
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index 0c9d24a..6480f84 100644 --- a/OpenSim/Data/GridDataBase.cs +++ b/OpenSim/Data/GridDataBase.cs | |||
@@ -29,19 +29,21 @@ using libsecondlife; | |||
29 | 29 | ||
30 | namespace OpenSim.Data | 30 | namespace OpenSim.Data |
31 | { | 31 | { |
32 | public abstract class GridDataBase : IGridData | 32 | public abstract class GridDataBase : IGridDataPlugin |
33 | { | 33 | { |
34 | public abstract RegionProfileData GetProfileByHandle(ulong regionHandle); | 34 | public abstract RegionProfileData GetProfileByHandle(ulong regionHandle); |
35 | public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID); | 35 | public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID); |
36 | public abstract RegionProfileData GetProfileByString(string regionName); | 36 | public abstract RegionProfileData GetProfileByString(string regionName); |
37 | public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | 37 | public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); |
38 | public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); | 38 | public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); |
39 | public abstract void Initialise(string connect); | ||
40 | public abstract void Close(); | ||
41 | public abstract string getName(); | ||
42 | public abstract string getVersion(); | ||
43 | public abstract DataResponse AddProfile(RegionProfileData profile); | 39 | public abstract DataResponse AddProfile(RegionProfileData profile); |
44 | public abstract ReservationData GetReservationAtPoint(uint x, uint y); | 40 | public abstract ReservationData GetReservationAtPoint(uint x, uint y); |
45 | public abstract DataResponse UpdateProfile(RegionProfileData profile); | 41 | public abstract DataResponse UpdateProfile(RegionProfileData profile); |
42 | |||
43 | public abstract void Initialise(); | ||
44 | public abstract void Initialise(string connect); | ||
45 | public abstract void Dispose(); | ||
46 | public abstract string Name { get; } | ||
47 | public abstract string Version { get; } | ||
46 | } | 48 | } |
47 | } | 49 | } |
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs index e242312..fa24d82 100644 --- a/OpenSim/Data/IGridData.cs +++ b/OpenSim/Data/IGridData.cs | |||
@@ -26,6 +26,10 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using libsecondlife; | 28 | using libsecondlife; |
29 | using Mono.Addins; | ||
30 | using OpenSim.Framework; | ||
31 | |||
32 | [assembly : AddinRoot("OpenSim.Data", "0.5")] | ||
29 | 33 | ||
30 | namespace OpenSim.Data | 34 | namespace OpenSim.Data |
31 | { | 35 | { |
@@ -40,9 +44,15 @@ namespace OpenSim.Data | |||
40 | /// <summary> | 44 | /// <summary> |
41 | /// A standard grid interface | 45 | /// A standard grid interface |
42 | /// </summary> | 46 | /// </summary> |
43 | public interface IGridData | 47 | [TypeExtensionPoint("/OpenSim/GridDataStore")] |
48 | public interface IGridDataPlugin : IPlugin | ||
44 | { | 49 | { |
45 | /// <summary> | 50 | /// <summary> |
51 | /// Initialises the interface | ||
52 | /// </summary> | ||
53 | void Initialise(string connect); | ||
54 | |||
55 | /// <summary> | ||
46 | /// Returns a sim profile from a regionHandle | 56 | /// Returns a sim profile from a regionHandle |
47 | /// </summary> | 57 | /// </summary> |
48 | /// <param name="regionHandle">A 64bit Region Handle</param> | 58 | /// <param name="regionHandle">A 64bit Region Handle</param> |
@@ -84,28 +94,6 @@ namespace OpenSim.Data | |||
84 | bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); | 94 | bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); |
85 | 95 | ||
86 | /// <summary> | 96 | /// <summary> |
87 | /// Initialises the interface | ||
88 | /// </summary> | ||
89 | void Initialise(string connect); | ||
90 | |||
91 | /// <summary> | ||
92 | /// Closes the interface | ||
93 | /// </summary> | ||
94 | void Close(); | ||
95 | |||
96 | /// <summary> | ||
97 | /// The plugin being loaded | ||
98 | /// </summary> | ||
99 | /// <returns>A string containing the plugin name</returns> | ||
100 | string getName(); | ||
101 | |||
102 | /// <summary> | ||
103 | /// The plugins version | ||
104 | /// </summary> | ||
105 | /// <returns>A string containing the plugin version</returns> | ||
106 | string getVersion(); | ||
107 | |||
108 | /// <summary> | ||
109 | /// Adds a new profile to the database | 97 | /// Adds a new profile to the database |
110 | /// </summary> | 98 | /// </summary> |
111 | /// <param name="profile">The profile to add</param> | 99 | /// <param name="profile">The profile to add</param> |
@@ -116,4 +104,15 @@ namespace OpenSim.Data | |||
116 | 104 | ||
117 | ReservationData GetReservationAtPoint(uint x, uint y); | 105 | ReservationData GetReservationAtPoint(uint x, uint y); |
118 | } | 106 | } |
107 | |||
108 | public class GridDataStoreInitialiser : PluginInitialiserBase | ||
109 | { | ||
110 | private string connect; | ||
111 | public GridDataStoreInitialiser (string s) { connect = s; } | ||
112 | public override void Initialise (IPlugin plugin) | ||
113 | { | ||
114 | IGridDataPlugin p = plugin as IGridDataPlugin; | ||
115 | p.Initialise (connect); | ||
116 | } | ||
117 | } | ||
119 | } | 118 | } |
diff --git a/OpenSim/Data/ILogData.cs b/OpenSim/Data/ILogData.cs index 7275637..34657dc 100644 --- a/OpenSim/Data/ILogData.cs +++ b/OpenSim/Data/ILogData.cs | |||
@@ -25,6 +25,9 @@ | |||
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 Mono.Addins; | ||
29 | using OpenSim.Framework; | ||
30 | |||
28 | namespace OpenSim.Data | 31 | namespace OpenSim.Data |
29 | { | 32 | { |
30 | /// <summary> | 33 | /// <summary> |
@@ -61,7 +64,8 @@ namespace OpenSim.Data | |||
61 | /// <summary> | 64 | /// <summary> |
62 | /// An interface to a LogData storage system | 65 | /// An interface to a LogData storage system |
63 | /// </summary> | 66 | /// </summary> |
64 | public interface ILogData | 67 | [TypeExtensionPoint("/OpenSim/GridLogData")] |
68 | public interface ILogDataPlugin : IPlugin | ||
65 | { | 69 | { |
66 | void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, | 70 | void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, |
67 | string logMessage); | 71 | string logMessage); |
@@ -70,22 +74,16 @@ namespace OpenSim.Data | |||
70 | /// Initialises the interface | 74 | /// Initialises the interface |
71 | /// </summary> | 75 | /// </summary> |
72 | void Initialise(string connect); | 76 | void Initialise(string connect); |
73 | 77 | } | |
74 | /// <summary> | 78 | |
75 | /// Closes the interface | 79 | public class LogDataInitialiser : PluginInitialiserBase |
76 | /// </summary> | 80 | { |
77 | void Close(); | 81 | private string connect; |
78 | 82 | public LogDataInitialiser (string s) { connect = s; } | |
79 | /// <summary> | 83 | public override void Initialise (IPlugin plugin) |
80 | /// The plugin being loaded | 84 | { |
81 | /// </summary> | 85 | ILogDataPlugin p = plugin as ILogDataPlugin; |
82 | /// <returns>A string containing the plugin name</returns> | 86 | p.Initialise (connect); |
83 | string getName(); | 87 | } |
84 | |||
85 | /// <summary> | ||
86 | /// The plugins version | ||
87 | /// </summary> | ||
88 | /// <returns>A string containing the plugin version</returns> | ||
89 | string getVersion(); | ||
90 | } | 88 | } |
91 | } | 89 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 0abd0d0..7de77d1 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs | |||
@@ -33,12 +33,18 @@ using System.Security.Cryptography; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using log4net; | 35 | using log4net; |
36 | using Mono.Addins; | ||
37 | using OpenSim.Framework; | ||
38 | |||
39 | [assembly : Addin] | ||
40 | [assembly : AddinDependency("OpenSim.Data", "0.5")] | ||
36 | 41 | ||
37 | namespace OpenSim.Data.MSSQL | 42 | namespace OpenSim.Data.MSSQL |
38 | { | 43 | { |
39 | /// <summary> | 44 | /// <summary> |
40 | /// A grid data interface for MSSQL Server | 45 | /// A grid data interface for MSSQL Server |
41 | /// </summary> | 46 | /// </summary> |
47 | [Extension("/OpenSim/GridDataStore")] | ||
42 | public class MSSQLGridData : GridDataBase | 48 | public class MSSQLGridData : GridDataBase |
43 | { | 49 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,6 +56,12 @@ namespace OpenSim.Data.MSSQL | |||
50 | 56 | ||
51 | private string m_regionsTableName; | 57 | private string m_regionsTableName; |
52 | 58 | ||
59 | override public void Initialise() | ||
60 | { | ||
61 | m_log.Info("[MSSQLGridData]: " + Name + " cannot be default-initialized!"); | ||
62 | throw new PluginNotInitialisedException (Name); | ||
63 | } | ||
64 | |||
53 | /// <summary> | 65 | /// <summary> |
54 | /// Initialises the Grid Interface | 66 | /// Initialises the Grid Interface |
55 | /// </summary> | 67 | /// </summary> |
@@ -101,7 +113,7 @@ namespace OpenSim.Data.MSSQL | |||
101 | /// <summary> | 113 | /// <summary> |
102 | /// Shuts down the grid interface | 114 | /// Shuts down the grid interface |
103 | /// </summary> | 115 | /// </summary> |
104 | override public void Close() | 116 | override public void Dispose() |
105 | { | 117 | { |
106 | // nothing to close | 118 | // nothing to close |
107 | } | 119 | } |
@@ -110,18 +122,18 @@ namespace OpenSim.Data.MSSQL | |||
110 | /// The name of this DB provider. | 122 | /// The name of this DB provider. |
111 | /// </summary> | 123 | /// </summary> |
112 | /// <returns>A string containing the storage system name</returns> | 124 | /// <returns>A string containing the storage system name</returns> |
113 | override public string getName() | 125 | override public string Name |
114 | { | 126 | { |
115 | return "Sql OpenGridData"; | 127 | get { return "Sql OpenGridData"; } |
116 | } | 128 | } |
117 | 129 | ||
118 | /// <summary> | 130 | /// <summary> |
119 | /// Database provider version. | 131 | /// Database provider version. |
120 | /// </summary> | 132 | /// </summary> |
121 | /// <returns>A string containing the storage system version</returns> | 133 | /// <returns>A string containing the storage system version</returns> |
122 | override public string getVersion() | 134 | override public string Version |
123 | { | 135 | { |
124 | return "0.1"; | 136 | get { return "0.1"; } |
125 | } | 137 | } |
126 | 138 | ||
127 | /// <summary> | 139 | /// <summary> |
diff --git a/OpenSim/Data/MSSQL/MSSQLLogData.cs b/OpenSim/Data/MSSQL/MSSQLLogData.cs index 849d0fb..d0d81b6 100644 --- a/OpenSim/Data/MSSQL/MSSQLLogData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLogData.cs | |||
@@ -25,21 +25,39 @@ | |||
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 | using System.Reflection; | ||
28 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
29 | using System.Data; | 31 | using System.Data; |
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | using OpenSim.Framework; | ||
35 | |||
36 | // Only one attribute per assembly. See: *GridData.cs | ||
37 | // [assembly : Addin] | ||
38 | // [assembly : AddinDependency("OpenSim.Data", "0.5")] | ||
30 | 39 | ||
31 | namespace OpenSim.Data.MSSQL | 40 | namespace OpenSim.Data.MSSQL |
32 | { | 41 | { |
33 | /// <summary> | 42 | /// <summary> |
34 | /// An interface to the log database for MSSQL | 43 | /// An interface to the log database for MSSQL |
35 | /// </summary> | 44 | /// </summary> |
36 | internal class MSSQLLogData : ILogData | 45 | [Extension("/OpenSim/GridLogData")] |
46 | internal class MSSQLLogData : ILogDataPlugin | ||
37 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
38 | /// <summary> | 50 | /// <summary> |
39 | /// The database manager | 51 | /// The database manager |
40 | /// </summary> | 52 | /// </summary> |
41 | public MSSQLManager database; | 53 | public MSSQLManager database; |
42 | 54 | ||
55 | public void Initialise() | ||
56 | { | ||
57 | m_log.Info("[MSSQLLogData]: " + Name + " cannot be default-initialized!"); | ||
58 | throw new PluginNotInitialisedException (Name); | ||
59 | } | ||
60 | |||
43 | /// <summary> | 61 | /// <summary> |
44 | /// Artificial constructor called when the plugin is loaded | 62 | /// Artificial constructor called when the plugin is loaded |
45 | /// </summary> | 63 | /// </summary> |
@@ -97,15 +115,15 @@ namespace OpenSim.Data.MSSQL | |||
97 | /// Returns the name of this DB provider | 115 | /// Returns the name of this DB provider |
98 | /// </summary> | 116 | /// </summary> |
99 | /// <returns>A string containing the DB provider name</returns> | 117 | /// <returns>A string containing the DB provider name</returns> |
100 | public string getName() | 118 | public string Name |
101 | { | 119 | { |
102 | return "MSSQL Logdata Interface"; | 120 | get { return "MSSQL Logdata Interface"; } |
103 | } | 121 | } |
104 | 122 | ||
105 | /// <summary> | 123 | /// <summary> |
106 | /// Closes the database provider | 124 | /// Closes the database provider |
107 | /// </summary> | 125 | /// </summary> |
108 | public void Close() | 126 | public void Dispose() |
109 | { | 127 | { |
110 | // Do nothing. | 128 | // Do nothing. |
111 | } | 129 | } |
@@ -114,9 +132,9 @@ namespace OpenSim.Data.MSSQL | |||
114 | /// Returns the version of this DB provider | 132 | /// Returns the version of this DB provider |
115 | /// </summary> | 133 | /// </summary> |
116 | /// <returns>A string containing the provider version</returns> | 134 | /// <returns>A string containing the provider version</returns> |
117 | public string getVersion() | 135 | public string Version |
118 | { | 136 | { |
119 | return "0.1"; | 137 | get { return "0.1"; } |
120 | } | 138 | } |
121 | } | 139 | } |
122 | } | 140 | } |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 6cb0b4c..9284ba9 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -34,6 +34,7 @@ using log4net; | |||
34 | using MySql.Data.MySqlClient; | 34 | using MySql.Data.MySqlClient; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | 36 | ||
37 | |||
37 | namespace OpenSim.Data.MySQL | 38 | namespace OpenSim.Data.MySQL |
38 | { | 39 | { |
39 | /// <summary> | 40 | /// <summary> |
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index bb71c99..8142c74 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -33,12 +33,18 @@ using System.Security.Cryptography; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using log4net; | 35 | using log4net; |
36 | using Mono.Addins; | ||
37 | using OpenSim.Framework; | ||
38 | |||
39 | [assembly : Addin] | ||
40 | [assembly : AddinDependency("OpenSim.Data", "0.5")] | ||
36 | 41 | ||
37 | namespace OpenSim.Data.MySQL | 42 | namespace OpenSim.Data.MySQL |
38 | { | 43 | { |
39 | /// <summary> | 44 | /// <summary> |
40 | /// A MySQL Interface for the Grid Server | 45 | /// A MySQL Interface for the Grid Server |
41 | /// </summary> | 46 | /// </summary> |
47 | [Extension("/OpenSim/GridDataStore")] | ||
42 | public class MySQLGridData : GridDataBase | 48 | public class MySQLGridData : GridDataBase |
43 | { | 49 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -48,6 +54,12 @@ namespace OpenSim.Data.MySQL | |||
48 | /// </summary> | 54 | /// </summary> |
49 | private MySQLManager database; | 55 | private MySQLManager database; |
50 | 56 | ||
57 | override public void Initialise() | ||
58 | { | ||
59 | m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); | ||
60 | throw new PluginNotInitialisedException (Name); | ||
61 | } | ||
62 | |||
51 | /// <summary> | 63 | /// <summary> |
52 | /// <para>Initialises Grid interface</para> | 64 | /// <para>Initialises Grid interface</para> |
53 | /// <para> | 65 | /// <para> |
@@ -144,7 +156,7 @@ namespace OpenSim.Data.MySQL | |||
144 | /// <summary> | 156 | /// <summary> |
145 | /// Shuts down the grid interface | 157 | /// Shuts down the grid interface |
146 | /// </summary> | 158 | /// </summary> |
147 | override public void Close() | 159 | override public void Dispose() |
148 | { | 160 | { |
149 | database.Close(); | 161 | database.Close(); |
150 | } | 162 | } |
@@ -153,18 +165,18 @@ namespace OpenSim.Data.MySQL | |||
153 | /// Returns the plugin name | 165 | /// Returns the plugin name |
154 | /// </summary> | 166 | /// </summary> |
155 | /// <returns>Plugin name</returns> | 167 | /// <returns>Plugin name</returns> |
156 | override public string getName() | 168 | override public string Name |
157 | { | 169 | { |
158 | return "MySql OpenGridData"; | 170 | get { return "MySql OpenGridData"; } |
159 | } | 171 | } |
160 | 172 | ||
161 | /// <summary> | 173 | /// <summary> |
162 | /// Returns the plugin version | 174 | /// Returns the plugin version |
163 | /// </summary> | 175 | /// </summary> |
164 | /// <returns>Plugin version</returns> | 176 | /// <returns>Plugin version</returns> |
165 | override public string getVersion() | 177 | override public string Version |
166 | { | 178 | { |
167 | return "0.1"; | 179 | get { return "0.1"; } |
168 | } | 180 | } |
169 | 181 | ||
170 | /// <summary> | 182 | /// <summary> |
diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index fee7f2f..f11aec5 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs | |||
@@ -28,20 +28,34 @@ using System; | |||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | // Only one attribute per assembly. See: *GridData.cs | ||
35 | // [assembly : Addin] | ||
36 | // [assembly : AddinDependency("OpenSim.Data", "0.5")] | ||
31 | 37 | ||
32 | namespace OpenSim.Data.MySQL | 38 | namespace OpenSim.Data.MySQL |
33 | { | 39 | { |
34 | /// <summary> | 40 | /// <summary> |
35 | /// An interface to the log database for MySQL | 41 | /// An interface to the log database for MySQL |
36 | /// </summary> | 42 | /// </summary> |
37 | internal class MySQLLogData : ILogData | 43 | [Extension("/OpenSim/GridLogData")] |
44 | internal class MySQLLogData : ILogDataPlugin | ||
38 | { | 45 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | |||
40 | /// <summary> | 48 | /// <summary> |
41 | /// The database manager | 49 | /// The database manager |
42 | /// </summary> | 50 | /// </summary> |
43 | public MySQLManager database; | 51 | public MySQLManager database; |
44 | 52 | ||
53 | public void Initialise() | ||
54 | { | ||
55 | m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); | ||
56 | throw new PluginNotInitialisedException (Name); | ||
57 | } | ||
58 | |||
45 | /// <summary> | 59 | /// <summary> |
46 | /// Artificial constructor called when the plugin is loaded | 60 | /// Artificial constructor called when the plugin is loaded |
47 | /// Uses the obsolete mysql_connection.ini if connect string is empty. | 61 | /// Uses the obsolete mysql_connection.ini if connect string is empty. |
@@ -128,16 +142,16 @@ namespace OpenSim.Data.MySQL | |||
128 | /// Returns the name of this DB provider | 142 | /// Returns the name of this DB provider |
129 | /// </summary> | 143 | /// </summary> |
130 | /// <returns>A string containing the DB provider name</returns> | 144 | /// <returns>A string containing the DB provider name</returns> |
131 | public string getName() | 145 | public string Name |
132 | { | 146 | { |
133 | return "MySQL Logdata Interface"; | 147 | get { return "MySQL Logdata Interface";} |
134 | } | 148 | } |
135 | 149 | ||
136 | /// <summary> | 150 | /// <summary> |
137 | /// Closes the database provider | 151 | /// Closes the database provider |
138 | /// </summary> | 152 | /// </summary> |
139 | /// <remarks>do nothing</remarks> | 153 | /// <remarks>do nothing</remarks> |
140 | public void Close() | 154 | public void Dispose() |
141 | { | 155 | { |
142 | // Do nothing. | 156 | // Do nothing. |
143 | } | 157 | } |
@@ -146,9 +160,9 @@ namespace OpenSim.Data.MySQL | |||
146 | /// Returns the version of this DB provider | 160 | /// Returns the version of this DB provider |
147 | /// </summary> | 161 | /// </summary> |
148 | /// <returns>A string containing the provider version</returns> | 162 | /// <returns>A string containing the provider version</returns> |
149 | public string getVersion() | 163 | public string Version |
150 | { | 164 | { |
151 | return "0.1"; | 165 | get { return "0.1"; } |
152 | } | 166 | } |
153 | } | 167 | } |
154 | } | 168 | } |
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index cf4bce3..89d0672 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -227,7 +227,7 @@ namespace OpenSim.Data.MySQL | |||
227 | 227 | ||
228 | return | 228 | return |
229 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, | 229 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, |
230 | dllVersion.Revision); | 230 | dllVersion.Revision); |
231 | } | 231 | } |
232 | 232 | ||
233 | /// <summary> | 233 | /// <summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs index 6fd7235..1e07458 100644 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridData.cs | |||
@@ -28,23 +28,38 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Reflection; | ||
31 | using System.Security.Cryptography; | 32 | using System.Security.Cryptography; |
32 | using System.Text; | 33 | using System.Text; |
33 | using libsecondlife; | 34 | using libsecondlife; |
35 | using log4net; | ||
36 | using Mono.Addins; | ||
34 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
35 | 38 | ||
39 | [assembly : Addin] | ||
40 | [assembly : AddinDependency("OpenSim.Data", "0.5")] | ||
41 | |||
36 | namespace OpenSim.Data.SQLite | 42 | namespace OpenSim.Data.SQLite |
37 | { | 43 | { |
38 | /// <summary> | 44 | /// <summary> |
39 | /// A Grid Interface to the SQLite database | 45 | /// A Grid Interface to the SQLite database |
40 | /// </summary> | 46 | /// </summary> |
47 | [Extension("/OpenSim/GridDataStore")] | ||
41 | public class SQLiteGridData : GridDataBase | 48 | public class SQLiteGridData : GridDataBase |
42 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
43 | /// <summary> | 52 | /// <summary> |
44 | /// SQLite database manager | 53 | /// SQLite database manager |
45 | /// </summary> | 54 | /// </summary> |
46 | private SQLiteManager database; | 55 | private SQLiteManager database; |
47 | 56 | ||
57 | override public void Initialise() | ||
58 | { | ||
59 | m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!"); | ||
60 | throw new PluginNotInitialisedException (Name); | ||
61 | } | ||
62 | |||
48 | /// <summary> | 63 | /// <summary> |
49 | /// <list type="bullet"> | 64 | /// <list type="bullet"> |
50 | /// <item>Initialises Inventory interface</item> | 65 | /// <item>Initialises Inventory interface</item> |
@@ -61,7 +76,7 @@ namespace OpenSim.Data.SQLite | |||
61 | /// <summary> | 76 | /// <summary> |
62 | /// Shuts down the grid interface | 77 | /// Shuts down the grid interface |
63 | /// </summary> | 78 | /// </summary> |
64 | override public void Close() | 79 | override public void Dispose() |
65 | { | 80 | { |
66 | database.Close(); | 81 | database.Close(); |
67 | } | 82 | } |
@@ -70,18 +85,18 @@ namespace OpenSim.Data.SQLite | |||
70 | /// Returns the name of this grid interface | 85 | /// Returns the name of this grid interface |
71 | /// </summary> | 86 | /// </summary> |
72 | /// <returns>A string containing the grid interface</returns> | 87 | /// <returns>A string containing the grid interface</returns> |
73 | override public string getName() | 88 | override public string Name |
74 | { | 89 | { |
75 | return "SQLite OpenGridData"; | 90 | get { return "SQLite OpenGridData"; } |
76 | } | 91 | } |
77 | 92 | ||
78 | /// <summary> | 93 | /// <summary> |
79 | /// Returns the version of this grid interface | 94 | /// Returns the version of this grid interface |
80 | /// </summary> | 95 | /// </summary> |
81 | /// <returns>A string containing the version</returns> | 96 | /// <returns>A string containing the version</returns> |
82 | override public string getVersion() | 97 | override public string Version |
83 | { | 98 | { |
84 | return "0.1"; | 99 | get { return "0.1"; } |
85 | } | 100 | } |
86 | 101 | ||
87 | /// <summary> | 102 | /// <summary> |
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs index 9104958..2d61b2c 100644 --- a/OpenSim/Framework/PluginLoader.cs +++ b/OpenSim/Framework/PluginLoader.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using Mono.Addins; | 33 | using Mono.Addins; |
34 | 34 | ||
35 | |||
35 | namespace OpenSim.Framework | 36 | namespace OpenSim.Framework |
36 | { | 37 | { |
37 | /// <summary> | 38 | /// <summary> |
@@ -50,8 +51,17 @@ namespace OpenSim.Framework | |||
50 | /// </summary> | 51 | /// </summary> |
51 | public interface IPluginConstraint | 52 | public interface IPluginConstraint |
52 | { | 53 | { |
53 | bool Fail (string extpoint); | ||
54 | string Message { get; } | 54 | string Message { get; } |
55 | bool Apply (string extpoint); | ||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// Classes wishing to select specific plugins from a range of possible options | ||
60 | /// must implement this class and pass it to PluginLoader Load() | ||
61 | /// </summary> | ||
62 | public interface IPluginFilter | ||
63 | { | ||
64 | bool Apply (ExtensionNode plugin); | ||
55 | } | 65 | } |
56 | 66 | ||
57 | /// <summary> | 67 | /// <summary> |
@@ -64,18 +74,22 @@ namespace OpenSim.Framework | |||
64 | private List<T> loaded = new List<T>(); | 74 | private List<T> loaded = new List<T>(); |
65 | private List<string> extpoints = new List<string>(); | 75 | private List<string> extpoints = new List<string>(); |
66 | private PluginInitialiserBase initialiser; | 76 | private PluginInitialiserBase initialiser; |
77 | |||
67 | private Dictionary<string,IPluginConstraint> constraints | 78 | private Dictionary<string,IPluginConstraint> constraints |
68 | = new Dictionary<string,IPluginConstraint>(); | 79 | = new Dictionary<string,IPluginConstraint>(); |
69 | 80 | ||
81 | private Dictionary<string,IPluginFilter> filters | ||
82 | = new Dictionary<string,IPluginFilter>(); | ||
83 | |||
70 | private static readonly ILog log | 84 | private static readonly ILog log |
71 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 85 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
72 | 86 | ||
73 | public PluginInitialiserBase Initialiser | 87 | public PluginInitialiserBase Initialiser |
74 | { | 88 | { |
75 | set { initialiser = value; } | 89 | set { initialiser = value; } |
76 | get { return initialiser; } | 90 | get { return initialiser; } |
77 | } | 91 | } |
78 | 92 | ||
79 | public List<T> Plugins | 93 | public List<T> Plugins |
80 | { | 94 | { |
81 | get { return loaded; } | 95 | get { return loaded; } |
@@ -84,25 +98,19 @@ namespace OpenSim.Framework | |||
84 | public PluginLoader () | 98 | public PluginLoader () |
85 | { | 99 | { |
86 | Initialiser = new PluginInitialiserBase(); | 100 | Initialiser = new PluginInitialiserBase(); |
101 | initialise_plugin_dir_ ("."); | ||
87 | } | 102 | } |
88 | 103 | ||
89 | public PluginLoader (PluginInitialiserBase init) | 104 | public PluginLoader (PluginInitialiserBase init) |
90 | { | 105 | { |
91 | Initialiser = init; | 106 | Initialiser = init; |
107 | initialise_plugin_dir_ ("."); | ||
92 | } | 108 | } |
93 | 109 | ||
94 | public PluginLoader (PluginInitialiserBase init, string dir) | 110 | public PluginLoader (PluginInitialiserBase init, string dir) |
95 | { | 111 | { |
96 | Initialiser = init; | 112 | Initialiser = init; |
97 | AddPluginDir (dir); | 113 | initialise_plugin_dir_ (dir); |
98 | } | ||
99 | |||
100 | public void AddPluginDir (string dir) | ||
101 | { | ||
102 | suppress_console_output_ (true); | ||
103 | AddinManager.Initialize (dir); | ||
104 | AddinManager.Registry.Update (null); | ||
105 | suppress_console_output_ (false); | ||
106 | } | 114 | } |
107 | 115 | ||
108 | public void AddExtensionPoint (string extpoint) | 116 | public void AddExtensionPoint (string extpoint) |
@@ -114,50 +122,88 @@ namespace OpenSim.Framework | |||
114 | { | 122 | { |
115 | constraints.Add (extpoint, cons); | 123 | constraints.Add (extpoint, cons); |
116 | } | 124 | } |
117 | 125 | ||
118 | public void Load (string extpoint, string dir) | 126 | public void AddFilter (string extpoint, IPluginFilter filter) |
127 | { | ||
128 | filters.Add (extpoint, filter); | ||
129 | } | ||
130 | |||
131 | public void Load (string extpoint) | ||
119 | { | 132 | { |
120 | AddPluginDir (dir); | ||
121 | AddExtensionPoint (extpoint); | 133 | AddExtensionPoint (extpoint); |
122 | Load(); | 134 | Load(); |
123 | } | 135 | } |
124 | 136 | ||
125 | public void Load () | 137 | public void Load () |
126 | { | 138 | { |
127 | suppress_console_output_ (true); | ||
128 | AddinManager.Registry.Update (null); | ||
129 | suppress_console_output_ (false); | ||
130 | |||
131 | foreach (string ext in extpoints) | 139 | foreach (string ext in extpoints) |
132 | { | 140 | { |
141 | log.Info("[PLUGINS]: Loading extension point " + ext); | ||
142 | |||
133 | if (constraints.ContainsKey (ext)) | 143 | if (constraints.ContainsKey (ext)) |
134 | { | 144 | { |
135 | IPluginConstraint cons = constraints [ext]; | 145 | IPluginConstraint cons = constraints [ext]; |
136 | if (cons.Fail (ext)) | 146 | if (cons.Apply (ext)) |
137 | throw new PluginConstraintViolatedException (cons.Message); | 147 | log.Error ("[PLUGINS]: " + ext + " failed constraint: " + cons.Message); |
138 | } | 148 | } |
139 | 149 | ||
140 | ExtensionNodeList ns = AddinManager.GetExtensionNodes (ext); | 150 | IPluginFilter filter = null; |
141 | foreach (TypeExtensionNode n in ns) | 151 | |
142 | { | 152 | if (filters.ContainsKey (ext)) |
143 | T p = (T) n.CreateInstance(); | 153 | filter = filters [ext]; |
144 | Initialiser.Initialise (p); | ||
145 | Plugins.Add (p); | ||
146 | 154 | ||
147 | log.Info("[PLUGINS]: Loading plugin " + n.Path); | 155 | foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (ext)) |
156 | { | ||
157 | log.Info("[PLUGINS]: Trying plugin " + node.Path); | ||
158 | |||
159 | if ((filter != null) && (filter.Apply (node) == false)) | ||
160 | continue; | ||
161 | |||
162 | T plugin = (T) node.CreateInstance(); | ||
163 | Initialiser.Initialise (plugin); | ||
164 | Plugins.Add (plugin); | ||
148 | } | 165 | } |
149 | } | 166 | } |
150 | } | 167 | } |
151 | 168 | ||
152 | public void Dispose () | 169 | public void Dispose () |
153 | { | 170 | { |
154 | foreach (T p in Plugins) | 171 | foreach (T plugin in Plugins) |
155 | p.Dispose (); | 172 | plugin.Dispose (); |
156 | } | 173 | } |
157 | 174 | ||
158 | public void ClearCache() | 175 | private void initialise_plugin_dir_ (string dir) |
159 | { | 176 | { |
160 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache | 177 | if (AddinManager.IsInitialized == true) |
178 | return; | ||
179 | |||
180 | log.Info("[PLUGINS]: Initialzing"); | ||
181 | |||
182 | AddinManager.AddinLoadError += on_addinloaderror_; | ||
183 | AddinManager.AddinLoaded += on_addinloaded_; | ||
184 | |||
185 | clear_registry_(); | ||
186 | |||
187 | suppress_console_output_ (true); | ||
188 | AddinManager.Initialize (dir); | ||
189 | AddinManager.Registry.Update (null); | ||
190 | suppress_console_output_ (false); | ||
191 | } | ||
192 | |||
193 | private void on_addinloaded_(object sender, AddinEventArgs args) | ||
194 | { | ||
195 | log.Info ("[PLUGINS]: Plugin Loaded: " + args.AddinId); | ||
196 | } | ||
197 | |||
198 | private void on_addinloaderror_(object sender, AddinErrorEventArgs args) | ||
199 | { | ||
200 | log.Error ("[PLUGINS]: Plugin Error: " + args.Message); | ||
201 | } | ||
202 | |||
203 | private void clear_registry_ () | ||
204 | { | ||
205 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) | ||
206 | // occasionally seems to corrupt its addin cache | ||
161 | // Hence, as a temporary solution we'll remove it before each startup | 207 | // Hence, as a temporary solution we'll remove it before each startup |
162 | if (Directory.Exists("addin-db-000")) | 208 | if (Directory.Exists("addin-db-000")) |
163 | Directory.Delete("addin-db-000", true); | 209 | Directory.Delete("addin-db-000", true); |
@@ -182,6 +228,9 @@ namespace OpenSim.Framework | |||
182 | } | 228 | } |
183 | } | 229 | } |
184 | 230 | ||
231 | /// <summary> | ||
232 | /// Constraint that bounds the number of plugins to be loaded. | ||
233 | /// </summary> | ||
185 | public class PluginCountConstraint : IPluginConstraint | 234 | public class PluginCountConstraint : IPluginConstraint |
186 | { | 235 | { |
187 | private int min; | 236 | private int min; |
@@ -208,45 +257,32 @@ namespace OpenSim.Framework | |||
208 | } | 257 | } |
209 | } | 258 | } |
210 | 259 | ||
211 | public bool Fail (string extpoint) | 260 | public bool Apply (string extpoint) |
212 | { | 261 | { |
213 | ExtensionNodeList ns = AddinManager.GetExtensionNodes (extpoint); | 262 | int count = AddinManager.GetExtensionNodes (extpoint).Count; |
214 | if ((ns.Count < min) || (ns.Count > max)) | ||
215 | return true; | ||
216 | else | ||
217 | return false; | ||
218 | } | ||
219 | } | ||
220 | 263 | ||
221 | public class PluginFilenameConstraint : IPluginConstraint | 264 | if ((count < min) || (count > max)) |
222 | { | 265 | throw new PluginConstraintViolatedException (Message); |
223 | private string filename; | ||
224 | 266 | ||
225 | public PluginFilenameConstraint (string name) | 267 | return true; |
226 | { | ||
227 | filename = name; | ||
228 | |||
229 | } | ||
230 | |||
231 | public string Message | ||
232 | { | ||
233 | get | ||
234 | { | ||
235 | return "The plugin must have the following name: " + filename; | ||
236 | } | ||
237 | } | 268 | } |
269 | } | ||
270 | |||
271 | /// <summary> | ||
272 | /// Filters out which plugin to load based on its "Id", which is name given by the namespace or by Mono.Addins. | ||
273 | /// </summary> | ||
274 | public class PluginIdFilter : IPluginFilter | ||
275 | { | ||
276 | private string id; | ||
238 | 277 | ||
239 | public bool Fail (string extpoint) | 278 | public PluginIdFilter (string id) |
240 | { | 279 | { |
241 | ExtensionNodeList ns = AddinManager.GetExtensionNodes (extpoint); | 280 | this.id = id; |
242 | if (ns.Count != 1) | 281 | } |
243 | return true; | ||
244 | 282 | ||
245 | string[] path = ns[0].Path.Split('/'); | 283 | public bool Apply (ExtensionNode plugin) |
246 | if (path [path.Length-1] == filename) | 284 | { |
247 | return false; | 285 | return (plugin.Id == id); |
248 | |||
249 | return true; | ||
250 | } | 286 | } |
251 | } | 287 | } |
252 | } | 288 | } |
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index c539e66..ebc6ac3 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Text; | ||
29 | using System.Collections; | 30 | using System.Collections; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.IO; | 32 | using System.IO; |
@@ -46,8 +47,8 @@ namespace OpenSim.Grid.GridServer | |||
46 | { | 47 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 49 | ||
49 | private Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>(); | 50 | private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>(); |
50 | private Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>(); | 51 | private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>(); |
51 | 52 | ||
52 | // This is here so that the grid server can hand out MessageServer settings to regions on registration | 53 | // This is here so that the grid server can hand out MessageServer settings to regions on registration |
53 | private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); | 54 | private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); |
@@ -57,42 +58,39 @@ namespace OpenSim.Grid.GridServer | |||
57 | /// <summary> | 58 | /// <summary> |
58 | /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. | 59 | /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. |
59 | /// </summary> | 60 | /// </summary> |
60 | /// <param name="FileName">The filename to the grid server plugin DLL</param> | 61 | /// <param name="provider">The name of the grid server plugin DLL</param> |
61 | public void AddPlugin(string FileName, string Connect) | 62 | public void AddPlugin(string provider, string connect) |
62 | { | 63 | { |
63 | m_log.Info("[DATA]: Attempting to load " + FileName); | 64 | // FIXME: convert "provider" DLL file name to Mono.Addins "id", |
64 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 65 | // which unless it is changed in the source code, is the .NET namespace. |
65 | 66 | // In the future, the "provider" should be changed to "id" in the | |
66 | m_log.Info("[DATA]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | 67 | // config files, and is independent of filenames or namespaces. |
67 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 68 | string[] s = provider.Split ('.'); |
68 | { | 69 | int len = s.Length; |
69 | if (!pluginType.IsAbstract) | 70 | if ((len >= 2) && (s [len-1] == "dll")) |
70 | { | 71 | s [len-1] = s [len-2]; |
71 | // Regions go here | 72 | |
72 | Type typeInterface = pluginType.GetInterface("IGridData", true); | 73 | provider = String.Join (".", s); |
73 | 74 | ||
74 | if (typeInterface != null) | 75 | PluginLoader<IGridDataPlugin> gridloader = |
75 | { | 76 | new PluginLoader<IGridDataPlugin> (new GridDataStoreInitialiser (connect)); |
76 | IGridData plug = | 77 | |
77 | (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 78 | PluginLoader<ILogDataPlugin> logloader = |
78 | plug.Initialise(Connect); | 79 | new PluginLoader<ILogDataPlugin> (new LogDataInitialiser (connect)); |
79 | _plugins.Add(plug.getName(), plug); | 80 | |
80 | m_log.Info("[DATA]: Added IGridData Interface"); | 81 | gridloader.AddExtensionPoint ("/OpenSim/GridDataStore"); |
81 | } | 82 | logloader.AddExtensionPoint ("/OpenSim/GridLogData"); |
82 | 83 | ||
83 | // Logs go here | 84 | // loader will try to load all providers (MySQL, MSSQL, etc) |
84 | typeInterface = pluginType.GetInterface("ILogData", true); | 85 | // unless it is constrainted to the correct "id" |
85 | 86 | gridloader.AddFilter ("/OpenSim/GridDataStore", new PluginIdFilter (provider + "GridData")); | |
86 | if (typeInterface != null) | 87 | logloader.AddFilter ("/OpenSim/GridLogData", new PluginIdFilter (provider + "LogData")); |
87 | { | 88 | |
88 | ILogData plug = | 89 | gridloader.Load(); |
89 | (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 90 | logloader.Load(); |
90 | plug.Initialise(Connect); | 91 | |
91 | _logplugins.Add(plug.getName(), plug); | 92 | _plugins = gridloader.Plugins; |
92 | m_log.Info("[DATA]: Added ILogData Interface"); | 93 | _logplugins = logloader.Plugins; |
93 | } | ||
94 | } | ||
95 | } | ||
96 | } | 94 | } |
97 | 95 | ||
98 | /// <summary> | 96 | /// <summary> |
@@ -105,15 +103,15 @@ namespace OpenSim.Grid.GridServer | |||
105 | /// <param name="message">The message to log</param> | 103 | /// <param name="message">The message to log</param> |
106 | private void logToDB(string target, string method, string args, int priority, string message) | 104 | private void logToDB(string target, string method, string args, int priority, string message) |
107 | { | 105 | { |
108 | foreach (KeyValuePair<string, ILogData> kvp in _logplugins) | 106 | foreach (ILogDataPlugin plugin in _logplugins) |
109 | { | 107 | { |
110 | try | 108 | try |
111 | { | 109 | { |
112 | kvp.Value.saveLog("Gridserver", target, method, args, priority, message); | 110 | plugin.saveLog("Gridserver", target, method, args, priority, message); |
113 | } | 111 | } |
114 | catch (Exception) | 112 | catch (Exception) |
115 | { | 113 | { |
116 | m_log.Warn("[storage]: Unable to write log via " + kvp.Key); | 114 | m_log.Warn("[storage]: Unable to write log via "); |
117 | } | 115 | } |
118 | } | 116 | } |
119 | } | 117 | } |
@@ -125,11 +123,11 @@ namespace OpenSim.Grid.GridServer | |||
125 | /// <returns>A SimProfileData for the region</returns> | 123 | /// <returns>A SimProfileData for the region</returns> |
126 | public RegionProfileData GetRegion(LLUUID uuid) | 124 | public RegionProfileData GetRegion(LLUUID uuid) |
127 | { | 125 | { |
128 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 126 | foreach (IGridDataPlugin plugin in _plugins) |
129 | { | 127 | { |
130 | try | 128 | try |
131 | { | 129 | { |
132 | return kvp.Value.GetProfileByLLUUID(uuid); | 130 | return plugin.GetProfileByLLUUID(uuid); |
133 | } | 131 | } |
134 | catch (Exception e) | 132 | catch (Exception e) |
135 | { | 133 | { |
@@ -146,15 +144,15 @@ namespace OpenSim.Grid.GridServer | |||
146 | /// <returns>A SimProfileData for the region</returns> | 144 | /// <returns>A SimProfileData for the region</returns> |
147 | public RegionProfileData GetRegion(ulong handle) | 145 | public RegionProfileData GetRegion(ulong handle) |
148 | { | 146 | { |
149 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 147 | foreach (IGridDataPlugin plugin in _plugins) |
150 | { | 148 | { |
151 | try | 149 | try |
152 | { | 150 | { |
153 | return kvp.Value.GetProfileByHandle(handle); | 151 | return plugin.GetProfileByHandle(handle); |
154 | } | 152 | } |
155 | catch | 153 | catch |
156 | { | 154 | { |
157 | m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key); | 155 | m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name); |
158 | } | 156 | } |
159 | } | 157 | } |
160 | return null; | 158 | return null; |
@@ -167,15 +165,15 @@ namespace OpenSim.Grid.GridServer | |||
167 | /// <returns>A SimProfileData for the region</returns> | 165 | /// <returns>A SimProfileData for the region</returns> |
168 | public RegionProfileData GetRegion(string regionName) | 166 | public RegionProfileData GetRegion(string regionName) |
169 | { | 167 | { |
170 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 168 | foreach (IGridDataPlugin plugin in _plugins) |
171 | { | 169 | { |
172 | try | 170 | try |
173 | { | 171 | { |
174 | return kvp.Value.GetProfileByString(regionName); | 172 | return plugin.GetProfileByString(regionName); |
175 | } | 173 | } |
176 | catch | 174 | catch |
177 | { | 175 | { |
178 | m_log.Warn("[storage]: Unable to find region " + regionName + " via " + kvp.Key); | 176 | m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name); |
179 | } | 177 | } |
180 | } | 178 | } |
181 | return null; | 179 | return null; |
@@ -185,11 +183,11 @@ namespace OpenSim.Grid.GridServer | |||
185 | { | 183 | { |
186 | Dictionary<ulong, RegionProfileData> regions = new Dictionary<ulong, RegionProfileData>(); | 184 | Dictionary<ulong, RegionProfileData> regions = new Dictionary<ulong, RegionProfileData>(); |
187 | 185 | ||
188 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 186 | foreach (IGridDataPlugin plugin in _plugins) |
189 | { | 187 | { |
190 | try | 188 | try |
191 | { | 189 | { |
192 | RegionProfileData[] neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax); | 190 | RegionProfileData[] neighbours = plugin.GetProfilesInRange(xmin, ymin, xmax, ymax); |
193 | foreach (RegionProfileData neighbour in neighbours) | 191 | foreach (RegionProfileData neighbour in neighbours) |
194 | { | 192 | { |
195 | regions[neighbour.regionHandle] = neighbour; | 193 | regions[neighbour.regionHandle] = neighbour; |
@@ -197,7 +195,7 @@ namespace OpenSim.Grid.GridServer | |||
197 | } | 195 | } |
198 | catch | 196 | catch |
199 | { | 197 | { |
200 | m_log.Warn("[storage]: Unable to query regionblock via " + kvp.Key); | 198 | m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); |
201 | } | 199 | } |
202 | } | 200 | } |
203 | 201 | ||
@@ -404,7 +402,7 @@ namespace OpenSim.Grid.GridServer | |||
404 | return e.XmlRpcErrorResponse; | 402 | return e.XmlRpcErrorResponse; |
405 | } | 403 | } |
406 | 404 | ||
407 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 405 | foreach (IGridDataPlugin plugin in _plugins) |
408 | { | 406 | { |
409 | try | 407 | try |
410 | { | 408 | { |
@@ -412,11 +410,11 @@ namespace OpenSim.Grid.GridServer | |||
412 | 410 | ||
413 | if (existingSim == null) | 411 | if (existingSim == null) |
414 | { | 412 | { |
415 | insertResponse = kvp.Value.AddProfile(sim); | 413 | insertResponse = plugin.AddProfile(sim); |
416 | } | 414 | } |
417 | else | 415 | else |
418 | { | 416 | { |
419 | insertResponse = kvp.Value.UpdateProfile(sim); | 417 | insertResponse = plugin.UpdateProfile(sim); |
420 | } | 418 | } |
421 | 419 | ||
422 | switch (insertResponse) | 420 | switch (insertResponse) |
@@ -441,7 +439,7 @@ namespace OpenSim.Grid.GridServer | |||
441 | catch (Exception e) | 439 | catch (Exception e) |
442 | { | 440 | { |
443 | m_log.Warn("[LOGIN END]: " + | 441 | m_log.Warn("[LOGIN END]: " + |
444 | "Unable to login region " + sim.UUID.ToString() + " via " + kvp.Key); | 442 | "Unable to login region " + sim.UUID.ToString() + " via " + plugin.Name); |
445 | m_log.Warn("[LOGIN END]: " + e.ToString()); | 443 | m_log.Warn("[LOGIN END]: " + e.ToString()); |
446 | } | 444 | } |
447 | } | 445 | } |
@@ -682,12 +680,12 @@ namespace OpenSim.Grid.GridServer | |||
682 | return response; | 680 | return response; |
683 | } | 681 | } |
684 | 682 | ||
685 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 683 | foreach (IGridDataPlugin plugin in _plugins) |
686 | { | 684 | { |
687 | //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); | 685 | //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); |
688 | try | 686 | try |
689 | { | 687 | { |
690 | MySQLGridData mysqldata = (MySQLGridData)(kvp.Value); | 688 | MySQLGridData mysqldata = (MySQLGridData)(plugin); |
691 | //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); | 689 | //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); |
692 | DataResponse insertResponse = mysqldata.DeleteProfile(uuid); | 690 | DataResponse insertResponse = mysqldata.DeleteProfile(uuid); |
693 | switch (insertResponse) | 691 | switch (insertResponse) |
@@ -1053,17 +1051,17 @@ namespace OpenSim.Grid.GridServer | |||
1053 | m_log.Info("[DATA]: " + | 1051 | m_log.Info("[DATA]: " + |
1054 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); | 1052 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); |
1055 | 1053 | ||
1056 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 1054 | foreach (IGridDataPlugin plugin in _plugins) |
1057 | { | 1055 | { |
1058 | try | 1056 | try |
1059 | { | 1057 | { |
1060 | //Check reservations | 1058 | //Check reservations |
1061 | ReservationData reserveData = | 1059 | ReservationData reserveData = |
1062 | kvp.Value.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); | 1060 | plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); |
1063 | if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || | 1061 | if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || |
1064 | (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) | 1062 | (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) |
1065 | { | 1063 | { |
1066 | kvp.Value.AddProfile(theSim); | 1064 | plugin.AddProfile(theSim); |
1067 | m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); | 1065 | m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); |
1068 | logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, | 1066 | logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, |
1069 | "Region successfully updated and connected to grid."); | 1067 | "Region successfully updated and connected to grid."); |
@@ -1078,7 +1076,7 @@ namespace OpenSim.Grid.GridServer | |||
1078 | } | 1076 | } |
1079 | catch (Exception e) | 1077 | catch (Exception e) |
1080 | { | 1078 | { |
1081 | m_log.Warn("[GRID]: GetRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + | 1079 | m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " + |
1082 | e.ToString()); | 1080 | e.ToString()); |
1083 | } | 1081 | } |
1084 | } | 1082 | } |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 3cd7489..a8ebd27 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -31,7 +31,6 @@ using System.IO; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Timers; | 32 | using System.Timers; |
33 | using log4net; | 33 | using log4net; |
34 | using Mono.Addins; | ||
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
@@ -121,7 +120,7 @@ namespace OpenSim.Grid.GridServer | |||
121 | PluginLoader<IGridPlugin> loader = | 120 | PluginLoader<IGridPlugin> loader = |
122 | new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this)); | 121 | new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this)); |
123 | 122 | ||
124 | loader.Load ("/OpenSim/GridServer", "."); | 123 | loader.Load ("/OpenSim/GridServer"); |
125 | m_plugins = loader.Plugins; | 124 | m_plugins = loader.Plugins; |
126 | } | 125 | } |
127 | 126 | ||
diff --git a/OpenSim/Grid/GridServer/IGridPlugin.cs b/OpenSim/Grid/GridServer/IGridPlugin.cs index 6593962..418caec 100644 --- a/OpenSim/Grid/GridServer/IGridPlugin.cs +++ b/OpenSim/Grid/GridServer/IGridPlugin.cs | |||
@@ -29,7 +29,7 @@ | |||
29 | using Mono.Addins; | 29 | using Mono.Addins; |
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | 31 | ||
32 | [assembly : AddinRoot("OpenSim", "0.5")] | 32 | [assembly : AddinRoot("OpenSim.Grid.GridServer", "0.5")] |
33 | 33 | ||
34 | namespace OpenSim.Grid.GridServer | 34 | namespace OpenSim.Grid.GridServer |
35 | { | 35 | { |
@@ -37,7 +37,6 @@ namespace OpenSim.Grid.GridServer | |||
37 | public interface IGridPlugin : IPlugin | 37 | public interface IGridPlugin : IPlugin |
38 | { | 38 | { |
39 | void Initialise(GridServerBase gridServer); | 39 | void Initialise(GridServerBase gridServer); |
40 | void Close(); | ||
41 | } | 40 | } |
42 | 41 | ||
43 | public class GridPluginInitialiser : PluginInitialiserBase | 42 | public class GridPluginInitialiser : PluginInitialiserBase |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 380df73..910ec55 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -34,7 +34,6 @@ using System.Text; | |||
34 | using System.Threading; | 34 | using System.Threading; |
35 | using libsecondlife; | 35 | using libsecondlife; |
36 | using log4net; | 36 | using log4net; |
37 | using Mono.Addins; | ||
38 | using Nini.Config; | 37 | using Nini.Config; |
39 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
@@ -338,7 +337,7 @@ namespace OpenSim | |||
338 | PluginLoader<IApplicationPlugin> loader = | 337 | PluginLoader<IApplicationPlugin> loader = |
339 | new PluginLoader<IApplicationPlugin> (new ApplicationPluginInitialiser (this)); | 338 | new PluginLoader<IApplicationPlugin> (new ApplicationPluginInitialiser (this)); |
340 | 339 | ||
341 | loader.Load ("/OpenSim/Startup", "."); | 340 | loader.Load ("/OpenSim/Startup"); |
342 | m_plugins = loader.Plugins; | 341 | m_plugins = loader.Plugins; |
343 | } | 342 | } |
344 | 343 | ||
diff --git a/prebuild.xml b/prebuild.xml index e66f470..97f9394 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -218,6 +218,7 @@ | |||
218 | <Reference name="OpenSim.Framework"/> | 218 | <Reference name="OpenSim.Framework"/> |
219 | <Reference name="OpenSim.Data.Base"/> | 219 | <Reference name="OpenSim.Data.Base"/> |
220 | <Reference name="log4net.dll"/> | 220 | <Reference name="log4net.dll"/> |
221 | <Reference name="Mono.Addins.dll" /> | ||
221 | <Files> | 222 | <Files> |
222 | <Match pattern="*.cs" recurse="false"/> | 223 | <Match pattern="*.cs" recurse="false"/> |
223 | <Match pattern="Properties/*.cs" recurse="false"/> | 224 | <Match pattern="Properties/*.cs" recurse="false"/> |
@@ -1293,6 +1294,7 @@ | |||
1293 | <Reference name="OpenSim.Framework.Console"/> | 1294 | <Reference name="OpenSim.Framework.Console"/> |
1294 | <Reference name="OpenSim.Region.Environment"/> | 1295 | <Reference name="OpenSim.Region.Environment"/> |
1295 | <Reference name="log4net.dll"/> | 1296 | <Reference name="log4net.dll"/> |
1297 | <Reference name="Mono.Addins.dll" /> | ||
1296 | 1298 | ||
1297 | <Files> | 1299 | <Files> |
1298 | <Match pattern="*.cs" recurse="true"/> | 1300 | <Match pattern="*.cs" recurse="true"/> |
@@ -1322,6 +1324,7 @@ | |||
1322 | <Reference name="OpenSim.Framework.Console"/> | 1324 | <Reference name="OpenSim.Framework.Console"/> |
1323 | <Reference name="libsecondlife.dll"/> | 1325 | <Reference name="libsecondlife.dll"/> |
1324 | <Reference name="log4net.dll"/> | 1326 | <Reference name="log4net.dll"/> |
1327 | <Reference name="Mono.Addins.dll" /> | ||
1325 | 1328 | ||
1326 | <Files> | 1329 | <Files> |
1327 | <Match pattern="*.cs" recurse="true"/> | 1330 | <Match pattern="*.cs" recurse="true"/> |
@@ -1352,6 +1355,7 @@ | |||
1352 | <Reference name="OpenSim.Region.Environment"/> | 1355 | <Reference name="OpenSim.Region.Environment"/> |
1353 | <Reference name="libsecondlife.dll"/> | 1356 | <Reference name="libsecondlife.dll"/> |
1354 | <Reference name="Mono.Data.SqliteClient"/> | 1357 | <Reference name="Mono.Data.SqliteClient"/> |
1358 | <Reference name="Mono.Addins.dll" /> | ||
1355 | <Reference name="log4net.dll"/> | 1359 | <Reference name="log4net.dll"/> |
1356 | 1360 | ||
1357 | <Files> | 1361 | <Files> |