aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
diff options
context:
space:
mode:
authorMike Mazur2009-02-16 02:27:43 +0000
committerMike Mazur2009-02-16 02:27:43 +0000
commit5277fc64c07da92014e749be40aa837193a26495 (patch)
tree5351a96ac5d612560dc63d8c8585237d9dc80d27 /OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
parent- remove dependency on ExtensionLoader.dll (DBConnString.cs can go) (diff)
downloadopensim-SC-5277fc64c07da92014e749be40aa837193a26495.zip
opensim-SC-5277fc64c07da92014e749be40aa837193a26495.tar.gz
opensim-SC-5277fc64c07da92014e749be40aa837193a26495.tar.bz2
opensim-SC-5277fc64c07da92014e749be40aa837193a26495.tar.xz
- change AssetInventoryServer config from XML to INI
- convert AssetInventoryServer logging to OpenSim's log4net - updated AssetInventoryServer.ini.example file
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs53
1 files changed, 30 insertions, 23 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
index f6d46e8..b76b9c6 100644
--- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
+++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
@@ -32,18 +32,18 @@ using System.Collections.Generic;
32using System.IO; 32using System.IO;
33using System.Net; 33using System.Net;
34using System.Reflection; 34using System.Reflection;
35using log4net;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
38using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using Nini.Config;
39using log4net;
39 40
40namespace OpenSim.Grid.AssetInventoryServer 41namespace OpenSim.Grid.AssetInventoryServer
41{ 42{
42 public class AssetInventoryServer : BaseOpenSimServer 43 public class AssetInventoryServer : BaseOpenSimServer
43 { 44 {
44 public const string CONFIG_FILE = "AssetInventoryServer.ini"; 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 46 public IConfigSource ConfigFile;
46 public AssetInventoryConfig ConfigFile;
47 47
48 public IAssetStorageProvider StorageProvider; 48 public IAssetStorageProvider StorageProvider;
49 public IInventoryStorageProvider InventoryProvider; 49 public IInventoryStorageProvider InventoryProvider;
@@ -54,51 +54,58 @@ namespace OpenSim.Grid.AssetInventoryServer
54 private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>(); 54 private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>();
55 private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>(); 55 private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>();
56 56
57 public AssetInventoryServer() 57 public AssetInventoryServer(IConfigSource config)
58 { 58 {
59 m_console = new ConsoleBase("Asset"); 59 ConfigFile = config;
60
61 m_console = new ConsoleBase("AssetInventory");
60 MainConsole.Instance = m_console; 62 MainConsole.Instance = m_console;
61 } 63 }
62 64
63 public bool Start() 65 public bool Start()
64 { 66 {
65 Logger.Log.Info("Starting Asset Server"); 67 Startup();
66 uint port = 0; 68 m_log.Info("[ASSETINVENTORY] Starting AssetInventory Server");
67 69
68 try { ConfigFile = new AssetInventoryConfig("AssetInventory Server", (Path.Combine(Util.configDir(), "AssetInventoryServer.ini"))); } 70 try
71 {
72 ConfigFile = AssetInventoryConfig.LoadConfig(ConfigFile);
73 }
69 catch (Exception) 74 catch (Exception)
70 { 75 {
71 Logger.Log.Error("Failed to load the config file " + CONFIG_FILE); 76 m_log.Error("[ASSETINVENTORY] Failed to load the config.");
72 return false; 77 return false;
73 } 78 }
74 79
75 StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", ConfigFile.AssetStorageProvider) as IAssetStorageProvider; 80 IConfig pluginConfig = ConfigFile.Configs["Plugins"];
81
82 StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", pluginConfig.GetString("asset_storage_provider")) as IAssetStorageProvider;
76 m_backends.Add(StorageProvider); 83 m_backends.Add(StorageProvider);
77 84
78 InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", ConfigFile.InventoryStorageProvider) as IInventoryStorageProvider; 85 InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", pluginConfig.GetString("inventory_storage_provider")) as IInventoryStorageProvider;
79 m_backends.Add(InventoryProvider); 86 m_backends.Add(InventoryProvider);
80 87
81 MetricsProvider = LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/MetricsProvider", ConfigFile.MetricsProvider) as IMetricsProvider; 88 MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", pluginConfig.GetString("metrics_provider")) as IMetricsProvider;
82 m_backends.Add(MetricsProvider); 89 m_backends.Add(MetricsProvider);
83 90
84 try 91 try
85 { 92 {
86 InitHttpServer(ConfigFile.HttpPort); 93 InitHttpServer((uint) ConfigFile.Configs["Config"].GetInt("listen_port"));
87 } 94 }
88 catch (Exception ex) 95 catch (Exception ex)
89 { 96 {
90 Logger.Log.Error("Initializing the HTTP server failed, shutting down: " + ex.Message); 97 m_log.Error("[ASSETINVENTORY] Initializing the HTTP server failed, shutting down: " + ex.Message);
91 Shutdown(); 98 Shutdown();
92 return false; 99 return false;
93 } 100 }
94 101
95 AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", ConfigFile.AuthenticationProvider) as IAuthenticationProvider; 102 AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", pluginConfig.GetString("authentication_provider")) as IAuthenticationProvider;
96 m_backends.Add(AuthenticationProvider); 103 m_backends.Add(AuthenticationProvider);
97 104
98 AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", ConfigFile.AuthorizationProvider) as IAuthorizationProvider; 105 AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", pluginConfig.GetString("authorization_provider")) as IAuthorizationProvider;
99 m_backends.Add(AuthorizationProvider); 106 m_backends.Add(AuthorizationProvider);
100 107
101 m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", ConfigFile.Frontends)); 108 m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", pluginConfig.GetString("frontends")));
102 109
103 return true; 110 return true;
104 } 111 }
@@ -117,18 +124,18 @@ namespace OpenSim.Grid.AssetInventoryServer
117 { 124 {
118 foreach (IAssetInventoryServerPlugin plugin in m_frontends) 125 foreach (IAssetInventoryServerPlugin plugin in m_frontends)
119 { 126 {
120 Logger.Log.Debug("Disposing plugin " + plugin.Name); 127 m_log.Debug("[ASSETINVENTORY] Disposing plugin " + plugin.Name);
121 try { plugin.Dispose(); } 128 try { plugin.Dispose(); }
122 catch (Exception ex) 129 catch (Exception ex)
123 { Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } 130 { m_log.ErrorFormat("[ASSETINVENTORY] Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
124 } 131 }
125 132
126 foreach (IAssetInventoryServerPlugin plugin in m_backends) 133 foreach (IAssetInventoryServerPlugin plugin in m_backends)
127 { 134 {
128 Logger.Log.Debug("Disposing plugin " + plugin.Name); 135 m_log.Debug("[ASSETINVENTORY] Disposing plugin " + plugin.Name);
129 try { plugin.Dispose(); } 136 try { plugin.Dispose(); }
130 catch (Exception ex) 137 catch (Exception ex)
131 { Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } 138 { m_log.ErrorFormat("[ASSETINVENTORY] Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
132 } 139 }
133 140
134 if (HttpServer != null) 141 if (HttpServer != null)
@@ -140,7 +147,7 @@ namespace OpenSim.Grid.AssetInventoryServer
140 m_httpServer = new BaseHttpServer(port); 147 m_httpServer = new BaseHttpServer(port);
141 m_httpServer.Start(); 148 m_httpServer.Start();
142 149
143 Logger.Log.Info("Asset server is listening on port " + port); 150 m_log.Info("[ASSETINVENTORY] AssetInventory server is listening on port " + port);
144 } 151 }
145 152
146 private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider) 153 private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider)