From 679533f632110d432889d81e0931a529fe1d12e5 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 10 Apr 2012 14:36:24 -0400 Subject: [PATCH] Work on loading new addins --- .../IntegrationServiceBase.cs | 57 ++----------------- .../IntegrationService/PluginManager.cs | 25 ++++++-- 2 files changed, 27 insertions(+), 55 deletions(-) diff --git a/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs b/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs index 7216db25d8..fd310ae188 100644 --- a/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs +++ b/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs @@ -89,7 +89,10 @@ namespace OpenSim.Services.IntegrationService "."); AddinRegistry registry = new AddinRegistry(RegistryLocation, "."); + + suppress_console_output_(true); m_PluginManager = new PluginManager(registry); + suppress_console_output_(false); // Deal with files only for now - will add url/environment later m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty); @@ -104,64 +107,16 @@ namespace OpenSim.Services.IntegrationService return; } - AddinManager.Initialize (RegistryLocation); - - suppress_console_output_(true); - + AddinManager.Registry.Update (); AddinManager.AddinLoaded += on_addinloaded_; AddinManager.AddinLoadError += on_addinloaderror_; AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded; AddinManager.AddinEngine.ExtensionChanged += HandleAddinManagerAddinEngineExtensionChanged; - AddinManager.Registry.Update (); - - suppress_console_output_(false); - - AddinManager.AddExtensionNodeHandler ("/OpenSim/IntegrationService", OnExtensionChanged); - // **** Moving this -// foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService")) -// { -// string ConfigPath = String.Format("{0}/(1)", m_IntegrationConfigLoc,cmd.ConfigName); -// IConfigSource PlugConfig = Ux.GetConfigSource(m_IntegrationConfigLoc, cmd.ConfigName); -// -// // We maintain a configuration per-plugin to enhance modularity -// // If ConfigSource is null, we will get the default from the repo -// // and write it to our directory -// // Fetch the starter ini -// if (PlugConfig == null) -// { -// -// m_log.InfoFormat("[INTEGRATION SERVICE]: Fetching starter config for {0} from {1}", cmd.Name, cmd.DefaultConfig); -// -// // Send the default data service -// IConfig DataService = m_ConfigSource.Configs["DatabaseService"]; -// m_log.InfoFormat("[INTEGRATION SERVICE]: Writing initial config to {0}", cmd.ConfigName); -// -// IniConfigSource source = new IniConfigSource(); -// IConfig Init = source.AddConfig("DatabaseService"); -// Init.Set("StorageProvider",(string)DataService.GetString("StorageProvider")); -// Init.Set("ConnectionString", (string)DataService.GetString("ConnectionString")); -// -// -// PlugConfig = Ux.LoadInitialConfig(cmd.DefaultConfig); -// -// source.Merge(PlugConfig); -// -// source.Save(Path.Combine(m_IntegrationConfigLoc, cmd.ConfigName)); -// -// PlugConfig = source; -// } -// -// // Initialise and bring up the plugin -// // Need to take down the plugin when disabling it. -// cmd.Init (PlugConfig); -// server.AddStreamHandler((IRequestHandler)cmd); -// m_log.InfoFormat("[INTEGRATION SERVICE]: Loading IntegrationService plugin {0}", cmd.Name); -// } } void HandleAddinManagerAddinEngineExtensionChanged (object sender, ExtensionEventArgs args) @@ -268,13 +223,13 @@ namespace OpenSim.Services.IntegrationService PlugConfig = source; } - m_log.InfoFormat("[INTEGRATION SERVICE]: In Loading Plugin {0}", plugin.Name); + m_log.InfoFormat("[INTEGRATION SERVICE]: ****** In Loading Plugin {0}", plugin.Name); plugin.Init(PlugConfig, m_Server); } private void UnLoadingPlugin(IntegrationPlugin plugin) { - + plugin.Unload(); } } } diff --git a/OpenSim/Services/IntegrationService/PluginManager.cs b/OpenSim/Services/IntegrationService/PluginManager.cs index 89f7beea18..7f18407b68 100644 --- a/OpenSim/Services/IntegrationService/PluginManager.cs +++ b/OpenSim/Services/IntegrationService/PluginManager.cs @@ -86,7 +86,7 @@ namespace OpenSim.Services.IntegrationService { Addin[] addins = GetSortedAddinList("IntegrationPlugin"); - int n = Convert.ToInt16(args[2]); + int n = Convert.ToInt16(args[1]); if (n > (addins.Length -1)) { MainConsole.Instance.Output("Selection out of range"); @@ -94,9 +94,12 @@ namespace OpenSim.Services.IntegrationService } Addin addin = addins[n]; + MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id); + AddinManager.Registry.DisableAddin(addin.Id); + addin.Enabled = false; IProgressStatus ps = new ConsoleProgressStatus(true); Uninstall(ps, addin.Id); - m_Registry.Rebuild(null); + // m_Registry.Rebuild(null); return; } @@ -321,10 +324,24 @@ namespace OpenSim.Services.IntegrationService } Addin addin = addins[n]; + addin.Enabled = true; AddinManager.Registry.EnableAddin(addin.Id); - AddinManager.Registry.Update(); - AddinManager.AddinEngine.LoadAddin(null, addin.Id); + // AddinManager.Registry.Update(); + if(m_Registry.IsAddinEnabled(addin.Id)) + { + ConsoleProgressStatus ps = new ConsoleProgressStatus(true); + if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id)) + { + AddinManager.Registry.Rebuild(ps); + AddinManager.AddinEngine.LoadAddin(ps, addin.Id); + } + + } + else + { + MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name); + } return; }