diff options
author | Justin Clark-Casey (justincc) | 2010-03-12 19:31:14 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-03-12 19:31:14 +0000 |
commit | f2de50bb14bd8215ea98c79c79aabe1e6b4f2780 (patch) | |
tree | a234ef918308290b8d9db829f392ce646b7f2c06 /OpenSim/Server/Base/ServerUtils.cs | |
parent | Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-f2de50bb14bd8215ea98c79c79aabe1e6b4f2780.zip opensim-SC-f2de50bb14bd8215ea98c79c79aabe1e6b4f2780.tar.gz opensim-SC-f2de50bb14bd8215ea98c79c79aabe1e6b4f2780.tar.bz2 opensim-SC-f2de50bb14bd8215ea98c79c79aabe1e6b4f2780.tar.xz |
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
Diffstat (limited to 'OpenSim/Server/Base/ServerUtils.cs')
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 40 |
1 files changed, 20 insertions, 20 deletions
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 | |||
57 | return ret; | 57 | return ret; |
58 | } | 58 | } |
59 | 59 | ||
60 | /// <summary> | ||
61 | /// Load a plugin from a dll with the given class or interface | ||
62 | /// </summary> | ||
63 | /// <param name="dllName"></param> | ||
64 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> | ||
65 | /// <returns></returns> | ||
60 | public static T LoadPlugin<T>(string dllName, Object[] args) where T:class | 66 | public static T LoadPlugin<T>(string dllName, Object[] args) where T:class |
61 | { | 67 | { |
62 | string[] parts = dllName.Split(new char[] {':'}); | 68 | string[] parts = dllName.Split(new char[] {':'}); |
@@ -71,6 +77,13 @@ namespace OpenSim.Server.Base | |||
71 | return LoadPlugin<T>(dllName, className, args); | 77 | return LoadPlugin<T>(dllName, className, args); |
72 | } | 78 | } |
73 | 79 | ||
80 | /// <summary> | ||
81 | /// Load a plugin from a dll with the given class or interface | ||
82 | /// </summary> | ||
83 | /// <param name="dllName"></param> | ||
84 | /// <param name="className"></param> | ||
85 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> | ||
86 | /// <returns></returns> | ||
74 | public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class | 87 | public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class |
75 | { | 88 | { |
76 | string interfaceName = typeof(T).ToString(); | 89 | string interfaceName = typeof(T).ToString(); |
@@ -83,28 +96,15 @@ namespace OpenSim.Server.Base | |||
83 | { | 96 | { |
84 | if (pluginType.IsPublic) | 97 | if (pluginType.IsPublic) |
85 | { | 98 | { |
86 | if (className != String.Empty && | 99 | if (className != String.Empty |
87 | pluginType.ToString() != | 100 | && pluginType.ToString() != pluginType.Namespace + "." + className) |
88 | pluginType.Namespace + "." + className) | ||
89 | continue; | 101 | continue; |
90 | Type typeInterface = | 102 | |
91 | pluginType.GetInterface(interfaceName, true); | 103 | Type typeInterface = pluginType.GetInterface(interfaceName, true); |
104 | |||
92 | if (typeInterface != null) | 105 | if (typeInterface != null) |
93 | { | 106 | { |
94 | T plug = null; | 107 | return (T)Activator.CreateInstance(pluginType, args); |
95 | try | ||
96 | { | ||
97 | plug = (T)Activator.CreateInstance(pluginType, | ||
98 | args); | ||
99 | } | ||
100 | catch (Exception e) | ||
101 | { | ||
102 | if (!(e is System.MissingMethodException)) | ||
103 | m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); | ||
104 | return null; | ||
105 | } | ||
106 | |||
107 | return plug; | ||
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
@@ -113,7 +113,7 @@ namespace OpenSim.Server.Base | |||
113 | } | 113 | } |
114 | catch (Exception e) | 114 | catch (Exception e) |
115 | { | 115 | { |
116 | m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e); | 116 | m_log.Error(string.Format("Error loading plugin from {0}", dllName), e); |
117 | return null; | 117 | return null; |
118 | } | 118 | } |
119 | } | 119 | } |