From e41f761e0d808f39d58766cb8f888cda3b5a6043 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:28:51 +0000 Subject: - add restrictions and error handling to plugin loading in AssetInventoryServer - assign shorter names to each AssetInventory plugin - modify AssetInventoryServer.ini.example file so it works out of the box --- .../AssetInventoryServer/AssetInventoryServer.cs | 74 ++++++++++++++-------- .../Plugins/AuthorizeAllPlugin.cs | 2 +- .../Plugins/BrowseFrontendPlugin.cs | 2 +- .../Plugins/NullAuthenticationPlugin.cs | 2 +- .../Plugins/NullMetricsPlugin.cs | 2 +- .../Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs | 2 +- .../Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | 3 +- .../OpenSim/OpenSimInventoryFrontendPlugin.cs | 2 +- .../OpenSim/OpenSimInventoryStoragePlugin.cs | 3 +- .../Plugins/ReferenceFrontendPlugin.cs | 2 +- .../Plugins/Simple/SimpleAssetStoragePlugin.cs | 2 +- .../Plugins/Simple/SimpleInventoryStoragePlugin.cs | 2 +- 12 files changed, 61 insertions(+), 37 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs index 07cbade..5e8a6f1 100644 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs +++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs @@ -75,15 +75,16 @@ namespace OpenSim.Grid.AssetInventoryServer return false; } - IConfig pluginConfig = ConfigFile.Configs["Plugins"]; - - StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider", pluginConfig.GetString("asset_storage_provider")) as IAssetStorageProvider; + StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider", + "asset_storage_provider", false) as IAssetStorageProvider; m_backends.Add(StorageProvider); - InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryStorageProvider", pluginConfig.GetString("inventory_storage_provider")) as IInventoryStorageProvider; + InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryStorageProvider", + "inventory_storage_provider", false) as IInventoryStorageProvider; m_backends.Add(InventoryProvider); - MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", pluginConfig.GetString("metrics_provider")) as IMetricsProvider; + MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", + "metrics_provider", false) as IMetricsProvider; m_backends.Add(MetricsProvider); try @@ -97,13 +98,19 @@ namespace OpenSim.Grid.AssetInventoryServer return false; } - AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", pluginConfig.GetString("authentication_provider")) as IAuthenticationProvider; + AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", + "authentication_provider", false) as IAuthenticationProvider; m_backends.Add(AuthenticationProvider); - AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", pluginConfig.GetString("authorization_provider")) as IAuthorizationProvider; + AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", + "authorization_provider", false) as IAuthorizationProvider; m_backends.Add(AuthorizationProvider); - m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", pluginConfig.GetString("frontends"))); + m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", "frontends")); + + // Inform the user if we don't have any frontends at this point. + if (m_frontends.Count == 0) + m_log.Info("[ASSETINVENTORY]: Starting with no frontends loaded, which isn't extremely useful. Did you set the 'frontends' configuration parameter?"); return true; } @@ -148,32 +155,47 @@ namespace OpenSim.Grid.AssetInventoryServer m_log.Info("[ASSETINVENTORY]: AssetInventory server is listening on port " + port); } - private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider) + private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string configParam, bool optional) { - PluginLoader loader = new PluginLoader(new AssetInventoryServerPluginInitialiser(this)); + IAssetInventoryServerPlugin result = null; + List plugins = LoadAssetInventoryServerPlugins(addinPath, configParam); - if (provider == String.Empty) - loader.Add(addinPath); - else - loader.Add(addinPath, new PluginIdFilter(provider)); - //loader.Add(addinPath, new PluginCountConstraint(1)); - - loader.Load(); + if (plugins.Count == 1) + { + result = plugins[0]; + } + else if (plugins.Count > 1) + { + m_log.ErrorFormat("[ASSETINVENTORY]: Only 1 plugin expected for extension point '{0}', {1} plugins loaded. Check the '{2}' parameter in the config file.", + addinPath, plugins.Count, configParam); + Shutdown(); + Environment.Exit(0); + } + else if (!optional) + { + m_log.ErrorFormat("[ASSETINVENTORY]: The extension point '{0}' is not optional. Check the '{1}' parameter in the config file.", addinPath, configParam); + Shutdown(); + Environment.Exit(0); + } - return loader.Plugin; + return result; } - private List LoadAssetInventoryServerPlugins(string addinPath, string provider) + private List LoadAssetInventoryServerPlugins(string addinPath, string configParam) { PluginLoader loader = new PluginLoader(new AssetInventoryServerPluginInitialiser(this)); + loader.Add(addinPath, new PluginIdFilter(ConfigFile.Configs["Plugins"].GetString(configParam))); - if (provider == String.Empty) - loader.Add(addinPath); - else - loader.Add(addinPath, new PluginIdFilter(provider)); - //loader.Add(addinPath, new PluginCountConstraint(1)); - - loader.Load(); + try + { + loader.Load(); + } + catch (PluginNotInitialisedException e) + { + m_log.ErrorFormat("[ASSETINVENTORY]: Error initialising plugin '{0}' for extension point '{1}'.", e.Message, addinPath); + Shutdown(); + Environment.Exit(0); + } return loader.Plugins; } diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs index 9e3a421..7fd1ee8 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs @@ -74,7 +74,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public string Name { - get { return "AssetInventoryServer Authorize All"; } + get { return "AuthorizeAll"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs index 6c98612..4ed8d87 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs @@ -83,7 +83,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public string Name { - get { return "AssetInventoryServer Browse asset frontend"; } + get { return "BrowseFrontend"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs index 1fbe780..e958591 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs @@ -74,7 +74,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public string Name { - get { return "AssetInventoryServer Null authentication"; } + get { return "NullAuthentication"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs index eef98dc..84e526a 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs @@ -145,7 +145,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public string Name { - get { return "AssetInventoryServer Null Metrics"; } + get { return "NullMetrics"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs index d2a87e6..887ab68 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs @@ -86,7 +86,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim public string Name { - get { return "AssetInventoryServer OpenSim asset frontend"; } + get { return "OpenSimAssetFrontend"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index 69dcff3..ad68c57 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs @@ -183,6 +183,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim catch (Exception e) { m_log.WarnFormat("[OPENSIMASSETSTORAGE]: Failure loading data plugin: {0}", e.ToString()); + throw new PluginNotInitialisedException(Name); } } @@ -206,7 +207,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim public string Name { - get { return "AssetInventoryServer OpenSim asset storage provider"; } + get { return "OpenSimAssetStorage"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs index 76d7122..5e7f0c6 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs @@ -91,7 +91,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim public string Name { - get { return "AssetInventoryServer OpenSim inventory frontend"; } + get { return "OpenSimInventoryFrontend"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs index 2f5d2ca..1ead422 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs @@ -815,6 +815,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim catch (Exception e) { m_log.WarnFormat("[OPENSIMINVENTORYSTORAGE]: Failure loading data plugin: {0}", e.ToString()); + throw new PluginNotInitialisedException(Name); } } @@ -839,7 +840,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim public string Name { - get { return "AssetInventoryServer OpenSim inventory storage provider"; } + get { return "OpenSimInventoryStorage"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs index af10393..f411127 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs @@ -87,7 +87,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins public string Name { - get { return "AssetInventoryServer Reference asset frontend"; } + get { return "ReferenceFrontend"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs index 26c34e9..4e5526b 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs @@ -229,7 +229,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple public string Name { - get { return "AssetInventoryServer Simple asset storage provider"; } + get { return "SimpleAssetStorage"; } } #endregion IPlugin implementation diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs index fee8837..a48be2e 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs @@ -619,7 +619,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple public string Name { - get { return "AssetInventoryServer Simple inventory storage provider"; } + get { return "SimpleInventoryStorage"; } } #endregion IPlugin implementation -- cgit v1.1