aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs146
1 files changed, 0 insertions, 146 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
deleted file mode 100644
index ac8f888..0000000
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ /dev/null
@@ -1,146 +0,0 @@
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.IO;
30using System.Reflection;
31using log4net;
32using log4net.Config;
33using OpenMetaverse;
34using OpenSim.Data;
35using OpenSim.Framework;
36using OpenSim.Framework.AssetLoader.Filesystem;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Framework.Statistics;
41
42namespace OpenSim.Grid.AssetServer
43{
44 /// <summary>
45 /// An asset server
46 /// </summary>
47 public class OpenAsset_Main : BaseOpenSimServer
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 public static OpenAsset_Main assetserver;
52
53 // Temporarily hardcoded - should be a plugin
54 protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
55
56 private IAssetDataPlugin m_assetProvider;
57
58 public static void Main(string[] args)
59 {
60 XmlConfigurator.Configure();
61
62 assetserver = new OpenAsset_Main();
63 assetserver.Startup();
64
65 assetserver.Work();
66 }
67
68 private void Work()
69 {
70 m_console.Output("Enter help for a list of commands");
71
72 while (true)
73 {
74 m_console.Prompt();
75 }
76 }
77
78 public OpenAsset_Main()
79 {
80 m_console = new LocalConsole("Asset");
81
82 MainConsole.Instance = m_console;
83 }
84
85 protected override void StartupSpecific()
86 {
87 AssetConfig config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
88
89 m_log.Info("[ASSET]: Setting up asset DB");
90 setupDB(config);
91
92 m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'");
93 LoadDefaultAssets(config.AssetSetsLocation);
94
95 m_log.Info("[ASSET]: Starting HTTP process");
96 m_httpServer = new BaseHttpServer(config.HttpPort);
97
98 m_stats = StatsManager.StartCollectingAssetStats();
99
100 AddHttpHandlers();
101
102 m_httpServer.Start();
103
104 base.StartupSpecific();
105 }
106
107 protected void AddHttpHandlers()
108 {
109 m_httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider));
110 m_httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider));
111 }
112
113 public byte[] GetAssetData(UUID assetID, bool isTexture)
114 {
115 return null;
116 }
117
118 public void setupDB(AssetConfig config)
119 {
120 try
121 {
122 m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect);
123 if (m_assetProvider == null)
124 {
125 m_log.Error("[ASSET]: Failed to load a database plugin, server halting");
126 Environment.Exit(-1);
127 }
128 }
129 catch (Exception e)
130 {
131 m_log.Warn("[ASSET]: setupDB() - Exception occured");
132 m_log.Warn("[ASSET]: " + e.ToString());
133 }
134 }
135
136 public void LoadDefaultAssets(string pAssetSetsLocation)
137 {
138 assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset);
139 }
140
141 protected void StoreAsset(AssetBase asset)
142 {
143 m_assetProvider.StoreAsset(asset);
144 }
145 }
146}