- 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
0.6.3-post-fixes
Mike Mazur 2009-02-16 02:28:51 +00:00
parent efbb44b98a
commit e41f761e0d
13 changed files with 69 additions and 45 deletions

View File

@ -75,15 +75,16 @@ namespace OpenSim.Grid.AssetInventoryServer
return false; return false;
} }
IConfig pluginConfig = ConfigFile.Configs["Plugins"]; StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider",
"asset_storage_provider", false) as IAssetStorageProvider;
StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider", pluginConfig.GetString("asset_storage_provider")) as IAssetStorageProvider;
m_backends.Add(StorageProvider); 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); 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); m_backends.Add(MetricsProvider);
try try
@ -97,13 +98,19 @@ namespace OpenSim.Grid.AssetInventoryServer
return false; 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); 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_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; return true;
} }
@ -148,32 +155,47 @@ namespace OpenSim.Grid.AssetInventoryServer
m_log.Info("[ASSETINVENTORY]: AssetInventory server is listening on port " + port); 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<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this)); IAssetInventoryServerPlugin result = null;
List<IAssetInventoryServerPlugin> plugins = LoadAssetInventoryServerPlugins(addinPath, configParam);
if (provider == String.Empty) if (plugins.Count == 1)
loader.Add(addinPath); {
else result = plugins[0];
loader.Add(addinPath, new PluginIdFilter(provider)); }
//loader.Add(addinPath, new PluginCountConstraint(1)); else if (plugins.Count > 1)
{
loader.Load(); 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);
return loader.Plugin; 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);
} }
private List<IAssetInventoryServerPlugin> LoadAssetInventoryServerPlugins(string addinPath, string provider) return result;
}
private List<IAssetInventoryServerPlugin> LoadAssetInventoryServerPlugins(string addinPath, string configParam)
{ {
PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this)); PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this));
loader.Add(addinPath, new PluginIdFilter(ConfigFile.Configs["Plugins"].GetString(configParam)));
if (provider == String.Empty) try
loader.Add(addinPath); {
else
loader.Add(addinPath, new PluginIdFilter(provider));
//loader.Add(addinPath, new PluginCountConstraint(1));
loader.Load(); 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; return loader.Plugins;
} }

View File

@ -74,7 +74,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public string Name public string Name
{ {
get { return "AssetInventoryServer Authorize All"; } get { return "AuthorizeAll"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -83,7 +83,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public string Name public string Name
{ {
get { return "AssetInventoryServer Browse asset frontend"; } get { return "BrowseFrontend"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -74,7 +74,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public string Name public string Name
{ {
get { return "AssetInventoryServer Null authentication"; } get { return "NullAuthentication"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -145,7 +145,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public string Name public string Name
{ {
get { return "AssetInventoryServer Null Metrics"; } get { return "NullMetrics"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -86,7 +86,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
public string Name public string Name
{ {
get { return "AssetInventoryServer OpenSim asset frontend"; } get { return "OpenSimAssetFrontend"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -183,6 +183,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
catch (Exception e) catch (Exception e)
{ {
m_log.WarnFormat("[OPENSIMASSETSTORAGE]: Failure loading data plugin: {0}", e.ToString()); 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 public string Name
{ {
get { return "AssetInventoryServer OpenSim asset storage provider"; } get { return "OpenSimAssetStorage"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -91,7 +91,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
public string Name public string Name
{ {
get { return "AssetInventoryServer OpenSim inventory frontend"; } get { return "OpenSimInventoryFrontend"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -815,6 +815,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
catch (Exception e) catch (Exception e)
{ {
m_log.WarnFormat("[OPENSIMINVENTORYSTORAGE]: Failure loading data plugin: {0}", e.ToString()); 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 public string Name
{ {
get { return "AssetInventoryServer OpenSim inventory storage provider"; } get { return "OpenSimInventoryStorage"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -87,7 +87,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public string Name public string Name
{ {
get { return "AssetInventoryServer Reference asset frontend"; } get { return "ReferenceFrontend"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -229,7 +229,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
public string Name public string Name
{ {
get { return "AssetInventoryServer Simple asset storage provider"; } get { return "SimpleAssetStorage"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -619,7 +619,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
public string Name public string Name
{ {
get { return "AssetInventoryServer Simple inventory storage provider"; } get { return "SimpleInventoryStorage"; }
} }
#endregion IPlugin implementation #endregion IPlugin implementation

View File

@ -101,12 +101,12 @@ frontends = ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,Brow
; The database provider determines which database to use. Any database backend ; The database provider determines which database to use. Any database backend
; supported by OpenSim is supported. ; supported by OpenSim is supported.
;asset_database_provider = "OpenSim.Data.SQLite.dll" asset_database_provider = "OpenSim.Data.SQLite.dll"
asset_database_provider = "OpenSim.Data.MySQL.dll" ;asset_database_provider = "OpenSim.Data.MySQL.dll"
;asset_database_provider = "OpenSim.Data.NHibernate.dll" ;asset_database_provider = "OpenSim.Data.NHibernate.dll"
;inventory_database_provider = "OpenSim.Data.SQLite.dll" inventory_database_provider = "OpenSim.Data.SQLite.dll"
inventory_database_provider = "OpenSim.Data.MySQL.dll" ;inventory_database_provider = "OpenSim.Data.MySQL.dll"
;inventory_database_provider = "OpenSim.Data.NHibernate.dll" ;inventory_database_provider = "OpenSim.Data.NHibernate.dll"
; Database connection string used by the OpenSim MySQL backend. If these lines ; Database connection string used by the OpenSim MySQL backend. If these lines
@ -117,12 +117,12 @@ inventory_database_provider = "OpenSim.Data.MySQL.dll"
; modification. ; modification.
; For SQLite ; For SQLite
;asset_database_connect = "URI=file:Asset.db,version=3" asset_database_connect = "URI=file:Asset.db,version=3"
;inventory_database_connect = "URI=file:Inventory.db,version=3" inventory_database_connect = "URI=file:Inventory.db,version=3"
; For MySQL ; For MySQL
asset_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" ;asset_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;"
inventory_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" ;inventory_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;"
; For NHibernate ; For NHibernate
;asset_database_connect = "SQLiteDialect;SQLite20Driver;Data Source=file:Asset.db;Version=3" ;asset_database_connect = "SQLiteDialect;SQLite20Driver;Data Source=file:Asset.db;Version=3"