aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/InventoryService/InventoryServiceBase.cs
diff options
context:
space:
mode:
authordiva2009-06-07 19:00:55 +0000
committerdiva2009-06-07 19:00:55 +0000
commit1ad237a8a757a0e6074278aff76805d01abf0c0b (patch)
treee6a697dd113aeb90c7dd92ee4d07f278d7ebf8de /OpenSim/Services/InventoryService/InventoryServiceBase.cs
parentSkip lone ident statments or for-loop assignments (diff)
downloadopensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.zip
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.gz
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.bz2
opensim-SC_OLD-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.xz
First draft of inventory service connectors, and service implementation. No handlers yet, this is just the OUT part for now. It's not active and nothing in the simulator uses this yet. Just checking it in to start sharing with others. There are a couple of interesting software design points that could use other devs opinions.
Hopefully I added all needed files.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/InventoryService/InventoryServiceBase.cs98
1 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Services/InventoryService/InventoryServiceBase.cs
new file mode 100644
index 0000000..a10e94f
--- /dev/null
+++ b/OpenSim/Services/InventoryService/InventoryServiceBase.cs
@@ -0,0 +1,98 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using Nini.Config;
32using OpenSim.Framework;
33using OpenSim.Data;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Base;
36
37namespace OpenSim.Services.InventoryService
38{
39 public class InventoryServiceBase : ServiceBase
40 {
41 protected IInventoryDataPlugin m_Database = null;
42
43 protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>();
44
45 public InventoryServiceBase(IConfigSource config) : base(config)
46 {
47 IConfig assetConfig = config.Configs["InventoryService"];
48 if (assetConfig == null)
49 throw new Exception("No InventoryService configuration");
50
51 string dllName = assetConfig.GetString("StorageProvider",
52 String.Empty);
53
54 if (dllName == String.Empty)
55 throw new Exception("No StorageProvider configured");
56
57 string connString = assetConfig.GetString("ConnectionString",
58 String.Empty);
59
60 m_Database = LoadPlugin<IInventoryDataPlugin>(dllName);
61 if (m_Database == null)
62 throw new Exception("Could not find a storage interface in the given module");
63
64 m_Database.Initialise(connString);
65
66 }
67
68 #region Plugin methods
69
70 /// <summary>
71 /// Add a new inventory data plugin - plugins will be requested in the order they were added.
72 /// </summary>
73 /// <param name="plugin">The plugin that will provide data</param>
74 public void AddPlugin(IInventoryDataPlugin plugin)
75 {
76 m_plugins.Add(plugin);
77 }
78
79 /// <summary>
80 /// Adds a list of inventory data plugins, as described by `provider'
81 /// and `connect', to `m_plugins'.
82 /// </summary>
83 /// <param name="provider">
84 /// The filename of the inventory server plugin DLL.
85 /// </param>
86 /// <param name="connect">
87 /// The connection string for the storage backend.
88 /// </param>
89 public void AddPlugin(string provider, string connect)
90 {
91 m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>(provider, connect));
92 }
93
94 #endregion
95
96
97 }
98}