aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PluginLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/PluginLoader.cs98
1 files changed, 49 insertions, 49 deletions
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index 7ceb0b2..cabce1b 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Framework
47 } 47 }
48 48
49 /// <summary> 49 /// <summary>
50 /// Classes wishing to impose constraints on plugin loading must implement 50 /// Classes wishing to impose constraints on plugin loading must implement
51 /// this class and pass it to PluginLoader AddConstraint() 51 /// this class and pass it to PluginLoader AddConstraint()
52 /// </summary> 52 /// </summary>
53 public interface IPluginConstraint 53 public interface IPluginConstraint
@@ -75,46 +75,46 @@ namespace OpenSim.Framework
75 private List<T> loaded = new List<T>(); 75 private List<T> loaded = new List<T>();
76 private List<string> extpoints = new List<string>(); 76 private List<string> extpoints = new List<string>();
77 private PluginInitialiserBase initialiser; 77 private PluginInitialiserBase initialiser;
78 78
79 private Dictionary<string,IPluginConstraint> constraints 79 private Dictionary<string,IPluginConstraint> constraints
80 = new Dictionary<string,IPluginConstraint>(); 80 = new Dictionary<string,IPluginConstraint>();
81 81
82 private Dictionary<string,IPluginFilter> filters 82 private Dictionary<string,IPluginFilter> filters
83 = new Dictionary<string,IPluginFilter>(); 83 = new Dictionary<string,IPluginFilter>();
84 84
85 private static readonly ILog log 85 private static readonly ILog log
86 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 86 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
87 87
88 public PluginInitialiserBase Initialiser 88 public PluginInitialiserBase Initialiser
89 { 89 {
90 set { initialiser = value; } 90 set { initialiser = value; }
91 get { return initialiser; } 91 get { return initialiser; }
92 } 92 }
93 93
94 public List<T> Plugins 94 public List<T> Plugins
95 { 95 {
96 get { return loaded; } 96 get { return loaded; }
97 } 97 }
98 98
99 public T Plugin 99 public T Plugin
100 { 100 {
101 get { return (loaded.Count == 1)? loaded [0] : default (T); } 101 get { return (loaded.Count == 1)? loaded [0] : default (T); }
102 } 102 }
103 103
104 public PluginLoader () 104 public PluginLoader ()
105 { 105 {
106 Initialiser = new PluginInitialiserBase(); 106 Initialiser = new PluginInitialiserBase();
107 initialise_plugin_dir_ ("."); 107 initialise_plugin_dir_ (".");
108 } 108 }
109 109
110 public PluginLoader (PluginInitialiserBase init) 110 public PluginLoader (PluginInitialiserBase init)
111 { 111 {
112 Initialiser = init; 112 Initialiser = init;
113 initialise_plugin_dir_ ("."); 113 initialise_plugin_dir_ (".");
114 } 114 }
115 115
116 public PluginLoader (PluginInitialiserBase init, string dir) 116 public PluginLoader (PluginInitialiserBase init, string dir)
117 { 117 {
118 Initialiser = init; 118 Initialiser = init;
119 initialise_plugin_dir_ (dir); 119 initialise_plugin_dir_ (dir);
120 } 120 }
@@ -123,7 +123,7 @@ namespace OpenSim.Framework
123 { 123 {
124 if (extpoints.Contains (extpoint)) 124 if (extpoints.Contains (extpoint))
125 return; 125 return;
126 126
127 extpoints.Add (extpoint); 127 extpoints.Add (extpoint);
128 } 128 }
129 129
@@ -156,7 +156,7 @@ namespace OpenSim.Framework
156 } 156 }
157 157
158 public void Load () 158 public void Load ()
159 { 159 {
160 foreach (string ext in extpoints) 160 foreach (string ext in extpoints)
161 { 161 {
162 log.Info("[PLUGINS]: Loading extension point " + ext); 162 log.Info("[PLUGINS]: Loading extension point " + ext);
@@ -169,17 +169,17 @@ namespace OpenSim.Framework
169 } 169 }
170 170
171 IPluginFilter filter = null; 171 IPluginFilter filter = null;
172 172
173 if (filters.ContainsKey (ext)) 173 if (filters.ContainsKey (ext))
174 filter = filters [ext]; 174 filter = filters [ext];
175 175
176 foreach (PluginExtensionNode node in AddinManager.GetExtensionNodes (ext)) 176 foreach (PluginExtensionNode node in AddinManager.GetExtensionNodes (ext))
177 { 177 {
178 log.Info("[PLUGINS]: Trying plugin " + node.Path); 178 log.Info("[PLUGINS]: Trying plugin " + node.Path);
179 179
180 if ((filter != null) && (filter.Apply (node) == false)) 180 if ((filter != null) && (filter.Apply (node) == false))
181 continue; 181 continue;
182 182
183 T plugin = (T) node.CreateInstance(); 183 T plugin = (T) node.CreateInstance();
184 Initialiser.Initialise (plugin); 184 Initialiser.Initialise (plugin);
185 Plugins.Add (plugin); 185 Plugins.Add (plugin);
@@ -219,7 +219,7 @@ namespace OpenSim.Framework
219 private void on_addinloaderror_(object sender, AddinErrorEventArgs args) 219 private void on_addinloaderror_(object sender, AddinErrorEventArgs args)
220 { 220 {
221 if (args.Exception == null) 221 if (args.Exception == null)
222 log.Error ("[PLUGINS]: Plugin Error: " 222 log.Error ("[PLUGINS]: Plugin Error: "
223 + args.Message); 223 + args.Message);
224 else 224 else
225 log.Error ("[PLUGINS]: Plugin Error: " 225 log.Error ("[PLUGINS]: Plugin Error: "
@@ -229,7 +229,7 @@ namespace OpenSim.Framework
229 229
230 private void clear_registry_ () 230 private void clear_registry_ ()
231 { 231 {
232 // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) 232 // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0)
233 // occasionally seems to corrupt its addin cache 233 // occasionally seems to corrupt its addin cache
234 // Hence, as a temporary solution we'll remove it before each startup 234 // Hence, as a temporary solution we'll remove it before each startup
235 try 235 try
@@ -252,7 +252,7 @@ namespace OpenSim.Framework
252 } 252 }
253 } 253 }
254 254
255 private static TextWriter prev_console_; 255 private static TextWriter prev_console_;
256 public void suppress_console_output_ (bool save) 256 public void suppress_console_output_ (bool save)
257 { 257 {
258 if (save) 258 if (save)
@@ -262,7 +262,7 @@ namespace OpenSim.Framework
262 } 262 }
263 else 263 else
264 { 264 {
265 if (prev_console_ != null) 265 if (prev_console_ != null)
266 System.Console.SetOut(prev_console_); 266 System.Console.SetOut(prev_console_);
267 } 267 }
268 } 268 }
@@ -283,7 +283,7 @@ namespace OpenSim.Framework
283 283
284 public Type TypeObject 284 public Type TypeObject
285 { 285 {
286 get 286 get
287 { 287 {
288 if (typeobj != null) 288 if (typeobj != null)
289 return typeobj; 289 return typeobj;
@@ -295,9 +295,9 @@ namespace OpenSim.Framework
295 } 295 }
296 } 296 }
297 297
298 public object CreateInstance () 298 public object CreateInstance ()
299 { 299 {
300 return Activator.CreateInstance (TypeObject); 300 return Activator.CreateInstance (TypeObject);
301 } 301 }
302 } 302 }
303 303
@@ -305,29 +305,29 @@ namespace OpenSim.Framework
305 /// Constraint that bounds the number of plugins to be loaded. 305 /// Constraint that bounds the number of plugins to be loaded.
306 /// </summary> 306 /// </summary>
307 public class PluginCountConstraint : IPluginConstraint 307 public class PluginCountConstraint : IPluginConstraint
308 { 308 {
309 private int min; 309 private int min;
310 private int max; 310 private int max;
311 311
312 public PluginCountConstraint (int exact) 312 public PluginCountConstraint (int exact)
313 { 313 {
314 min = exact; 314 min = exact;
315 max = exact; 315 max = exact;
316 }
317
318 public PluginCountConstraint (int minimum, int maximum)
319 {
320 min = minimum;
321 max = maximum;
316 } 322 }
317 323
318 public PluginCountConstraint (int minimum, int maximum) 324 public string Message
319 { 325 {
320 min = minimum; 326 get
321 max = maximum; 327 {
322 } 328 return "The number of plugins is constrained to the interval ["
323 329 + min + ", " + max + "]";
324 public string Message 330 }
325 {
326 get
327 {
328 return "The number of plugins is constrained to the interval ["
329 + min + ", " + max + "]";
330 }
331 } 331 }
332 332
333 public bool Apply (string extpoint) 333 public bool Apply (string extpoint)
@@ -340,7 +340,7 @@ namespace OpenSim.Framework
340 return true; 340 return true;
341 } 341 }
342 } 342 }
343 343
344 /// <summary> 344 /// <summary>
345 /// Filters out which plugin to load based on its "Provider", which is name given by in the addin.xml 345 /// Filters out which plugin to load based on its "Provider", which is name given by in the addin.xml
346 /// </summary> 346 /// </summary>
@@ -348,7 +348,7 @@ namespace OpenSim.Framework
348 { 348 {
349 private string provider; 349 private string provider;
350 350
351 public PluginProviderFilter (string p) 351 public PluginProviderFilter (string p)
352 { 352 {
353 provider = p; 353 provider = p;
354 } 354 }