diff options
Diffstat (limited to 'OpenSim/Services/UserService')
-rw-r--r-- | OpenSim/Services/UserService/UserServiceBase.cs | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserService/UserServiceBase.cs index 6a20670..0cf24a4 100644 --- a/OpenSim/Services/UserService/UserServiceBase.cs +++ b/OpenSim/Services/UserService/UserServiceBase.cs | |||
@@ -30,18 +30,19 @@ using System.Reflection; | |||
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenSim.Data; | 31 | using OpenSim.Data; |
32 | using OpenSim.Services.Interfaces; | 32 | using OpenSim.Services.Interfaces; |
33 | using OpenSim.Services.Base; | ||
33 | 34 | ||
34 | namespace OpenSim.Services.UserService | 35 | namespace OpenSim.Services.UserService |
35 | { | 36 | { |
36 | public class UserServiceBase | 37 | public class UserServiceBase: ServiceBase |
37 | { | 38 | { |
38 | protected IUserDataPlugin m_Database = null; | 39 | protected IUserDataPlugin m_Database = null; |
39 | 40 | ||
40 | public UserServiceBase(IConfigSource config) | 41 | public UserServiceBase(IConfigSource config) : base(config) |
41 | { | 42 | { |
42 | IConfig userConfig = config.Configs["UserService"]; | 43 | IConfig userConfig = config.Configs["UserService"]; |
43 | if (userConfig == null) | 44 | if (userConfig == null) |
44 | throw new Exception("No userService configuration"); | 45 | throw new Exception("No UserService configuration"); |
45 | 46 | ||
46 | string dllName = userConfig.GetString("StorageProvider", | 47 | string dllName = userConfig.GetString("StorageProvider", |
47 | String.Empty); | 48 | String.Empty); |
@@ -52,34 +53,12 @@ namespace OpenSim.Services.UserService | |||
52 | string connString = userConfig.GetString("ConnectionString", | 53 | string connString = userConfig.GetString("ConnectionString", |
53 | String.Empty); | 54 | String.Empty); |
54 | 55 | ||
55 | try | 56 | m_Database = LoadPlugin<IUserDataPlugin>(dllName); |
56 | { | ||
57 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
58 | 57 | ||
59 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 58 | if (m_Database == null) |
60 | { | 59 | throw new Exception("Could not find a storage interface in the given module"); |
61 | if (pluginType.IsPublic) | ||
62 | { | ||
63 | Type typeInterface = | ||
64 | pluginType.GetInterface("IUserDataPlugin", true); | ||
65 | if (typeInterface != null) | ||
66 | { | ||
67 | IUserDataPlugin plug = | ||
68 | (IUserDataPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
69 | plug.Initialise(connString); | ||
70 | 60 | ||
71 | m_Database = plug; | 61 | m_Database.Initialise(connString); |
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | if (m_Database == null) | ||
77 | throw new Exception("Could not find a storage interface in the given module"); | ||
78 | } | ||
79 | catch (Exception e) | ||
80 | { | ||
81 | throw new Exception("Can't open database module: "+e.Message); | ||
82 | } | ||
83 | } | 62 | } |
84 | } | 63 | } |
85 | } | 64 | } |