diff options
author | Charles Krinke | 2008-07-10 13:45:46 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-10 13:45:46 +0000 |
commit | 7fd63d9dc84cce5a6e6b177ff3b62598b08978f4 (patch) | |
tree | 22e18ec3c23e6d7d9ee4cc9b9b39609974651df7 /OpenSim/Framework/PluginLoader.cs | |
parent | Thanks to mikem for a patch that resolves a reference error when building SVN... (diff) | |
download | opensim-SC-7fd63d9dc84cce5a6e6b177ff3b62598b08978f4.zip opensim-SC-7fd63d9dc84cce5a6e6b177ff3b62598b08978f4.tar.gz opensim-SC-7fd63d9dc84cce5a6e6b177ff3b62598b08978f4.tar.bz2 opensim-SC-7fd63d9dc84cce5a6e6b177ff3b62598b08978f4.tar.xz |
Mantis#1682. Thank you kindly, Sempuki for a patch that:
Move control of Mono.Addins from source attributes to external XML files.
This removes a lot of coupling of the source with Mono.Addins
Diffstat (limited to 'OpenSim/Framework/PluginLoader.cs')
-rw-r--r-- | OpenSim/Framework/PluginLoader.cs | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs index 9104958..cfc1d7c 100644 --- a/OpenSim/Framework/PluginLoader.cs +++ b/OpenSim/Framework/PluginLoader.cs | |||
@@ -55,6 +55,7 @@ namespace OpenSim.Framework | |||
55 | } | 55 | } |
56 | 56 | ||
57 | /// <summary> | 57 | /// <summary> |
58 | |||
58 | /// Generic Plugin Loader | 59 | /// Generic Plugin Loader |
59 | /// </summary> | 60 | /// </summary> |
60 | public class PluginLoader <T> : IDisposable where T : IPlugin | 61 | public class PluginLoader <T> : IDisposable where T : IPlugin |
@@ -66,16 +67,17 @@ namespace OpenSim.Framework | |||
66 | private PluginInitialiserBase initialiser; | 67 | private PluginInitialiserBase initialiser; |
67 | private Dictionary<string,IPluginConstraint> constraints | 68 | private Dictionary<string,IPluginConstraint> constraints |
68 | = new Dictionary<string,IPluginConstraint>(); | 69 | = new Dictionary<string,IPluginConstraint>(); |
69 | 70 | ||
71 | private static bool runonce = false; | ||
70 | private static readonly ILog log | 72 | private static readonly ILog log |
71 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 73 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
72 | 74 | ||
73 | public PluginInitialiserBase Initialiser | 75 | public PluginInitialiserBase Initialiser |
74 | { | 76 | { |
75 | set { initialiser = value; } | 77 | set { initialiser = value; } |
76 | get { return initialiser; } | 78 | get { return initialiser; } |
77 | } | 79 | } |
78 | 80 | ||
79 | public List<T> Plugins | 81 | public List<T> Plugins |
80 | { | 82 | { |
81 | get { return loaded; } | 83 | get { return loaded; } |
@@ -84,25 +86,19 @@ namespace OpenSim.Framework | |||
84 | public PluginLoader () | 86 | public PluginLoader () |
85 | { | 87 | { |
86 | Initialiser = new PluginInitialiserBase(); | 88 | Initialiser = new PluginInitialiserBase(); |
89 | initialise_plugin_dir_ ("."); | ||
87 | } | 90 | } |
88 | 91 | ||
89 | public PluginLoader (PluginInitialiserBase init) | 92 | public PluginLoader (PluginInitialiserBase init) |
90 | { | 93 | { |
91 | Initialiser = init; | 94 | Initialiser = init; |
95 | initialise_plugin_dir_ ("."); | ||
92 | } | 96 | } |
93 | 97 | ||
94 | public PluginLoader (PluginInitialiserBase init, string dir) | 98 | public PluginLoader (PluginInitialiserBase init, string dir) |
95 | { | 99 | { |
96 | Initialiser = init; | 100 | Initialiser = init; |
97 | AddPluginDir (dir); | 101 | 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 | } | 102 | } |
107 | 103 | ||
108 | public void AddExtensionPoint (string extpoint) | 104 | public void AddExtensionPoint (string extpoint) |
@@ -114,22 +110,21 @@ namespace OpenSim.Framework | |||
114 | { | 110 | { |
115 | constraints.Add (extpoint, cons); | 111 | constraints.Add (extpoint, cons); |
116 | } | 112 | } |
117 | 113 | ||
118 | public void Load (string extpoint, string dir) | 114 | public void Load (string extpoint) |
119 | { | 115 | { |
120 | AddPluginDir (dir); | ||
121 | AddExtensionPoint (extpoint); | 116 | AddExtensionPoint (extpoint); |
122 | Load(); | 117 | Load(); |
123 | } | 118 | } |
124 | 119 | ||
125 | public void Load () | 120 | public void Load () |
126 | { | 121 | { |
127 | suppress_console_output_ (true); | 122 | log.Info("[PLUGINS]: Begin Loading " + AddinManager.Registry.RegistryPath); |
128 | AddinManager.Registry.Update (null); | ||
129 | suppress_console_output_ (false); | ||
130 | 123 | ||
131 | foreach (string ext in extpoints) | 124 | foreach (string ext in extpoints) |
132 | { | 125 | { |
126 | log.Info("[PLUGINS]: Loading extension point " + ext); | ||
127 | |||
133 | if (constraints.ContainsKey (ext)) | 128 | if (constraints.ContainsKey (ext)) |
134 | { | 129 | { |
135 | IPluginConstraint cons = constraints [ext]; | 130 | IPluginConstraint cons = constraints [ext]; |
@@ -155,9 +150,25 @@ namespace OpenSim.Framework | |||
155 | p.Dispose (); | 150 | p.Dispose (); |
156 | } | 151 | } |
157 | 152 | ||
158 | public void ClearCache() | 153 | private void initialise_plugin_dir_ (string dir) |
154 | { | ||
155 | if (runonce == true) | ||
156 | return; | ||
157 | |||
158 | log.Info("[PLUGINS]: Initialzing " + dir); | ||
159 | |||
160 | clear_registry_(); | ||
161 | suppress_console_output_ (true); | ||
162 | AddinManager.Initialize (dir); | ||
163 | AddinManager.Registry.Update (null); | ||
164 | suppress_console_output_ (false); | ||
165 | runonce = true; | ||
166 | } | ||
167 | |||
168 | private void clear_registry_ () | ||
159 | { | 169 | { |
160 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache | 170 | // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) |
171 | // occasionally seems to corrupt its addin cache | ||
161 | // Hence, as a temporary solution we'll remove it before each startup | 172 | // Hence, as a temporary solution we'll remove it before each startup |
162 | if (Directory.Exists("addin-db-000")) | 173 | if (Directory.Exists("addin-db-000")) |
163 | Directory.Delete("addin-db-000", true); | 174 | Directory.Delete("addin-db-000", true); |
@@ -225,7 +236,7 @@ namespace OpenSim.Framework | |||
225 | public PluginFilenameConstraint (string name) | 236 | public PluginFilenameConstraint (string name) |
226 | { | 237 | { |
227 | filename = name; | 238 | filename = name; |
228 | 239 | ||
229 | } | 240 | } |
230 | 241 | ||
231 | public string Message | 242 | public string Message |
@@ -245,7 +256,7 @@ namespace OpenSim.Framework | |||
245 | string[] path = ns[0].Path.Split('/'); | 256 | string[] path = ns[0].Path.Split('/'); |
246 | if (path [path.Length-1] == filename) | 257 | if (path [path.Length-1] == filename) |
247 | return false; | 258 | return false; |
248 | 259 | ||
249 | return true; | 260 | return true; |
250 | } | 261 | } |
251 | } | 262 | } |