aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/SQLAssetServer.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs248
1 files changed, 124 insertions, 124 deletions
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 379d609..69f83d2 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -1,125 +1,125 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Threading; 30using System.Threading;
31using System.Reflection; 31using System.Reflection;
32using libsecondlife; 32using libsecondlife;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38
39namespace OpenSim.Framework.Communications.Cache 39namespace OpenSim.Framework.Communications.Cache
40{ 40{
41 public class SQLAssetServer : AssetServerBase 41 public class SQLAssetServer : AssetServerBase
42 { 42 {
43 public SQLAssetServer(string pluginName) 43 public SQLAssetServer(string pluginName)
44 { 44 {
45 _assetRequests = new BlockingQueue<ARequest>(); 45 _assetRequests = new BlockingQueue<ARequest>();
46 AddPlugin(pluginName); 46 AddPlugin(pluginName);
47 } 47 }
48 48
49 public SQLAssetServer(IAssetProvider assetProvider) 49 public SQLAssetServer(IAssetProvider assetProvider)
50 { 50 {
51 m_assetProviderPlugin = assetProvider; 51 m_assetProviderPlugin = assetProvider;
52 } 52 }
53 53
54 public void AddPlugin(string FileName) 54 public void AddPlugin(string FileName)
55 { 55 {
56 MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); 56 MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName);
57 Assembly pluginAssembly = Assembly.LoadFrom(FileName); 57 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
58 58
59 foreach (Type pluginType in pluginAssembly.GetTypes()) 59 foreach (Type pluginType in pluginAssembly.GetTypes())
60 { 60 {
61 if (!pluginType.IsAbstract) 61 if (!pluginType.IsAbstract)
62 { 62 {
63 Type typeInterface = pluginType.GetInterface("IAssetProvider", true); 63 Type typeInterface = pluginType.GetInterface("IAssetProvider", true);
64 64
65 if (typeInterface != null) 65 if (typeInterface != null)
66 { 66 {
67 IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 67 IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
68 m_assetProviderPlugin = plug; 68 m_assetProviderPlugin = plug;
69 m_assetProviderPlugin.Initialise(); 69 m_assetProviderPlugin.Initialise();
70 70
71 MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); 71 MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version);
72 } 72 }
73 73
74 typeInterface = null; 74 typeInterface = null;
75 } 75 }
76 } 76 }
77 77
78 pluginAssembly = null; 78 pluginAssembly = null;
79 } 79 }
80 80
81 81
82 public override void Close() 82 public override void Close()
83 { 83 {
84 base.Close(); 84 base.Close();
85 85
86 m_assetProviderPlugin.CommitAssets(); 86 m_assetProviderPlugin.CommitAssets();
87 } 87 }
88 88
89 override protected void RunRequests() 89 override protected void RunRequests()
90 { 90 {
91 while (true) 91 while (true)
92 { 92 {
93 ARequest req = this._assetRequests.Dequeue(); 93 ARequest req = this._assetRequests.Dequeue();
94 94
95 MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); 95 MainLog.Instance.Verbose("Requesting asset: " + req.AssetID);
96 96
97 AssetBase asset = null; 97 AssetBase asset = null;
98 lock (syncLock) 98 lock (syncLock)
99 { 99 {
100 asset = m_assetProviderPlugin.FetchAsset(req.AssetID); 100 asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
101 } 101 }
102 if (asset != null) 102 if (asset != null)
103 { 103 {
104 _receiver.AssetReceived(asset, req.IsTexture); 104 _receiver.AssetReceived(asset, req.IsTexture);
105 } 105 }
106 else 106 else
107 { 107 {
108 _receiver.AssetNotFound(req.AssetID); 108 _receiver.AssetNotFound(req.AssetID);
109 } 109 }
110 110
111 } 111 }
112 112
113 } 113 }
114 114
115 protected override void StoreAsset(AssetBase asset) 115 protected override void StoreAsset(AssetBase asset)
116 { 116 {
117 m_assetProviderPlugin.CreateAsset(asset); 117 m_assetProviderPlugin.CreateAsset(asset);
118 } 118 }
119 119
120 protected override void CommitAssets() 120 protected override void CommitAssets()
121 { 121 {
122 m_assetProviderPlugin.CommitAssets(); 122 m_assetProviderPlugin.CommitAssets();
123 } 123 }
124 } 124 }
125} \ No newline at end of file 125} \ No newline at end of file