From f2de50bb14bd8215ea98c79c79aabe1e6b4f2780 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 12 Mar 2010 19:31:14 +0000
Subject: Fix tests broken in 88771aeed3d45e60a18aa9a810eeb37b8e5def12 Adds
MockUserAccountService and connects it up Stops services being carried over
between tests since this leads to hard to find bugs Improves information and
error reporting when loading plugins
---
OpenSim/Server/Base/ServerUtils.cs | 40 +++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Server/Base')
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 9c54410..a399672 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -57,6 +57,12 @@ namespace OpenSim.Server.Base
return ret;
}
+ ///
+ /// Load a plugin from a dll with the given class or interface
+ ///
+ ///
+ /// The arguments which control which constructor is invoked on the plugin
+ ///
public static T LoadPlugin(string dllName, Object[] args) where T:class
{
string[] parts = dllName.Split(new char[] {':'});
@@ -71,6 +77,13 @@ namespace OpenSim.Server.Base
return LoadPlugin(dllName, className, args);
}
+ ///
+ /// Load a plugin from a dll with the given class or interface
+ ///
+ ///
+ ///
+ /// The arguments which control which constructor is invoked on the plugin
+ ///
public static T LoadPlugin(string dllName, string className, Object[] args) where T:class
{
string interfaceName = typeof(T).ToString();
@@ -83,28 +96,15 @@ namespace OpenSim.Server.Base
{
if (pluginType.IsPublic)
{
- if (className != String.Empty &&
- pluginType.ToString() !=
- pluginType.Namespace + "." + className)
+ if (className != String.Empty
+ && pluginType.ToString() != pluginType.Namespace + "." + className)
continue;
- Type typeInterface =
- pluginType.GetInterface(interfaceName, true);
+
+ Type typeInterface = pluginType.GetInterface(interfaceName, true);
+
if (typeInterface != null)
{
- T plug = null;
- try
- {
- plug = (T)Activator.CreateInstance(pluginType,
- args);
- }
- catch (Exception e)
- {
- if (!(e is System.MissingMethodException))
- m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
- return null;
- }
-
- return plug;
+ return (T)Activator.CreateInstance(pluginType, args);
}
}
}
@@ -113,7 +113,7 @@ namespace OpenSim.Server.Base
}
catch (Exception e)
{
- m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e);
+ m_log.Error(string.Format("Error loading plugin from {0}", dllName), e);
return null;
}
}
--
cgit v1.1